python / python/mypy

Support glob patterns when configuring `mypy_path`

Offen
#9,965 4 Kommentare 8 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature topic-configuration
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Feature

Support the glob patterns * and ** in the mypy_path configuration.

Should work the same way as it does for the files configuration.

Pitch
I have a monorepo, with a bunch of python libraries located in a directory called libs.
All packages are namespace packages with the same namespace, but they are kept in their own directory inside of the libs directory:

repository_root
│
└───libs
│   └───pkg-a
│   |    └───namespace
│   |
│   └───pkg-b
│   |    └───namespace
│   |
│   └───pkg-c
│        └───namespace
│
└───mypy.ini

The mypy_path declaration in my mypy.ini looks something like this (but with dozens of packages):

mypy_path = $MYPY_CONFIG_FILE_DIR/libs/pkg-a:
    $MYPY_CONFIG_FILE_DIR/libs/pkg-b:
    $MYPY_CONFIG_FILE_DIR/libs/pkg-c:

It would be very convenient to use a glob pattern like this instead:

mypy_path = $MYPY_CONFIG_FILE_DIR/libs/*

It's more concise, and would avoid potential problems with forgetting to include a newly added package in mypy_path.

Thanks for a great tool!

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 Glob-Muster für die files-Konfiguration unterstützt werden, und identifiziere die entsprechenden Einstiegspunkte für das Parsen und Auflösen von mypy_path. Erweitere das Verhalten so, dass * und ** auch dort funktionieren, und überprüfe anschließend, dass das Beispiel für ein Namespace-Package-Monorepo alle passenden Bibliotheksverzeichnisse auflöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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