Finals and Literals: Spec contradiction
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 1.8k
- Forks
- 302
- Merge medio
- 23 h
- PR fusionados (30 d)
- 8
Descripción
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.)
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza comparando la sintaxis de Final y la redacción sobre el uso de literales en la typing specification con PEP 591 y PEP 586. Revisa conformance/tests/qualifiers_final_annotation.py, especialmente las líneas 11-13, y amplía los casos pertinentes si es necesario. La tarea estará terminada cuando la especificación sea internamente coherente y los conformance tests reflejen el comportamiento aclarado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- documentation, testing-qa
- Tipo de issue
- Documentación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 72/100