Typing spec should be clearer that type checkers are not expected to support PEP 3141
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- documentation
Línea de trabajo
Comienza con la página “Special cases for float and complex” de la typing spec y compara su redacción con los pasajes enlazados de PEP 484 y PEP 3141. Aclara que las ABCs de PEP 3141 no son las anotaciones numéricas recomendadas y que es posible que los comprobadores de tipos no las admitan; el pasaje actualizado debe conservar la explicación existente sobre la abreviatura numérica.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
With regards to the numeric tower, PEP 484 states:
PEP 3141 defines Python’s numeric tower, and the stdlib module
numbersimplements the corresponding ABCs (Number,Complex,Real,RationalandIntegral). There are some issues with these ABCs, but the built-in concrete numeric classescomplex,floatandintare ubiquitous (especially the latter two :-).Rather than requiring that users write
import numbersand then usenumbers.Floatetc., this PEP proposes a straightforward shortcut that is almost as effective: when an argument is annotated as having typefloat, an argument of typeintis acceptable; similar, for an argument annotated as having typecomplex, arguments of typefloatorintare acceptable. This does not handle classes implementing the corresponding ABCs or thefractions.Fractionclass, but we believe those use cases are exceedingly rare.
This is a very useful passage to link to, because:
- It clearly (albeit tersely) states that the PEP-3141 ABCs are problematic
- It clearly states the separate solution that PEP-484 proposes for dealing with numeric types
- It frames the PEP-484 solution in opposition and contrast to the PEP-3141 solution
The parallel passage in the typing spec currently states this:
Python’s numeric types
complex,floatandintare not subtypes of each other, but to support common use cases, the type system contains a straightforward shortcut: when an argument is annotated as having typefloat, an argument of typeintis acceptable; similar, for an argument annotated as having typecomplex, arguments of typefloatorintare acceptable.
Since PEP-484 is a historical document rather than a piece of living documentation, it would be great if the typing spec could state as clearly as PEP-484 that the PEP-3141 ABCs are not the recommended way of annotating numeric types in Python, and that type checkers may not necessarily (and in fact probably won't ever) support them.
- Lenguaje dominante
- Python
- Estrellas
- 1.8k
- Forks
- 302
- Merge medio
- 23 h
- PR fusionados (30 d)
- 8
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.
Más de python/typing
-
topic: typing spec
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
topic: typing spec
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
topic: documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
topic: documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
topic: conformance tests topic: typing spec
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Todos los issues de python/typing
Issues similares
-
🐛 Bug 🔔 Pending processing
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
jumpserver/jumpserver#17584 ·
-
link-check link-check:sphinx-theme
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
modelscope/DiffSynth-Studio#1702 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
OpenHands/extensions#626 · 1 comentario ·