-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
--strict
is too strict to be useful
#7767
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
I've been thinking about something related recently – I think it'd be useful to have a way to disable some specific checks while enabling strict mode. So hypothetically As it is now I often have mypy configurations that are quite repetitive and when a new check is introduced there's no way to have it enabled automatically after upgrading mypy (although I understand some people wouldn't like it). |
@jstasiak -- I think overriding specific parts of Somewhat tangentially: maybe we should rename |
Lovely, I completely missed that! (+1 on renaming here) |
I like the idea of making |
Having seen how this turned out with C and C++, be careful going down this path. In C++, this is a common incantation to compile with the equivalent of "strict mode": g++ -std=c++17 -Wall -Wextra -Wpedantic my_source_file.cpp
That's a lot of arcane options to get the compiler to help you code better. The end result is that unwary programmers write worse code because they don't know the magic words to get the compiler to help them. |
For anyone who happens upon this from google / searching, here's a recent example of mypy-ifying a project of mine so users can have an idea: Warning: libvcs: Basic diff, libtmux: Basic diff, |
@SyntaxColoring That said, I would actually use an option that enables absolutely everything, and is guaranteed to do so in future. The reason is that when I'm writing a mypy config, I could enable that and then disable anything I need to. That is, every rule that's too strict for me, and I don't want to have to When I bump mypy to a new version, I might have to exclude some new rules. But that's fine for me, because I only do that when I'm ready to tinker with the code and/or config. I won't come complaining that the latest mypy broke my build etc ;-) |
With #13464, mypy project started to use
is no longer true. Is that means I am currently considering enabling this option, but by finding this issue I am concerned that it is overly strict. |
Plenty of people use strict on their projects. By and large I'd define strict as "mostly the set of checks needed to ensure that you do not have any type unsoundness without an explicit circumvention of the type system, like type ignore, explicit use of Any or cast" Note that you can turn on strict, then turn off individual checks that don't yet work well for you. I recently wrote up some advice to get to |
We provide a
--strict
flag that is strict enough that we can not use it in mypy itself, which is one of the most carefully typed projects I know of.We should possibly consider removing some flags from strict.
The text was updated successfully, but these errors were encountered: