-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Always use bool
and Literal
for Python compat code
#9213
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
Always use bool
and Literal
for Python compat code
#9213
Conversation
Some of these go against the policy we established in #7258 |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
@AlexWaygood I don't think it is:
|
We agreed in #7258 that we'd pause converting global constants to
I don't have a problem with these constants being included in the stubs, since it's plausible that some users might be using them and/or find them useful, and I don't think they do much harm. But I think they're mostly intended as internal implementation details rather than things that are meant to be publicly exported. |
It depends, at least 3rd-party plugins for sqlalchemy and requests might be using them to have similar features support for different languages. |
That's an interesting point. Are 3rd-party plugins for It's worth noting that neither |
Yes, there are multiple
And: |
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 don't think the reasoning from #7258 applies here. From rereading that issue, the main problem was "enum-like" literals. When assigning such a literal to a field or variable and later re-assigning the variable, type checkers will complain. I can't really imagine situations where you would want to assign these "flag-like" literals and later change the flag.
Alrighty, let's do it then |
When values used for python compat are defined, they are always
bool
.But, we can also highlight that some versions are not supported at all: by marking them as
Literal[False]
.