python / python/mypy

Type checking a system-install package yields erronous results

Aperta
#10,532 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Bug Report

I'm working on todoman a cli app which I have installed on my system since, well, it's a cli app that I use interactively daily.

I'm working on adding type hints to this project, so I have it installed the development code a virtualenv (pip install -e .) and also installed mypy and other developer tools in that virtualenv.

When I run mypy, it seems to read type definitions from my system-installed version of todoman, so type checking does not match what's inside the repository checkout.

In other words, when there's a from todoman import X, mypy seems to read the system library, and not the $(pwd)/virtualenv one. That one lacks type definitions, so the results are skewed.

To Reproduce

  1. Install todoman using your system package manager (in my case pacman -S todoman ).
  2. git clone --branch typing2 https://github.com/pimutils/todoman.git
  3. cd todoman && mkvirtualenv todoman && pip install -e . && pip install mypy
  4. Make sure nothing in caching your $PATH here and run which mypy.
  5. mypy todoman.

Expected Behavior

mypy should fail here, since there's a type-checking error in the checked out brach.

Actual Behavior

mypy passes, since it seems to read the system install libraries which have no type hints.

Your Environment

➜ mypy --version
mypy 0.812

➜ cat .config/mypy/config
[mypy]
ignore_missing_imports = True
cache_dir = $HOME/.cache/mypy

➜ python --version
Python 3.9.5

➜ uname -srmo
Linux 5.12.6-arch1-1 x86_64 GNU/Linux

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 report con i passaggi indicati per pacman, editable-install, virtualenv e mypy todoman, controllando prima which mypy e le versioni riportate. Traccia il motivo per cui viene selezionato il pacchetto installato nel sistema invece del checkout e considera l’issue completata quando il pacchetto presente nel checkout è stato sottoposto al controllo dei tipi e l’errore riportato è stato rilevato.

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
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.