python / python/mypy

Per-module options patterns starting with *

Aperta
#8,522 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug priority-2-low topic-configuration
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in mypy/options.py con Options.compile_glob() e build_per_module_cache(), quindi riproduci i due esempi dell’issue per *.foo.bar e *. Verifica come vengono classificati i pattern e assicurati che i pattern con un asterisco iniziale si comportino in modo coerente con la regola documentata secondo cui gli asterischi corrispondono a zero o più componenti del modulo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
devtools
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.