You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ignore specific error codes from configuration file #9533
Please make it possible to ignore errors with arbitrary error codes, though the configuration file.
Essentially, make the # type: ignore[code, ...] behavior possible through the configuration file, as it would be
nice to have the ability to keep the code visually simpler, by moving these directives from comments, to the
config file.
Installed a git checked out version of mypy to try this. The command-line way worked (for one or more error codes), but the config file way did not: mypy: error: Invalid error code(s): i, m, o, p, r, t
Other list-receiving options, as always_true did not have this problem.
Printing options.disable_error_code in main.py:process_options gave this: ['i', 'm', 'p', 'o', 'r', 't']
which is strange, because the --disable-error-code argument is added to the parser exactly the same way others (like --always-true) do.
I think the mypy.ini file is not malformed:
[mypy]
always_true = foo, bar
disable_error_code = import
Python 3.8.5
Just saw you found out already by yourself :)
Trying to debug this myself, but in case somebody else does before me, I would be interested to know the cause of this.
I think we actually have documentation for this; both CLI and config are now documented. (But documentation can almost always be improved, so if you see improvements to be made, feel free to suggest them!)
Activity
gvanrossum commentedon Oct 5, 2020
You can do it from the command line, e.g.
--disable-error-code attr-defined.IIUC you can do it from the config file too (
disable-error-code = attr-defined) -- it just needs documenting.hauntsaninja commentedon Oct 5, 2020
(Note this feature hasn't made it to a mypy release yet, so you'll need to install mypy from git master to do this)
amikrop commentedon Oct 5, 2020
Alright, thanks for your answers.
gvanrossum commentedon Oct 5, 2020
Keeping this open because it needs docs.
gvanrossum commentedon Oct 5, 2020
Whoops, trying this with master, it looks like there's a bug in the code that reads this flag from mypy.ini.
The line in mypy.ini was
amikrop commentedon Oct 5, 2020
Installed a git checked out version of mypy to try this. The command-line way worked (for one or more error codes), but the config file way did not:
mypy: error: Invalid error code(s): i, m, o, p, r, tOther list-receiving options, as
always_truedid not have this problem.Printing
options.disable_error_codein main.py:process_options gave this:['i', 'm', 'p', 'o', 'r', 't']which is strange, because the --disable-error-code argument is added to the parser exactly the same way others (like --always-true) do.
I think the mypy.ini file is not malformed:
[mypy]
always_true = foo, bar
disable_error_code = import
Python 3.8.5
Just saw you found out already by yourself :)
Trying to debug this myself, but in case somebody else does before me, I would be interested to know the cause of this.
gvanrossum commentedon Oct 5, 2020
Probably something's needed to flag that config option as a list. I'd be grateful if you debugged this and came up with a fix!
amikrop commentedon Oct 5, 2020
Working on it.
Edit: done
#9537
Nikhil1O1 commentedon Oct 6, 2020
@gvanrossum can I work on the documenting this thing??
gvanrossum commentedon Oct 6, 2020
@Nikhil1O1
Please do!
hauntsaninja commentedon Oct 6, 2020
I think we actually have documentation for this; both CLI and config are now documented. (But documentation can almost always be improved, so if you see improvements to be made, feel free to suggest them!)