-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-configurationConfiguration files and flagsConfiguration files and flagstopic-incremental
Description
Bug Report
When running mypy with --warn-unused-ignore --no-namespace-packages --warn-unused-ignores --ignore-missing-imports, putting a type: ignore[attr-defined] on an import will have mypy report an Unused "type: ignore" comment [unused-ignore] every other run, unless the cache is being cleared between runs.
To Reproduce
from opentelemetry.instrumentation.asgi import ( # type: ignore[attr-defined]
OpenTelemetryMiddleware,
)(Since this only seems to work with external packages, some setup is required)
- Run
pip install opentelemetry-instrumentation-asgi opentelemetry-distro - Add the code snippet below to
file.py - Run
mypy --warn-unused-ignore --no-namespace-packages --warn-unused-ignores --ignore-missing-imports file.py: Observer no error - Run
mypy --warn-unused-ignore --no-namespace-packages --warn-unused-ignores --ignore-missing-imports file.py: Observe an[unused-ignore]error - Run
mypy --warn-unused-ignore --no-namespace-packages --warn-unused-ignores --ignore-missing-imports file.py: Observer no error - Repeat the cycle as many times as you like :)
When removing the cache between runs, all works well, so I suspect it has something to do with caching.
Your Environment
- Mypy version used:
1.18.2,main - Mypy command-line flags:
--warn-unused-ignore --no-namespace-packages --warn-unused-ignores --ignore-missing-imports - Mypy configuration options from
mypy.ini(and other config files): - - Python version used: 3.13.7
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-configurationConfiguration files and flagsConfiguration files and flagstopic-incremental