Support conditionally importing from typing_extensions
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
This code tries to import TypeAlias from typing if possible and falls back to typing_extensions if it isn't available (e.g. on Python 3.8):
try:
from typing import TypeAlias # type: ignore
except ImportError:
from typing_extensions import TypeAlias
Mypy doesn't actually support this as expected in older Python versions that are missing the definition in typing. They will just get an Any value, and the except block has no significance.
Perhaps the import from typing_extensions should take precedence? Or can we at least generate a more specific error about this?
A possible workaround is to flip the order of the imports.
This probably affects any feature that requires an import of a backported definition from typing_extensions.
Related issue: #14219
Guida per i contributori
Apri la guida per i contributori
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
Non viene indicato alcun file, test o punto di ingresso. Inizia esaminando il comportamento di importazione condizionale di TypeAlias descritto qui e la issue correlata #14219; determina se è prevista una precedenza di importazione o una diagnosi, quindi verifica il comportamento scelto per le versioni precedenti di Python.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100