@@ -47,9 +47,7 @@ from typing import (
4747 IO,
4848 Mapping,
4949 Callable,
50- TypeVar,
5150 MutableMapping,
52- Type,
5351 List,
5452)
5553
@@ -60,13 +58,13 @@ except ImportError:
6058import xml.etree.ElementTree as ET
6159
6260import isodate # type: ignore
61+ from typing_extensions import Self
6362
6463from {{ code_model.core_library }}.exceptions import DeserializationError, SerializationError
6564from {{ code_model.core_library }}.serialization import NULL as CoreNull
6665
6766_BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
6867
69- ModelType = TypeVar("ModelType", bound="Model")
7068JSON = MutableMapping[str, Any]
7169
7270
@@ -383,25 +381,25 @@ class Model:
383381 return client_models
384382
385383 @classmethod
386- def deserialize(cls: Type[ModelType] , data: Any, content_type: Optional[str] = None) -> ModelType :
384+ def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self :
387385 """Parse a str using the RestAPI syntax and return a model.
388386
389387 :param str data: A str using RestAPI structure. JSON by default.
390388 :param str content_type: JSON by default, set application/xml if XML.
391389 :returns: An instance of this model
392390 :raises DeserializationError: if something went wrong
393- :rtype: ModelType
391+ :rtype: Self
394392 """
395393 deserializer = Deserializer(cls._infer_class_models())
396394 return deserializer(cls.__name__, data, content_type=content_type) # type: ignore
397395
398396 @classmethod
399397 def from_dict(
400- cls: Type[ModelType] ,
398+ cls,
401399 data: Any,
402400 key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None,
403401 content_type: Optional[str] = None,
404- ) -> ModelType :
402+ ) -> Self :
405403 """Parse a dict using given key extractor return a model.
406404
407405 By default consider key
@@ -412,8 +410,8 @@ class Model:
412410 :param function key_extractors: A key extractor function.
413411 :param str content_type: JSON by default, set application/xml if XML.
414412 :returns: An instance of this model
415- :raises DeserializationError: if something went wrong
416- :rtype: ModelType
413+ :raises: DeserializationError if something went wrong
414+ :rtype: Self
417415 """
418416 deserializer = Deserializer(cls._infer_class_models())
419417 deserializer.key_extractors = ( # type: ignore
0 commit comments