-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Annotated
dependencies are interpreted incorrectly when using PEP 695
-style type alias.
#10719
Comments
I'm in search for my first fastapi contribution and as such I might ask some not so clever questions. To this problem: This can done before dependencies.utils:328: if isinstance(annotation, TypeAliasType):
annotation = annotation.__value__ I can work in python<3.12 with something like: try:
from typing import TypeAliasType
except ImportError:
TypeAliasType = type("TypeAliasType", tuple(), dict(__value__=None)) # dict content needed? (more elegant approach appreciated)
Best regards and happy weekend, Torsten Zielke |
Confirm this issue. With Python 3.12 new
The dependency
|
I too keep running into this issue. |
Discussed in #10662
Originally posted by Rockmizu November 16, 2023
First Check
Commit to Help
Example Code
Description
When using the method in line 15:
to declare a type alias, FastAPI correctly interprets it and fills the
value
with123
forget_with_dep
.However, when using the new type alias syntax introduced in Python 3.12 (line 18):
FastAPI interprets it as a URL query parameter and responds with HTTP 422 Unprocessable Entity when accessing
/
.Expected Response
HTTP 200 OK
Actual Response
HTTP 422 Unprocessable Entity
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.104.1
Pydantic Version
2.5.1
Python Version
Python 3.12.0
Additional Context
No response
The text was updated successfully, but these errors were encountered: