python / python/typeshed

Preventing code quality regressions

Offen
#11,769 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

project: infrastructure
Vorherrschende Sprache
Python
Sterne
5.1k
Forks
2.1k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
82

Beschreibung

For some time now we've used pyright's stricter configuration to prevent code quality regressions. Unless a stubs package is mentioned in the config file, it's expected to have annotations for all its fields. While this has served us well for a while, it has become unsuitable since the introduction of _typeshed.Incomplete:

  • pyright doesn't understand that a (partial) Incomplete annotation is equivalent (for our purposes) to an unannotated item.
  • It's tedious to maintain the pyright stricter configuration in addition to the metadata in the stubs directory.
  • It's easy to cheat the regression check by using Incomplete.

To improve the situation, I propose to move to a custom solution:

  1. Add an incomplete marker to METADATA.toml (defaulting to false).
  2. Add a custom script to CI that checks that a stub package marked as complete can't have any incomplete (unannotated or using Incomplete) fields. Alternatively, we could add a disabled-by-default check to flake8-pyi and use that instead.
  3. At a later date, we could also add a PR CI script that add a PR comment warning a user if the amount of incomplete increases due to a PR.

(See also https://alexwaygood.github.io/typeshed-stats/.)

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 der Durchsicht der Stub-Paketmetadaten in METADATA.toml und der aktuellen CI-Prüfungen, die die strengere Konfiguration von pyright verwenden. Vergleiche die Implementierung eines benutzerdefinierten CI-Skripts mit der vorgeschlagenen standardmäßig deaktivierten Prüfung flake8-pyi. Als abgeschlossen gilt die Aufgabe, wenn vollständige Pakete keine unannotierten Felder oder Felder mit _typeshed.Incomplete enthalten können und die Markierung für Unvollständigkeit standardmäßig auf false gesetzt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
ci-cd, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
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.