python / python/mypy

Disappearing dmypy errors using `--export-types`, `pip install -e`, and absolute paths

Open
#16,768 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-daemon
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-types flag.
  • 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 src directory. (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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.