mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Allow to enable/disable plugin error codes

Open tik-stbuehler opened this issue 3 years ago • 9 comments

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_configs is 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",
]

tik-stbuehler avatar Aug 15 '22 09:08 tik-stbuehler

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 15 '22 18:08 github-actions[bot]

Following up to see where this PR leads. Having issues with supressing django-manager-missing

mannyanebi avatar Aug 31 '22 07:08 mannyanebi

Just wanted to say thank you for this patchset, am also experiencing this issue in trying to suppress django-manager-missing.

scottp-dpaw avatar Oct 17 '22 08:10 scottp-dpaw

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

scottp-dpaw avatar Oct 17 '22 09:10 scottp-dpaw

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?

karamanolev avatar Mar 25 '23 17:03 karamanolev

I can take a look when CI is green.

JelleZijlstra avatar Mar 25 '23 17:03 JelleZijlstra

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Mar 25 '23 17:03 github-actions[bot]

I rebased the changes on the latest master in https://github.com/scottp-dpaw/mypy/tree/v1.8.0_fixes

scottp-dpaw avatar Mar 06 '24 04:03 scottp-dpaw

Running into the django-manager-missing issue as well.

tbrlpld avatar Jun 13 '25 19:06 tbrlpld

Superseded by https://github.com/python/mypy/pull/19719

ilevkivskyi avatar Oct 04 '25 01:10 ilevkivskyi