-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
help()
output of lambda
with manually set __annotations__
is one char off
#107155
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
Looks like a known issue :) Lines 1503 to 1506 in f443b54
|
Probably, we can just replace boundaries, |
…notations__` with `return` key.
f = lambda a, b: (a, b)
f.__annotations__['return'] = (int, int)
help(f)
# Help on function <lambda> in module __main__:
#
# <lambda> lambda a, b) -> (<class 'int'>, <class 'int'> This isn't currently a legal type annotation, but using tuple literals was proposed in PEP-677 and something similar could come up again -- a cleaner fix could be to handle the string conversion manually. I've suggested something on the PR. A |
The parentheses were removed because |
…notation (pythonGH-107401) (cherry picked from commit b9a9e3d) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Bug report
help()
output oflambda
with manually set__annotations__
is slightly scrambled.Note
This is a minor glitch for an atypical (perhaps even unsupported) use of annotations.
Hypothesis
Perhaps
help()
uses (the same logic as)inspect.signature()
and (to reflectlambda
syntax) wants to drop the brackets "(...)", but then has a one-off error for its text slice (picking") -> in"
instead of" -> int"
)Environment
Linked PRs
help(lambda_func)
whenlambda_func
has `__annotati… #107401The text was updated successfully, but these errors were encountered: