Clarify the float/int/complex special case
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Documentación
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- documentation
Línea de trabajo
Comienza con la sección numeric-types citada de la typing spec y revisa la discusión relacionada en typing/issues/1663. Resuelve si el atajo se aplica únicamente a los argumentos de las funciones y cómo se entiende el tipo aceptado dentro de la función; después, actualiza la redacción con ejemplos y una definición precisa de lo que significa "done".
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The typing spec currently says this:
Python’s numeric types complex, float and int are 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 type float, an argument of type int is acceptable; similar, for an argument annotated as having type complex, arguments of type float or int are acceptable.
This is helpful in that it clarifies that there is not a subtype relationship here. It remains unclear (to me, at least) in the following ways:
- It implies that this special case applies only to function argument annotations, and not to any other annotation (e.g. an annotation of the type of an attribute of a class). I find this surprising, but perhaps it is intended? I think it is surprising enough that if it's intended, the wording should be even clearer, and explicitly show examples where the special case does not apply outside an argument annotation.
- The wording "is acceptable" in the absence of a subtype relationship does not clarify how this special case actually fits into the type system; we can accept an
intto afloattyped argument, but then how do we type that name within the function body? If what we actually mean here is thatfloatshould be interpreted asfloat | int, then we should say that clearly.
There was some discussion of this on https://github.com/python/typing/issues/1663, which is about the different but related question of whether to mention the numeric tower and PEP 3141.
- 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
-
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 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 ·
-
Change observation tooltip text Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
CSCfi/sd-search-api#39 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100