mypy
mypy copied to clipboard
Allow to enable/disable plugin error codes
Description
Fixes #12987
- Ignore unknown error codes in process_options
- Reload enabled / disabled error codes after loading plugins
- Unknown errors codes no longer a hard failure, they only get logged to stderr
(I copied this from the way
warn_unused_configsis handled, and I don't think parser errors can be triggered after plugins were loaded?)
Duplicating the code seems a bit ugly, but the way the Errors instance is created before loading the plugins I'm not quite sure what the implications would be if the error code loading is delayed completely.
(Another thing I noticed: the Errors constructor creates new sets when passed empty sets, but shares non-empty sets otherwise. That seems bad - probably should either share always or clone always.)
Test Plan
No idea how to test plugins.
I used this manually (and successfully) by having something like this in pyproject.toml in a project using django:
[tool.mypy]
plugins = [
"mypy_django_plugin.main",
]
disable_error_code = [
"django-manager-missing",
]
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
Following up to see where this PR leads. Having issues with supressing django-manager-missing
Just wanted to say thank you for this patchset, am also experiencing this issue in trying to suppress django-manager-missing.
Also there's an additional error code validator in the config parser, I would suggest removing it so that pyproject.toml works - https://github.com/scottp-dpaw/mypy/commit/4fe7aeb12189f4afcc3167ddf8d8f559452a6d08
Are there any news on this? I'm also on the bandwagon trying to suppress django-manager-missing from django-stubs and failing. @tik-stbuehler thanks for opening this, anything I can do to get it in?
I can take a look when CI is green.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
I rebased the changes on the latest master in https://github.com/scottp-dpaw/mypy/tree/v1.8.0_fixes
Running into the django-manager-missing issue as well.
Superseded by https://github.com/python/mypy/pull/19719