-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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
Linked PRs
AlexWaygood and Eclips4
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error