python / python/mypy

Overrides in pyproject.toml not excluding specified modules

Open
#16,316 1 comment 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

When running mypy with a pyproject.toml configuration that uses the [[tool.mypy.overrides]] section to exclude specific modules, the specified modules are still being type-checked, contrary to expectations.

Steps to Reproduce:

Set up a pyproject.toml with mypy configurations using the [[tool.mypy.overrides]] section to exclude a specific module:

[tool.mypy]
python_version = "3.8"

[[tool.mypy.overrides]]
module = ["test_module.sample"]
ignore_errors = true

Have a sample module with evident type errors:

# test_module/sample.py
def faulty_function() -> int:
    return "This should be an integer!"

Run mypy with the provided configuration:

mypy test_module/ --config-file pyproject.toml

Expected Behavior:
The module test_module.sample should be excluded from type-checking and no errors should be reported.

Actual Behavior:
mypy reports type errors from the module test_module.sample, indicating that it is not being excluded as specified in the configuration.

Mypy Version: 1.6.1

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

Reproduce the issue using the shown pyproject.toml configuration and test_module/sample.py, then trace how mypy processes the [[tool.mypy.overrides]] section. Done means test_module.sample is not reported when ignore_errors is true; verify the behavior with the provided mypy command.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.