Fix mypy complaint for class that is dynamic created by pydantic_model_creator
Description
After remove the module = ["examples.*"] section in pyproject.toml and then run mypy main.py in examples/fastapi/, it raises:
main.py:36: error: Variable "models.User_Pydantic" is not valid as a type [valid-type]
main.py:36: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
main.py:42: error: Variable "models.UserIn_Pydantic" is not valid as a type [valid-type]
main.py:42: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
main.py:43: error: UserIn_Pydantic? has no attribute "model_dump" [attr-defined]
main.py:53: error: Variable "models.UserIn_Pydantic" is not valid as a type [valid-type]
main.py:53: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
main.py:54: error: UserIn_Pydantic? has no attribute "model_dump" [attr-defined]
Found 5 errors in 1 file (checked 1 source file)
cd examples/fastapi && pytest _tests.py show warning message with newer version of httpx:
site-packages/httpx/_client.py:1426: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=ASGITransport(app=...)' instead.
warnings.warn(message, DeprecationWarning)
Fix mypy complaint for class that is dynamic created by
pydantic_model_creator
Description
module = ["examples.*"]
section in pyproject.toml and then runmypy main.py
in examples/fastapi/, it raises:cd examples/fastapi && pytest _tests.py
show warning message with newer version of httpx:Motivation and Context
Our team have some projects tha using
fastapi+tortoise-orm+mypy
. It cost me a lot of time to find a pythonic way to fix mypy complaint about Xxx_Pydantic, finally this comment https://github.com/pydantic/pydantic/issues/615#issuecomment-504618897 give me the answer.How Has This Been Tested?
make ci
Checklist: