pip install type-analyzerfrom type_analyzer import MatchingTypesConfig, matching_types
# ----- Union type -----
matching_types(str | int)
# => (str, int)
# ----- Generic type alias -----
type StringOr[T] = str | T
config = MatchingTypesConfig(with_type_alias_value=True)
matching_types(StringOr[int], config)
# => (StringOr[int], str, int)
# ----- Generic classes -----
class A[T]:
...
class B[T]:
...
class C[T1, T2](A[T1], B[T2]):
...
config = MatchingTypesConfig(with_bases=True)
matching_types(C[str, int], config)
# => (C[str, int], A[str], B[int])