Mypy daemon + `--namespace-packages` mishandles deletion of `__init__.py`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug Report
Run mypy with --namespace-packages flag.
If daemon is initially run with
p/__init__.py
p/a.py
Then delete p/__init__.py
We expect p to become a namespace package and p.a to be resolvable still. This does not happen.
The issue exists within the daemon update logic (update.py).
If we initialize the daemon with only
p/a.py
things work ok.
Issue was discovered via #11259 and #9636 for context
To Reproduce
In test-data/unit/fine-grained-modules.test, add to the first line of the following tests testDeletePackage4, testDeletePackage5, and testDeletePackage6
# flags: --namespace-packages
Can run the test with
source .tox/py37/bin/activate
pytest mypy/test/testfinegrained.py -k testDeletePackage4 -n0
Expected Behavior
for testDeletePackage4
main:3: error: Argument 1 to "f" has incompatible type "int"; expected "str...
==
main:3: error: Argument 1 to "f" has incompatible type "int"; expected "str...
== (diff)
main:2: error: Cannot find implementation or library stub for module named "p.a" (diff)
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports (diff)
main:2: error: Cannot find implementation or library stub for module named "p" (diff)
Actual Behavior
for testDeletePackage4
main:3: error: Argument 1 to "f" has incompatible type "int"; expected "str...
==
main:2: error: Import of "p.a" ignored (diff)
main:2: note: (Using --follow-imports=error, module not passed on command line) (diff)
== (diff)
main:2: error: Cannot find implementation or library stub for module named "p.a" (diff)
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports (diff)
main:2: error: Cannot find implementation or library stub for module named "p" (diff)
Ideally when fixing this task - we should convert the three aformentioned tests to use --namespace-packages
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la logica di aggiornamento del daemon in update.py e i casi di test in test-data/unit/fine-grained-modules.test, in particolare testDeletePackage4, testDeletePackage5 e testDeletePackage6. Esegui pytest mypy/test/testfinegrained.py -k testDeletePackage4 -n0 con --namespace-packages abilitato, quindi verifica che i tre test mantengano la risoluzione di p.a dopo l'eliminazione di init.py e corrispondano alla diagnostica prevista.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 48/100