Disappearing dmypy errors using `--export-types`, `pip install -e`, and absolute paths
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Errors disappear on the second run of dmypy under specific circumstances:
- Dmypy is run using the
--export-typesflag. - We use absolute paths to the files checked.
- The files checked are in a project which has been installed with
pip install -e. - The files checked are in a
srcdirectory. (This is so odd that I feel as though I might have made a mistake here.)
This looks similar to https://github.com/python/mypy/issues/9655, but unlike that, this isn't fixed by https://github.com/python/mypy/pull/15043 (see https://github.com/python/mypy/pull/15043#issuecomment-1884022976).
To Reproduce
The best minimal example I have so far:
pyproject.toml:
[build-system]
requires = ["setuptools >= 64"]
build-backend = "setuptools.build_meta"
[project]
name = "dmypy_example"
version = "0.0.1"
dependencies = []
src/foo.py:
a: str = 1
Commands:
# Create a new Python 3.12 virtualenv, then:
pip install --editable .
dmypy run --export-types $(pwd)/src/foo.py
dmypy run --export-types $(pwd)/src/foo.py
Expected Behavior
We should see the same error output after both runs of dmypy.
Actual Behavior
Regardless of the error in the file, it disappears on the second run of dmypy.
$ pip install --editable .
...
$ dmypy run --export-types $(pwd)/src/foo.py
Daemon started
src/foo.py:1: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment]
Found 1 error in 1 file (checked 1 source file)
$ dmypy run --export-types $(pwd)/src/foo.py
Success: no issues found in 1 source file
Your Environment
- Mypy configuration options from
mypy.ini(and other config files): None. - Python version used: 3.12.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal example in pyproject.toml and src/foo.py, install it with pip install --editable ., and run the two dmypy commands exactly as shown. Compare the daemon's first and second results while tracing the --export-types, absolute-path, editable-install, and src-directory combination. Done means the type error remains visible on both runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100