Closed
Description
Bug report
help()
output of lambda
with manually set __annotations__
is slightly scrambled.
f = lambda a, b, c: 0 # lambdas cannot have annotations
f.__annotations__['return'] = int # but you can set them manually
help(f) # superfluous ")" and missed last char
# <lambda> lambda a, b, c) -> in
import inspect
print(inspect.signature(f)) # correctly displays
# (a, b, c) -> int
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 reflect lambda
syntax) wants to drop the brackets "(...)", but then has a one-off error for its text slice (picking ") -> in"
instead of " -> int"
)
Environment
- CPython versions tested on: 3.6.8 - 3.11.4, 3.12.0b4
- Operating system and architecture: Windows 11