`str-format` for fill and align specifiers
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
Feature
The fill and align string format specifiers do not currently have type checking, but are not supported by all types. Specifically, None does not support them.
Pitch
I ran into a bug where an optional type was being passed to string formatting using <. This would succeed most of the time, but error if the value was None:
>>> "{:<2}".format(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to NoneType.__format__
It would be great if mypy would catch this code as a type violation.
I attempted to implement here: https://github.com/python/mypy/pull/18799 but this was more challenging than I anticipated and I am a first time contributor.
Thanks.
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
Esamina innanzitutto l’implementazione tentata in PR #18799, quindi traccia il modo in cui mypy gestisce il controllo dei tipi degli specificatori di formato per gli specificatori di riempimento e allineamento. Il lavoro è completato quando mypy segnala un errore se un valore opzionale come None viene formattato con uno specificatore di riempimento o allineamento non supportato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100