Skip to content

Commit

Permalink
DEV: resolve import error on 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcar17 committed May 1, 2024
1 parent 2c1900c commit 4d30ae5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cogent3/app/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@

import inspect
import re
import sys

from typing import ForwardRef, TypeVar, Union
from types import UnionType

from typing_extensions import get_args, get_origin


if sys.version_info.minor >= 10:
from types import UnionType

NESTED_HINTS = (Union, UnionType, list, tuple, set)
else:
NESTED_HINTS = (Union, list, tuple, set)

AlignedSeqsType = TypeVar("AlignedSeqsType", "Alignment", "ArrayAlignment")
UnalignedSeqsType = TypeVar("UnalignedSeqsType", bound="SequenceCollection")
SeqsCollectionType = Union[AlignedSeqsType, UnalignedSeqsType]
Expand Down Expand Up @@ -76,7 +83,7 @@ def get_constraint_names(*hints) -> set[str | type]:
all_hints.update(hint.__constraints__)
continue

if get_origin(hint) in (Union, UnionType, list, tuple, set):
if get_origin(hint) in NESTED_HINTS:
all_hints.update(get_constraint_names(*get_args(hint)))

if type(hint) == type:
Expand Down

0 comments on commit 4d30ae5

Please sign in to comment.