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.

Bewertung

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

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.

Beschreibung

feature topic-plugins

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
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
Ø Merge
1 T. 18 Std.
Gemergte PRs (30 T.)
54

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python/mypy

Alle Issues in python/mypy

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

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