Improve mypy --pretty output for (multiline) f-strings
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Error messages merely say the line number, which is not always accurate - e.g. for multiline strings it's merely the first or last line of the overall multiline string (depending on Python version). If it's a format string and there's dozens of {} elements embedded in it, maybe across hundreds of lines, it can be practically impossible to tell what mypy is referring to. e.g. here's the actual output from a current problem:
src.py:136: error: "str" has no attribute "expression" [attr-defined]
src.py:136: error: Item "str" of "Optional[str]" has no attribute "expression" [union-attr]
src.py:136: error: Item "None" of "Optional[str]" has no attribute "expression" [union-attr]
src.py:136: error: Item "float" of "Optional[float]" has no attribute "expression" [union-attr]
src.py:136: error: Item "None" of "Optional[float]" has no attribute "expression" [union-attr]
src.py:136: error: "float" has no attribute "expression" [attr-defined]
src.py:136: error: "bool" has no attribute "expression" [attr-defined]
src.py:136: error: "int" has no attribute "expression" [attr-defined]
The multiline string these are embedded in is nearly a hundred lines long and has dozens of embedded elements, almost all of which reference an espression attribute. I genuinely have no idea which ones these messages are referring to. If it at least told me the name of the variable (or whatever), I'd be able to narrow it down.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando il rendering dei diagnostici di mypy con --pretty per gli errori che si verificano negli f-string multilinea; confronta la posizione segnalata con l'espressione incorporata che lo ha causato. Il lavoro è completato quando l'output pretty identifica l'espressione o la variabile rilevante dell'f-string, invece di indicare soltanto la riga dell'intera stringa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100