python / python/mypy

exclude should imply a per-module follow import skip for matching modules

Open
#10,377 4 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

Bug Report

I recently converted this project (linked to at the most recent commit) from a plain script to a Python package. This included adding an un-annotated _version.py file generated by versioneer to the package. mypy (when run as mypy src) now reports errors due to _version.py lacking any type annotations, and I cannot get it to ignore that file.

What I've tried:

  • Adding exclude = _version.py to the [mypy] section in setup.cfg
  • Adding exclude = src/tinuous/_version.py to the [mypy] section
  • Adding exclude = src/tinuous/_(version|_init__).py to the [mypy] section
  • Running just mypy src/tinuous/__main__.py
  • Running mypy --exclude _version.py src

In all of these cases, mypy spits out errors relating to _version.py even though I thought I told it to ignore that file.

Your Environment

  • Mypy version used: 0.812
  • Mypy command-line flags: --exclude or nothing
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
ignore_missing_imports = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
no_implicit_optional = True
warn_redundant_casts = True
warn_return_any = True
warn_unreachable = True
local_partial_types = True
no_implicit_reexport = True
strict_equality = True
show_error_codes = True
show_traceback = True
pretty = True
plugins = pydantic.mypy
# Various "exclude" options (see above)
  • Python version used: 3.9.4
  • Operating system and version: macOS 11.2.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 report with mypy 0.812 using mypy src and the exclude settings shown in setup.cfg or mypy.ini, focusing on src/tinuous/_version.py. Trace how --exclude and imported modules are handled, then verify that matching modules are skipped without errors while other modules in src are still checked.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.