Typing spec should be clearer that type checkers are not expected to support PEP 3141
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 38/100
- Type d'issue
- Documentation
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- documentation
Piste de recherche
Commencez par la page « Special cases for float and complex » de la typing spec et comparez sa formulation avec les passages liés de PEP 484 et PEP 3141. Précisez que les ABCs de PEP 3141 ne sont pas les annotations numériques recommandées et que les vérificateurs de types peuvent ne pas les prendre en charge ; le passage mis à jour doit conserver l’explication existante sur la notation abrégée numérique.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 1.8k
- Forks
- 302
- Merge moyen
- 23 h
- PR mergées (30 j)
- 8
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python/typing
-
topic: typing spec
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
topic: typing spec
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
topic: documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
topic: documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
topic: conformance tests topic: typing spec
Difficulté 3/5 1-2 jours Accessibilité débutants 72/100
Toutes les issues de python/typing
Issues similaires
-
link-check link-check:sphinx-theme
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
OpenHands/extensions#626 · 1 commentaire ·
-
Change observation tooltip text Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
CSCfi/sd-search-api#39 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100