Finals and Literals: Spec contradiction
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 1.8k
- Forks
- 302
- Merge moyen
- 23 h
- PR mergées (30 j)
- 8
Description
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.)
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.
Piste de recherche
Commencez par comparer la syntaxe de Final et la formulation concernant l’utilisation des littéraux dans la typing specification avec PEP 591 et PEP 586. Examinez conformance/tests/qualifiers_final_annotation.py, en particulier les lignes 11-13, et étendez les cas pertinents si nécessaire. La tâche est terminée lorsque la spécification est cohérente en interne et que les conformance tests reflètent le comportement clarifié.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- documentation, testing-qa
- Type d'issue
- Documentation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 72/100