Skip to content

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

Open
@meshy

Description

@meshy

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 #9655, but unlike that, this isn't fixed by #15043 (see #15043 (comment)).

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions