-
-
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
Add support for per-module enabling/disabling of error codes #9440
Comments
Seems reasonable. You have a typo, the option is actually called |
Second this request. For me, I'd really like to disable |
This sounds like a useful feature. Another potential use case would be migrating legacy code -- you might initially ignore some error codes in code that wasn't originally written with type checking in mind, but you'd want to enable all error codes in new files. |
Exactly this. I wrote a tool called mypy-runner for filtering errors using error codes (first using my own error codes, then the official ones once that feature arrived) as well regexes. I'd love to not have to use my tool at all! One of the big downsides of the runner-based approach is that there's a major performance penalty: dmypy rechecks files with errors (regardless of modified timestamps), and from mypy's perspective all those files still have errors, so reruns of dmypy on our very large codebase are slow. |
Just ran into a use case for this! I'm migrating our (large) codebase to mypy-protobuf 2.0 - and it requires some backward incompatible changes to enums in pyi stubs. Ideally, I'm able to do this in many smaller diffs. However, if a migrated module tries to import from a non-migrated module, it hits a Ideally I can disable that error specifically - and reenable it later when the non-migrated module gets migrated. Will be using ignore_errors for now - but it seems like an excessive hammer |
This would be useful to turn off override errors when using fixtures in tests, like: class A:
@pytest.fixture
def b():
pass
@pytest.fixture
def a(b):
pass
class B(A):
@pytest.fixture
def c():
pass
@pytest.fixture
def a(b, c):
pass |
Fixes #9440 This is a bit non-trivial because I decided to make per-module code act as overrides over main section error codes. This looks more natural no me, rather that putting an adjusted list in each section. I also fix the inline `# mypy: ...` comment error codes, that are currently just ignored. The logic is naturally like this: * Command line and/or config main section set global codes * Config sections _adjust_ them per glob/module * Inline comments adjust them again So one can e.g. enable code globally, disable it for all tests in config, and then re-enable locally by an inline comment.
Feature
#9172 implemented global error code disabling/enabling as discussed in #8975. It seems like it was always the intention to consider per-module configuration (#8975 (comment)), but we don't currently have an open issue for it.
Pitch
My personal use case is for tests. Typing tests is often just a chore, but it's nice to have whatever type safety you can get for free. I'd want to be able to do:
(For this use case, I think there's actually a fair argument to be made that we should suppress var-annotated aka "needs type annotation" errors when checking untyped defs. If this strikes you as reasonable, I can open another issue. Edit: see #8558 for this)
The text was updated successfully, but these errors were encountered: