`typing.TYPE_CHECKER` object to change types depending on which type checker is being run
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 302
- Merge medio
- 23h
- PR unite (30g)
- 8
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
La issue stessa è il punto di ingresso: inizia esaminando il dizionario TYPE_CHECKER proposto, i relativi campi name e version, i valori opzionali e il comportamento a runtime vuoto. Determina come i type checker fornirebbero informazioni di versione coerenti, quindi definisci e valida l’interfaccia concordata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100