Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions generator/plugins/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _reset(self):
self._imports: List[str] = [
"import enum",
"import functools",
"from typing import Any, Dict, Optional, Sequence, Tuple, Union",
"from typing import Any, Dict, Literal, Optional, Sequence, Tuple, Union",
"import attrs",
"from . import validators",
]
Expand Down Expand Up @@ -863,7 +863,7 @@ def _add_requests(self, lsp_mode: model.LSPModel) -> None:
f"{indent}id:Union[int, str] = attrs.field()",
f'{indent}"""The request id."""',
f"{indent}params: {params_type} ={params_field}",
f'{indent}method: str = "{request.method}"',
f'{indent}method: Literal["{request.method}"] = "{request.method}"',
f'{indent}"""The method to be invoked."""',
f'{indent}jsonrpc: str = attrs.field(default="2.0")',
],
Expand Down Expand Up @@ -908,7 +908,7 @@ def _add_notifications(self, lsp_mode: model.LSPModel) -> None:
f"class {class_name}Notification:",
f'{indent}"""{doc}"""' if notification.documentation else "",
f"{indent}params: {params_type} = {params_field}",
f"{indent}method:str = attrs.field(",
f'{indent}method: Literal["{notification.method}"] = attrs.field(',
f'validator=attrs.validators.in_(["{notification.method}"]),',
f'default="{notification.method}",',
")",
Expand Down
Loading