Per-module options patterns starting with *
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Hi,
I am experimenting with per-module options and came across weird behavior when module patterns start with star. Documentation does not explicitly say if this is allowed or not, but I would assume it would work the same way as if it was "in the middle" of pattern. And IMHO there is no reason not to support it.
First issue:
From documentation:
Stars match zero or more module components
This is not the case for stars at the start of the string. For example [mypy-*.foo.bar] does not match module foo.bar
>>> import re
>>> from mypy.options import Options
>>> pattern = Options().compile_glob("*.foo.bar")
re.compile('.*\\.foo\\.bar\\Z')
>>> bool(re.match(pattern, "foo.bar"))
False
Second issue:
[mypy-*] does not match anything. I know that it does not make sense to use this since it is the same as global config, but it would be nice to work nonetheless.
In this case it is a bit more difficult: compile_glob returns correct re.compile('.*\\Z'), but there is some flawed logic in build_per_module_cache(), where it gets to concrete section since it does not end with ".*"
Python: 3.7.2
Mypy: 0.770
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in mypy/options.py mit Options.compile_glob() und build_per_module_cache(), und reproduziere dann die beiden Beispiele aus dem Issue für *.foo.bar und *. Überprüfe, wie die Muster klassifiziert werden, und stelle sicher, dass Muster mit führendem Stern konsistent mit der dokumentierten Regel funktionieren, dass Sterne auf null oder mehr Modulkomponenten passen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100