python / python/mypy

Provide the full parsed config file to each plugin

Offen
#20,113 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Feature

Provide the full parsed config file to each plugin

Pitch

Currently, Mypy plugins are passed only the Options object in their constructor, which captures Mypy options but not Mypy plugin options. Consequently, each plugins has to re-parse the file. This is a waste of time, may add to the necessary dependencies for a plugin with configuration, and requires re-implementing the logic for parsing different file types (TOML vs config). Here's an example of the pydantic plugin doing just this:

https://github.com/pydantic/pydantic/blob/06448aa41764d0c1e1c2f9455b108c4b21012929/pydantic/v1/mypy.py#L239-L256

The neatest solution would be to pass the full config object to the constructor. Unfortunately, this would be a breaking change to the constructor signature, so probably the more palatable option would be to store the config options within each Plugin instance (in the constructor), which the subclasses can use if they want:

class SomeMypyPlugin(Plugin):
    def __init__(self, options: Options) -> None:
        super().__init__(options)
        my_config_option = self.raw_config["tools"]["some_mypy_plugin"]
        # use my_config_option

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 beim Plugin-Konstruktor und dem Konfigurationsladepfad und vergleiche dann das im Issue verlinkte pydantic-Plugin-Beispiel. Verfolge, wie Options und die Plugin-Konfiguration derzeit geparst werden, und definiere die Fertigstellung so, dass die vollständig geparste Konfiguration für Plugin-Instanzen verfügbar ist, ohne dass jedes Plugin TOML- oder Konfigurationsdateien erneut parsen muss.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
tooling
Issue-Typ
Feature
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.