Open liu-junyong opened 1 year ago
Seems to be the same as https://github.com/tortoise/tortoise-orm/issues/1440
up to now:
pydantic-core: 2.7 fix: https://github.com/pydantic/pydantic-core/pull/934
pydantic: last resource: with commit: https://github.com/pydantic/pydantic/commit/2575e71894a32dc615f9fa7a94ff37bb604a48a8
run result:
File "/Users/liujunyong/python310env/lib/python3.10/site-packages/tortoise/contrib/pydantic/creator.py", line 377, in pydantic_model_creator annotation = get_annotations(cls, func).get("return", None) File "/Users/liujunyong/python310env/lib/python3.10/site-packages/tortoise/contrib/pydantic/utils.py", line 18, in get_annotations return typing.get_type_hints(method or cls, globalns=globalns) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 1856, in get_type_hints raise TypeError('{!r} is not a module, class, method, ' TypeError: <property object at 0x11e066110> is not a module, class, method, or function.
up to now:
pydantic-core: 2.7 fix: https://github.com/pydantic/pydantic-core/pull/934
pydantic: last resource: with commit: https://github.com/pydantic/pydantic/commit/2575e71894a32dc615f9fa7a94ff37bb604a48a8
run result:
File "/Users/liujunyong/python310env/lib/python3.10/site-packages/tortoise/contrib/pydantic/creator.py", line 377, in pydantic_model_creator annotation = get_annotations(cls, func).get("return", None) File "/Users/liujunyong/python310env/lib/python3.10/site-packages/tortoise/contrib/pydantic/utils.py", line 18, in get_annotations return typing.get_type_hints(method or cls, globalns=globalns) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 1856, in get_type_hints raise TypeError('{!r} is not a module, class, method, ' TypeError: <property object at 0x11e066110> is not a module, class, method, or function.
Did you added a @property
decorator to the computed method?
modify from example: https://github.com/tortoise/tortoise-orm/blob/develop/examples/fastapi/models.py show full_name and hide name:
AttributeError: 'User' object has no attribute 'name'
Describe the bug tortoise-orm: v0.20.0 pydantic : v2.3.0
Expected behavior like pydantic v1, computed first then exclude