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
It should be possible to obtain value expressions used as generic arguments in an AnalyzeTypeContext
For example, given typing.Annotated[builtins.int, "hello world"], I want to obtain "hello world", which is not a type, but a value.
Pitch
This feature would enable type checking of dependencies in FastAPI. FastAPI dependency injection allows specification of dependencies like this:
In this situation, MyPy should (with the help of a FastAPI specific plugin) be able to verify that the return type of my_dependency matches the type, which is the first generic argument of Annotated.
Currently, a plugin could theoretically obtain dependencies using get_type_analyze_hook. However, when inspecting the type arguments (ctx.type.args), any non-type argument to Annotated is not accessible within the scope of this hook.
Furthermore, this could potentially enable additional inspections relating to Pydantic fields.
The text was updated successfully, but these errors were encountered:
Feature
It should be possible to obtain value expressions used as generic arguments in an
AnalyzeTypeContext
For example, given
typing.Annotated[builtins.int, "hello world"]
, I want to obtain "hello world", which is not a type, but a value.Pitch
This feature would enable type checking of dependencies in FastAPI. FastAPI dependency injection allows specification of dependencies like this:
In this situation, MyPy should (with the help of a FastAPI specific plugin) be able to verify that the return type of
my_dependency
matches the type, which is the first generic argument ofAnnotated
.Currently, a plugin could theoretically obtain dependencies using
get_type_analyze_hook
. However, when inspecting the type arguments (ctx.type.args
), any non-type argument toAnnotated
is not accessible within the scope of this hook.Furthermore, this could potentially enable additional inspections relating to Pydantic fields.
The text was updated successfully, but these errors were encountered: