diff --git a/generator/plugins/python/utils.py b/generator/plugins/python/utils.py index 93c7db1..1700ede 100644 --- a/generator/plugins/python/utils.py +++ b/generator/plugins/python/utils.py @@ -208,7 +208,7 @@ def _reset(self): self._imports: List[str] = [ "import enum", "import functools", - "from typing import Any, Dict, Literal, Optional, Sequence, Tuple, Union", + "from typing import Any, Dict, Mapping, Literal, Optional, Sequence, Tuple, Union", "import attrs", "from . import validators", ] @@ -356,7 +356,7 @@ def _generate_type_name( if type_def.kind == "map": # This kind defines a dictionary like object. - return f"Dict[{self._generate_type_name(type_def.key, class_name, prefix)}, {self._generate_type_name(type_def.value, class_name, prefix)}]" + return f"Mapping[{self._generate_type_name(type_def.key, class_name, prefix)}, {self._generate_type_name(type_def.value, class_name, prefix)}]" if type_def.kind == "tuple": # This kind defined a tuple like object. diff --git a/packages/python/lsprotocol/types.py b/packages/python/lsprotocol/types.py index 5eb4333..eb0e3ba 100644 --- a/packages/python/lsprotocol/types.py +++ b/packages/python/lsprotocol/types.py @@ -9,7 +9,7 @@ import enum import functools -from typing import Any, Dict, Literal, Optional, Sequence, Tuple, Union +from typing import Any, Dict, Mapping, Literal, Optional, Sequence, Tuple, Union import attrs from . import validators @@ -1955,7 +1955,7 @@ class WorkspaceEdit: cause failure of the operation. How the client recovers from the failure is described by the client capability: `workspace.workspaceEdit.failureHandling`""" - changes: Optional[Dict[str, Sequence["TextEdit"]]] = attrs.field(default=None) + changes: Optional[Mapping[str, Sequence["TextEdit"]]] = attrs.field(default=None) """Holds changes to existing resources.""" document_changes: Optional[ @@ -1973,7 +1973,7 @@ class WorkspaceEdit: only plain `TextEdit`s using the `changes` property are supported.""" change_annotations: Optional[ - Dict[ChangeAnnotationIdentifier, "ChangeAnnotation"] + Mapping[ChangeAnnotationIdentifier, "ChangeAnnotation"] ] = attrs.field(default=None) """A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and delete file / folder operations. @@ -2452,7 +2452,7 @@ class DocumentDiagnosticReportPartialResult: # Since: 3.17.0 - related_documents: Dict[ + related_documents: Mapping[ str, Union["FullDocumentDiagnosticReport", "UnchangedDocumentDiagnosticReport"] ] = attrs.field() @@ -5642,7 +5642,7 @@ class RelatedFullDocumentDiagnosticReport: """The actual items.""" related_documents: Optional[ - Dict[ + Mapping[ str, Union[FullDocumentDiagnosticReport, "UnchangedDocumentDiagnosticReport"], ] @@ -5703,7 +5703,7 @@ class RelatedUnchangedDocumentDiagnosticReport: diagnostic request for the same document.""" related_documents: Optional[ - Dict[ + Mapping[ str, Union[FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport] ] ] = attrs.field(default=None)