Finals and Literals: Spec contradiction
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 302
- Merge medio
- 23h
- PR unite (30g)
- 8
Descrizione
This came up in python/typeshed#16301. I assume this is mostly a clerical/historical error, but let me know if we should follow the whole spec change process.
The typing spec says about Final:
Example:
ID: Final = 1The typechecker should apply its usual type inference mechanisms to determine the type of ID (here, likely, int).
And then a bit later:
Type checkers should treat uses of a final name that was initialized with a literal as if it was replaced by the literal.
Both sentences are copied directly from PEP 591, which overlapped with the Literals PEP 586.
I assume that we should change the first sentence to "here, likely, Literal[1]" and change the second sentence to be a bit more concrete along these lines:
Type checkers should infer uses of a final name that was initialized with a literal
XasLiteral[X]ifXis an allowed literal type (cf. to the literals section). Otherwise, they should infer the type of theX.
(And maybe extend the example after a bit.)
In fact, this is what the conformance tests already check:
(Although the tests could be extended a bit.)
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
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 confrontando la sintassi di Final e la formulazione relativa all’uso dei valori letterali nella typing specification con PEP 591 e PEP 586. Esamina conformance/tests/qualifiers_final_annotation.py, in particolare le righe 11-13, ed estendi i casi pertinenti se necessario. Il lavoro è completato quando la specifica è internamente coerente e i conformance tests riflettono il comportamento chiarito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- documentation, testing-qa
- Tipo di issue
- Documentazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 72/100