python / python/mypy

local / in-folder setup.cfg without mypy section shadows any additional user config files

Offen
#9,113 0 Kommentare 0 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

As the config file read order defined by the order of the lists at https://github.com/python/mypy/blob/master/mypy/defaults.py#L15
is

CONFIG_FILES = CONFIG_FILE + SHARED_CONFIG_FILES + USER_CONFIG_FILES  # type: Final

a shared config file (which may exist for several other purposes) shadows any user config files even in the case when
the shared config file contains no mypy section.

Steps to reproduce:

  • Create an empty setup.cfg in the current directory, and also have one of the USER_CONFIG_FILE versions of a mypy config file.
  • Run mypy
  • Notice that only the setup.cfg file was read, even though it had no mypy section.
    `

Proposal

The logic which checks for a mypy section in the parser object (https://github.com/python/mypy/blob/master/mypy/config_parser.py#L127) should be used to check whether the parser.read call actually loaded anything meaningful from the config file. If no mypy section was loaded, then the loop over the config_files should continue instead of breaking.

This should at least be the case for any shared config files which may exist for entirely other reasons.

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

Beginnen Sie mit der Reihenfolge von CONFIG_FILES in mypy/defaults.py und der Prüfung des parser-Abschnitts in mypy/config_parser.py. Reproduzieren Sie das Problem mit einer leeren setup.cfg und einer Benutzerkonfigurationsdatei. Überprüfen Sie anschließend, dass das Laden der Konfiguration fortgesetzt wird, wenn die gemeinsame Datei keinen mypy-Abschnitt enthält, und dass die Benutzereinstellungen wirksam werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
developer-experience, tooling
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

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