Skip to content

Commit

Permalink
SQ: Fix missing GenericAlias in Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfstr committed Apr 12, 2024
1 parent 8fa8bd6 commit 707ff17
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions trycast.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections.abc import MutableSequence as CMutableSequence
from collections.abc import Sequence as CSequence
from inspect import Parameter
from types import GenericAlias, ModuleType
from types import ModuleType
from typing import ForwardRef # type: ignore[import-error] # pytype (for ForwardRef)
from typing import _GenericAlias # type: ignore[attr-defined]
from typing import (
Expand Down Expand Up @@ -40,10 +40,22 @@
from typing import _type_repr as type_repr # type: ignore[attr-defined]
from typing import cast, get_args, get_origin, overload


# GenericAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
else:

class GenericAlias(type): # type: ignore[no-redef]
def __init__(self, origin: object, args: tuple[object, ...]) -> None: ...

...


# UnionType
try:
if sys.version_info >= (3, 10):
from types import UnionType # type: ignore[attr-defined]
except ImportError:
else:

class UnionType(type): # type: ignore[no-redef]
...
Expand Down

0 comments on commit 707ff17

Please sign in to comment.