python / python/mypy

Make type checking mypy more straightforward for new contributors

Offen
#11,403 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

topic-developer topic-tests
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

There are a couple pitfalls relating to type checking mypy itself that don't seem to be documented anywhere:

  1. Specifying files: Running mypy . and mypy mypy mypyc both result in duplicate module errors that prevent further type checking. The correct way to run mypy is mypy -p mypy -p mypyc, which doesn't appear to be documented anywhere (I only found this by looking at the tox.ini config file).
  2. Specifying the config file: Failing to specify mypy_self_check.ini as the config file results in an error in mypy/bogus_type.py and means that people aren't using mypy's stricter type checking options.

I think the solution to 2 would be to rename mypy_self_check.ini to mypy.ini, because self checking mypy is significantly more common than compiling mypy with mypyc, so making mypy_self_check.ini the default config file seems reasonable.

For 1, we should at the very least document the command to run mypy in CONTRIBUTING.md. I think the ideal solution would involve changing the configuration file so that either mypy . or mypy mypy mypyc just works correctly, the latter of which seems to be possible from my experiments by turning on namespace_packages and excluding mypyc/test-data.

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 mit CONTRIBUTING.md und tox.ini, um die dokumentierten und konfigurierten mypy-Befehle zu vergleichen. Untersuche mypy_self_check.ini und mypy/bogus_type.py und prüfe anschließend, ob die vorgeschlagenen Änderungen an der Konfigurationsbenennung oder an namespace packages Fehler durch doppelte Module vermeiden und gleichzeitig die strikte Selbstprüfung beibehalten. Als erledigt gilt die Aufgabe, wenn der Beitragsworkflow einen zuverlässigen Befehl und eine zuverlässige Konfiguration dokumentiert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
build-system, developer-experience, documentation
Issue-Typ
Dokumentation
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
52/100

Neue Issues direkt in Ihr Postfach

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