Skip to content

Allow to enable/disable plugin error codes#13419

Closed
tik-stbuehler wants to merge 2 commits into
python:masterfrom
tik-stbuehler:allow-disable-plugin-error-codes
Closed

Allow to enable/disable plugin error codes#13419
tik-stbuehler wants to merge 2 commits into
python:masterfrom
tik-stbuehler:allow-disable-plugin-error-codes

Conversation

@tik-stbuehler
Copy link
Copy Markdown

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

Fixes python#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
@github-actions

This comment has been minimized.

@mannyanebi
Copy link
Copy Markdown

mannyanebi commented Aug 31, 2022

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

@scottp-dpaw
Copy link
Copy Markdown

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

@scottp-dpaw
Copy link
Copy Markdown

Also there's an additional error code validator in the config parser, I would suggest removing it so that pyproject.toml works - scottp-dpaw@4fe7aeb

@karamanolev
Copy link
Copy Markdown

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?

@JelleZijlstra
Copy link
Copy Markdown
Member

I can take a look when CI is green.

@github-actions
Copy link
Copy Markdown
Contributor

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

@scottp-dpaw
Copy link
Copy Markdown

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

@tbrlpld
Copy link
Copy Markdown

tbrlpld commented Jun 13, 2025

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

@ilevkivskyi
Copy link
Copy Markdown
Member

Superseded by #19719

@ilevkivskyi ilevkivskyi closed this Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ErrorCodes defined in mypy plugins seemingly cannot be ignored by --disable-error-code

7 participants