-
Notifications
You must be signed in to change notification settings - Fork 258
Inferred Optional type of wrapper function arguments #775
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
Comments
Regardless of the merits of the issue, I think this is the wrong tracker — typing.py issues should be filed in bpo. |
Sorry, i will use the right tracker. |
wyfo
added a commit
to wyfo/apischema
that referenced
this issue
May 22, 2021
See python/typing#775 about get_type_hints not giving Optional type to wrapped function with None-defaulted parameters
wyfo
added a commit
to wyfo/apischema
that referenced
this issue
May 22, 2021
See python/typing#775 about get_type_hints not giving Optional type to wrapped function with None-defaulted parameters
francomattar
pushed a commit
to francomattar/apischema-benchmark-django-expert
that referenced
this issue
Sep 16, 2022
See python/typing#775 about get_type_hints not giving Optional type to wrapped function with None-defaulted parameters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
typing.get_type_hints
gives a different result for a wrapper created withfunctools.wraps
in case of inferredOptional
arguments (when the default value of the argument is None)This is because
get_type_hints
use the defauts of the wrapper (foo2
) and not those of the wrapped function (foo
).This is not consistent with some other tools like
inspect.signature
which gives the same signature (and thus same default argument) for the wrapped function and its wrapper.I think this case has simply been forgotten in the resolution of https://bugs.python.org/issue37838 (fixing
get_type_hints
not takingwraps
in account at all), because inferredOptional
is a kind deprecated feature (#275).The text was updated successfully, but these errors were encountered: