-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Let's drop --strict-boolean #3195
Comments
Or at least start deprecating it and remove it from |
Before we proceed with this, I just wanted to clear up one thing based on the earlier discussion on gitter. Would this flag become useful if it was restricted just to the cases where it's actually unsafe? Specifically the usage of non-boolean variable in a boolean context is unsafe only if it has more than 1 values that is interpreted as
It seems very easy to identify unsafe cases, using the truth value testing rules. The usage is unsafe if the variable type is a
(Edit: The last bullet point can wait until we have structural types) Do you want me to check if restricting |
Agreed -- it's not worth having @pkch We can discuss that as a separate feature (which might perhaps share a name with the current option). Feel free to open an issue for it. |
When However, there are some related checks that mypy could do that are actually useful, like warning if you do |
Regarding the idea that conflating an empty something (or zero) with None is a bad idea, it is actually quite common to have code that does this intentionally, and uglifying it just doesn't seem right. So let someone please volunteer for a PR that deprecates it and removes it from the |
I use Alternatively, is there an easy way to create a mypy wrapper that adds back the functionality? |
@viktor25 The feature as it was implemented was problematic, since it actually doesn't do the right thing in all cases (as discussed in #3185 and elsewhere). We could perhaps add a fixed version of the feature at some point (but not enable it through |
Honestly I strongly believe it's an anti-pattern to do this in Python and I don't want to support a feature (even if contributed). Sorry. |
(Putting this in a separate commit since it's more controversial -- since it did work, some people might still be using it, even though it's been deprecated since May 2017. See discussion in python#3195.)
These will now all fail with `unrecognized arguments: <flag>` ``` --disallow-any (message points to options replacing it) -f/--dirty-stubs (ignored) --use-python-path (exited with error message) -s/--silent-imports (set ignore_missing_imports=True and follow_imports=skip) --almost-silent (ses follow_imports=error) --[no-]fast-parser (ignored) --strict-boolean (actually did something, see below) ``` Note that `--strict-boolean` might still be somewhat controversial -- some people might still be using it, even though it's been deprecated since May 2017 (and it isn't actually correct). See discussion in #3195.
See discussion in #3185 -- it's not working perfectly and it is encouraging bad style. It also makes
--strict
less useful: it means you can't use--strict
if you don't believe in--strict-optional
, else you'd get a ton of false positive from the latter.The text was updated successfully, but these errors were encountered: