python / python/mypy

Detect if shell is in activated virtual environment, but mypy is not installed in it.

Offen
#17,214 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature topic-usability
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
Ø Merge
1 T. 18 Std.
Gemergte PRs (30 T.)
54

Beschreibung

Feature

Detect if $VIRTUAL_ENV is defined when running mypy, potentially only if we report missing imports.

Pitch

Right now, if mypy is installed globally, and a user activates a virtual environment, they could be confused about missing import errors (e.g. https://github.com/python/mypy/issues/7237) where the packages are installed in the virtual environment but mypy can't see them. In such a scenario, we'd be able to detect that $VIRTUAL_ENV is set, and we could report a warning if that path doesn't match the prefix of sys.executable.

One question about this is should we report this in general or only if we report a missing import.

I think there probably are use cases where people don't care about running mypy globally, so my initial inclination would be to only report this and suggest --python-executable if an import is missing.

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

Beginne damit, nachzuverfolgen, wie mypy fehlende Importe meldet und wie es den laufenden Interpreter anhand von sys.executable bestimmt. Vergleiche dieses Präfix mit dem Wert von VIRTUAL_ENV und entscheide, ob die Warnung auf Fälle fehlender Importe beschränkt werden sollte, und empfehle --python-executable; abgeschlossen ist die Aufgabe, wenn Verhalten und Geltungsbereich durch Tests abgedeckt sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
devtools
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

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