-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
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 TypeAliasMypy 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
Avasam