python / python/mypy

Type checking a system-install package yields erronous results

Offen
#10,532 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere den Bericht mit den aufgeführten pacman-, editable-install-, virtualenv- und mypy todoman-Schritten und überprüfe zuerst which mypy sowie die angegebenen Versionen. Verfolge, warum das systemweit installierte Paket anstelle des Checkouts ausgewählt wird, und betrachte das Issue als erledigt, wenn das ausgecheckte Paket einer Typprüfung unterzogen wurde und der gemeldete Fehler erkannt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.