mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-06-25 09:58:21 -04:00
python 3.9 compat: introduce typehelpers.py for NoneType, UnionType, TypeAlias
This commit is contained in:
parent
c357b0a968
commit
b84d2202db
9 changed files with 34 additions and 27 deletions
18
typehelpers.py
Normal file
18
typehelpers.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from typing import Union
|
||||
|
||||
try:
|
||||
from typing import TypeAlias # type: ignore[attr-defined]
|
||||
except ImportError:
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
TypeAlias = TypeAlias
|
||||
|
||||
try:
|
||||
from types import UnionType
|
||||
except ImportError:
|
||||
UnionType: TypeAlias = Union # type: ignore[no-redef]
|
||||
|
||||
try:
|
||||
from types import NoneType
|
||||
except ImportError:
|
||||
NoneType: TypeAlias = type(None) # type: ignore[no-redef]
|
Loading…
Add table
Add a link
Reference in a new issue