Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
help() output oflambda with manually set__annotations__ is slightly scrambled.
f = lambda a, b, c: 0 # lambdas cannot have annotationsf.__annotations__['return'] = int # but you can set them manuallyhelp(f) # superfluous ")" and missed last char# <lambda> lambda a, b, c) -> inimport inspectprint(inspect.signature(f)) # correctly displays# (a, b, c) -> intNote
This is a minor glitch for an atypical (perhaps even unsupported) use of annotations.
Hypothesis
Perhapshelp() uses (the same logic as)inspect.signature() and (to reflectlambda syntax) wants to drop the brackets "(...)", but then has aone-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