-
Notifications
You must be signed in to change notification settings - Fork 275
Document the trouble with lambdas in the guides #2105
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
base: main
Are you sure you want to change the base?
Conversation
| ``f: Callable[[object], object] = lambda x: x`` | ||
|
|
||
| Type comments on function definitions do not actually work on lambda, nor do | ||
| normal type comments help (although you can use a type comment on an assignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to not mention type comments? They're effectively deprecated, and in the context we're discussing I don't think they add anything over variable annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are a random intrusion of esoterica here, but they are a potential answer to "where would the type annotations go?", so I think it makes sense to mention that they don't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel many readers probably won't even know what type comments are, so discussing them is more likely to confuse than to enlighten.
| 5. If you want to annotate the type of lambdas, you can bind them and annotate them | ||
| there. | ||
|
|
||
| 6. Most type checkers have a setting that will warn you if anything gets deduced as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be useful to mention what those rules are for at least some type checkers (minimally mypy and pyright), so the guide is more practically useful.
Closes #2020