python / python/mypy

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

Aperta
#16,768 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-daemon
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l'esempio minimo in pyproject.toml e src/foo.py, installalo con pip install --editable . ed esegui i due comandi dmypy esattamente come mostrato. Confronta il primo e il secondo risultato del daemon mentre tracci la combinazione di --export-types, absolute-path, editable-install e src-directory. Il lavoro è completato quando l'errore di tipo rimane visibile in entrambe le esecuzioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.