Closed
Description
As mentioned in #2411, it can become difficult to select what you want to see or not in mypy's ouput. This can lead to all-or-nothing behaviors, clutter display/logs, and make CI servers fail on errors we don't wish to check or ignore errors we do want to check.
A possible solution to this is to adopt the behaviour from popular linters such as flake8, pylint, etc.
Each type of error/warning have a code, and you can pass the ones you wish to ignore as a coma separated list using either the command line, a code comment or a config file. Each code is also displayed at the beginning of each respective warning/error in the tool output, so that you can grep for it easily.
E.G:
$ flake8 tests
tests/test_s.py:8:1: F821 undefined name 'test'
tests/test_s.py:10:1: E402 module level import not at top of file
tests/test_s.py:10:10: E261 at least two spaces before inline comment
tests/test_s.py:12:1: E402 module level import not at top of file
tests/test_s.py:14:1: E402 module level import not at top of file
$ flake8 tests --ignore=E402,E402
tests/test_s.py:8:1: F821 undefined name 'test'
tests/test_s.py:10:10: E261 at least two spaces before inline comment
This is a general way of solving the filtering problem:
- it works with one flag instead of many;
- it's flexible enough to cover potential future new use cases;
- with the config file, you can commit it in your VCS and share the checks you wish to apply with your team;
- it plays well with all configuration mechanisms: env var, config file, cmd options, code comments, etc.
- it plays well with the command line, allowing grep on specific code, or code type (in the example, F is a failure, E an error, W a warning, etc).