You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I need to check its return value every time even if I actually passing non-None value...
pet = Pet.from_dict(pet_dict)
assert(pet is not None)
# or
if pet is None:
raise Exception("should not be reached here")
Describe the solution you'd like
Remove Optional[] from the obj parameter and the return value.
def from_dict(cls, obj: Dict[str, Any]) -> Self:
"""Create an instance of Pet from a dict"""
if not isinstance(obj, dict):
return cls.model_validate(obj)
...
Is your feature request related to a problem? Please describe.
This generated
from_dict
method returnsNone
only ifNone
is passed asobj
.openapi-generator/samples/client/echo_api/python/openapi_client/models/pet.py
Lines 101 to 118 in c96d308
So I need to check its return value every time even if I actually passing non-None value...
Describe the solution you'd like
Remove
Optional[]
from theobj
parameter and the return value.Describe alternatives you've considered
@overload
also provides better typing:but I don't think this method should accept
None
value. I'm agree with checking None in caller side, like the commit which introduce None checking does.Additional context
The text was updated successfully, but these errors were encountered: