-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add _typeshed.MaybeNone
as Any trick marker
#11815
Conversation
Also condense the explanation in CONTRIBUTING to what's actionable for the user. Closes: python#11094
Cc @Avasam |
This comment has been minimized.
This comment has been minimized.
# Marker for return types that include None, but where forcing the user to | ||
# check for None can be detrimental. Sometimes called "the Any trick". See | ||
# CONTRIBUTING.md for more information. | ||
MaybeNone: TypeAlias = Any # stable |
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.
MaybeNone: TypeAlias = Any # stable | |
MaybeNone: TypeAlias = Any |
This probably shouldn't be marked as stable yet, considering the import will fail in third party stubs until type checkers update their embedded version of typeshed.
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.
Stable is more meant as "We assure you that we won't remove this within the next year, at least."
I'm all for condensing the actionable part of documentation. I'm a little bit hesitant to make the call on the documentation changes, but I do think that you managed to nicely condense the information needed. CC @Akuli as well as it was mainly their explanations. If we close #11094 with this (which does satisfy the "documentation" part), we should also remember to actually review current |
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 like the concise explanation.
I have mixed feelings about the alias. On the one hand, it's "non-standard" and unnecessary from a technical point of view, but on the other hand, it's easier to guess the meaning of Foo | MaybeNone
than Foo | Any
. Overall I think it's worth trying.
Co-authored-by: Akuli <[email protected]>
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Also condense the explanation in CONTRIBUTING to what's actionable for the user.
And mark
Incomplete
andUnused
as stable.Closes: #11094