If plugin has same name as top-level module which has been imported before mypy runs (e.g., you are using api), mypy picks up the wrong file
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
In some circumstances, a plugin which works fine from command line fails when run from the API with:
('Found 1 error in 1 file (errors prevented further checking)\n', '/data/users/ezyang/b/pytorch/mypy.ini:5:1: error: Plugin "/data/users/ezyang/b/pytorch/test/typing/../../mypy_plugins/sympy.py" does not define entry point function "plugin" [misc]\n', 2)
The problem appears to occur when the a filepath plugin is provided which has the same name as a top level module that has already been imported when mypy runs.
To Reproduce
- Create a plugin
mypy_plugins/sympy.py, any plugin code is fine, it doesn't matter (you will never hit/import the plugin code) - Direct mypy to use the plugin
plugins = mypy_plugins/sympy.py - Run mypy via the API on some test file (doesn't matter):
from mypy import api
import sympy
print(api.run(['--config-file', 'mypy.ini', 'test.py']))
Expected Behavior Plugin loads successfully, as it does when you call mypy directly
Actual Behavior Fails with "/data/users/ezyang/b/pytorch/test/typing/../../mypy_plugins/sympy.py" does not define entry point function "plugin"
Your Environment
- Mypy version used: 1.8.0
- Python version used: Python 3.10
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
Riproduci il problema importando sympy prima di chiamare mypy.api.run con mypy.ini e mypy_plugins/sympy.py, quindi confrontalo con un’invocazione diretta di mypy. Traccia come viene risolto il plugin filepath quando è già stato importato un modulo di primo livello con lo stesso nome; il lavoro è completo quando entrambi i percorsi di invocazione caricano correttamente il plugin e l’errore di entry-point segnalato è scomparso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100