python / python/mypy

dmypy's `--use-fine-grained-cache` crashes with `KeyError` on namespace packages

Aperta
#20,519 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

This is possibly related to #10735.

To Reproduce & Traceback

Create a minimal project as follows:

project/
  mypy.ini
      [mypy]
      files = src/
  src/
    pkg/
      __init__.py
      nspkg/
        mod.py
            a: int = ""

Reproduce with these steps:

  1. Navigate to project/
  2. $ mypy --cache-fine-grained
    src/pkg/nspkg/mod.py:1: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
    
  3. $ dmypy run -- --use-fine-grained-cache
    Daemon started
    Success: no issues found in 2 source files
    
    (I don't think this should say Success given the errors from Step 2., but that's a separate issue.)
  4. Change mod.py, e.g. modify the sole line to a: int = "a"
  5. Run the daemon twice:
    • $ dmypy run -- --use-fine-grained-cache
      src/pkg/nspkg/mod.py:1: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
      
    • $ dmypy run -- --use-fine-grained-cache
      Daemon crashed!
      Traceback (most recent call last):
        File ".../mypy/dmypy_server.py", line 237, in serve
          ...
        File ".../mypy/dmypy_server.py", line 768, in find_reachable_changed_modules
       worklist.append(BuildSource(graph[dep].path, graph[dep].id, followed=True))
                                   ~~~~~^^^^^
      KeyError: 'pkg.nspkg'
      

Your Environment

  • Mypy version used: 1.19.1
  • Python version used: Python 3.13

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

Riproduci il caso del namespace package con dmypy e --use-fine-grained-cache, quindi esamina dmypy_server.py nelle vicinanze di find_reachable_changed_modules e della riga 768, dove il traceback cerca pkg.nspkg in graph. Usa i comandi elencati per verificare che il daemon non vada più in crash alla seconda esecuzione e continui a segnalare l’errore di assegnazione.

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
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.