-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
How to specify constants of type NoneType? #2
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
Comments
The variables could be of their concrete type or of an optional concrete type depending on whether it is desirable to have the check for For example, a PEP 484 compatible definition of digest_size = ... # type: int or like this: digest_size = ... # type: Optional[int] |
Maybe one of the following should be declared best practice?
All of these work today with mypy. |
What about
It doesn't work in mypy yet, but mypy's error message sounds like it could, in the future. |
I was trying to avoid proposing that requires mypy changes, since it
looks like mypy treats the type `None` quite special. But sure, we'll
add that to the list of possibilities. @JukkaL, thoughts?
|
This is almost(ish :-) over. With
We'll just have to finish for the strict None checking flag in mypy to become the default. |
I'm submitting a PR to fix the specific objects @matthiaskramm mentioned. |
Type transforms module
Co-authored-by: Sebastian Rittau <[email protected]>
PEP 484 says "By default, None is an invalid value for any type". However, in the Python standard library there are class-level and module-level constants that are legitimately None.
Examples:
Should we allow these to be declared using e.g. something like
?
The text was updated successfully, but these errors were encountered: