Skip to content

Ignore specific error codes from configuration file #9533

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

Closed
amikrop opened this issue Oct 4, 2020 · 11 comments
Closed

Ignore specific error codes from configuration file #9533

amikrop opened this issue Oct 4, 2020 · 11 comments
Labels
bug mypy got something wrong documentation

Comments

@amikrop
Copy link
Contributor

amikrop commented Oct 4, 2020

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.

@amikrop amikrop added the feature label Oct 4, 2020
@gvanrossum
Copy link
Member

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
Copy link
Collaborator

(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
Copy link
Contributor Author

amikrop commented Oct 5, 2020

Alright, thanks for your answers.

@gvanrossum
Copy link
Member

Keeping this open because it needs docs.

@gvanrossum gvanrossum added the bug mypy got something wrong label Oct 5, 2020
@gvanrossum
Copy link
Member

Whoops, trying this with master, it looks like there's a bug in the code that reads this flag from mypy.ini.

usage: mypy [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: Invalid error code(s): i, m, o, p, r, t

The line in mypy.ini was

disable_error_code = import

@amikrop
Copy link
Contributor Author

amikrop commented 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, 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.

@gvanrossum
Copy link
Member

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
Copy link
Contributor Author

amikrop commented Oct 5, 2020

Working on it.
Edit: done
#9537

@Nikhil1O1
Copy link

@gvanrossum can I work on the documenting this thing??

@gvanrossum
Copy link
Member

@Nikhil1O1

@gvanrossum can I work on the documenting this thing??

Please do!

@hauntsaninja
Copy link
Collaborator

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!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong documentation
Projects
None yet
Development

No branches or pull requests

4 participants