Skip to content

Commit 0900c3b

Browse files
committed
fix tests
1 parent 6973c78 commit 0900c3b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

polyfactory/utils/normalize_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def normalize_type(type_annotation: Any) -> Any:
4040
"""
4141

4242
if is_type_alias(type_annotation):
43-
return type_annotation.__value__
43+
return normalize_type(type_annotation.__value__)
4444

4545
if not is_generic_alias(type_annotation):
4646
return type_annotation
@@ -85,7 +85,7 @@ def __apply_substitutions(target: Any, subs: Mapping[Any, Any]) -> Any:
8585

8686
if is_union(target):
8787
args = tuple(__apply_substitutions(arg, subs) for arg in get_args(target))
88-
return Union[args]
88+
return Union[*args]
8989

9090
origin = get_origin(target)
9191
args = get_args(target)

polyfactory/utils/predicates.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import sys
34
from inspect import isclass
45
from typing import Annotated, Any, ForwardRef, Literal, NewType, Optional, TypeGuard, TypeVar, get_args, get_origin
56

@@ -10,11 +11,12 @@
1011
TypeAliasType,
1112
)
1213

13-
try:
14-
from typing_extensions import TypeAliasType as typing_TypeAliasType
14+
# Python 3.12+ has TypeAliasType in typing module, and it's different from typing_extensions version
15+
if sys.version_info >= (3, 12):
16+
from typing import TypeAliasType as typing_TypeAliasType
1517

1618
AllTypeAliasTypes: tuple[type, ...] = (TypeAliasType, typing_TypeAliasType)
17-
except ImportError:
19+
else:
1820
AllTypeAliasTypes = (TypeAliasType,)
1921

2022

0 commit comments

Comments
 (0)