`typing.TYPE_CHECKER` object to change types depending on which type checker is being run
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
One issue I have run into as a library dev is varying support for typing features or bugs for both of the type checkers. typing.TYPE_CHECKER would allow me to change type definition based on the type checker so that I can support all static analysis tools more effectively.
I propose that TYPE_CHECKER would be a dict with a "name" and "version" key. Type checkers could also optionally add other keys/values.
TYPE_CHECKER = {
"name": "type-checker-name",
# `VersionInfo` would be implemented by each type checker to match their versioning scheme.
"version": VersionInfo(...),
}
Using it for types would look like this:
if TYPE_CHECKER.get("name") == "pyright" and TYPE_CHECKER.get("version") > (1, 1, 290):
T = TypeVar("T", default=int)
else:
T = TypeVar("T")
At runtime I think the TYPE_CHECKER object should be an empty dictionary.
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
L’issue elle-même est le point d’entrée : commencez par examiner le dictionnaire TYPE_CHECKER proposé, ses champs de nom et de version, ses valeurs facultatives et son comportement à l’exécution lorsqu’il est vide. Déterminez comment les vérificateurs de types fourniraient des informations de version cohérentes, puis définissez et validez l’interface convenue.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100