@@ -11,8 +11,8 @@ import pprint
1111import re
1212import tempfile
1313from types import MappingProxyType
14- from typing import Collection, Mapping, Union
15- from typing_extensions import Final
14+ from typing import Collection, Mapping, Union, overload
15+ from typing_extensions import Final, Self
1616
1717from dateutil.parser import parse
1818
@@ -89,7 +89,7 @@ def composed_model_input_classes(cls):
8989 return []
9090
9191
92- class OpenApiModel(object) :
92+ class OpenApiModel:
9393 """The base class for all OpenAPIModels.
9494
9595 :var attribute_map: The key is attribute name and the value is json
@@ -173,6 +173,18 @@ class OpenApiModel(object):
173173 """Get the value of an attribute using dot notation: `instance.attr`."""
174174 return self.__getitem__(attr)
175175
176+ @overload
177+ def __new__(cls, arg: None) -> None: # type: ignore
178+ ...
179+
180+ @overload
181+ def __new__(cls, arg: "ModelComposed") -> Self:
182+ ...
183+
184+ @overload
185+ def __new__(cls, *args, **kwargs) -> Self:
186+ ...
187+
176188 def __new__(cls, *args, **kwargs):
177189 if len(args) == 1:
178190 arg = args[0]
@@ -185,7 +197,7 @@ class OpenApiModel(object):
185197 oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg)
186198 return oneof_instance
187199
188- return super(OpenApiModel, cls ).__new__(cls)
200+ return super().__new__(cls)
189201
190202 def __init__(self, kwargs):
191203 """
0 commit comments