Replies: 8 comments
-
Adding more information:
I'm not sure if the info that I've provided help us. EDIT [19/10/2022]: I really didn't know much about a lot of stuff at the time. 👀 |
Beta Was this translation helpful? Give feedback.
-
I'm running across this problem in Python 3.8 WITHOUT the |
Beta Was this translation helpful? Give feedback.
-
By marking the parameter type as
Looked a little farther and both |
Beta Was this translation helpful? Give feedback.
-
I'm running into this problem too. It appears to be specific to objects used as dependencies via the Note that regular function dependencies work fine with |
Beta Was this translation helpful? Give feedback.
-
Bump on this thread, exact same issue as original poster. |
Beta Was this translation helpful? Give feedback.
-
You have may better luck raising this on the pydantic repository |
Beta Was this translation helpful? Give feedback.
-
This is still a problem, not sure why it's a discussion now. |
Beta Was this translation helpful? Give feedback.
-
I guess the following code can be found in pydantic: # pydantic/typing.py
if sys.version_info < (3, 9):
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
return type_._evaluate(globalns, localns)
else:
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
# Even though it is the right signature for python 3.9, mypy complains with
# `error: Too many arguments for "_evaluate" of "ForwardRef"` hence the cast...
return cast(Any, type_)._evaluate(globalns, localns, set()) You'll notice that they are using internal methods of Users of FastAPI can workaround this annoyance by providing a
Of course, instead of callings |
Beta Was this translation helpful? Give feedback.
-
Minimal working example:
Description
Environment
Additional context
The issue only happens when the
from __future__ import annotations
import is added. Without this import it works fine.We depend on this import in our code. We don't want to use strings for type definitions.
FastAPI seems to have issues with
from __future__ import annotations
. Here is a similar issues from the past that got resolved: #446Beta Was this translation helpful? Give feedback.
All reactions