python / python/mypy

(🐞) error code that is enabled in the config file can't be disabled on the CLI (with `--disable-error-code`)

Open
#16,628 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-configuration
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

I think it would be intuitive for commandline arguments to override config file options, but the way that enable/disable-error-code works isn't.

pyproject.toml

[tool.mypy]
enable_error_code = "operator"
> mypy --disable-error-code operator -c "1 + ''"
test.py:1: error: Unsupported operand types for + ("int" and "str")  [operator]
Found 1 error in 1 file (checked 1 source file)

The docs specify how these flags interact with themselves, but don't mention the ones in the config file.

--enable-error-code
This flag allows enabling one or multiple error codes globally. See [Error codes](https://mypy.readthedocs.io/en/stable/error_codes.html#error-codes) for more information.

Note: This flag will override disabled error codes from the [--disable-error-code](https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-disable-error-code) flag.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how mypy combines enable_error_code and disable_error_code from pyproject.toml with the command-line options. Reproduce the example using --disable-error-code operator, then add coverage for the configuration and CLI combination. Done means the CLI option suppresses the configured error code and the documentation explains this precedence.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.