Skip to content

Commit 19fe631

Browse files
committed
up
1 parent 41381b1 commit 19fe631

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/diffusers/utils/typing_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
Typing utilities: Utilities related to type checking and validation
1616
"""
1717

18+
from types import UnionType
1819
from typing import Any, Set, Type, Union, get_args, get_origin
19-
from types import UnionType as _UnionType
20+
2021

2122
def _is_valid_type(obj: Any, class_or_tuple: Type | tuple[Type, ...]) -> bool:
2223
"""
@@ -30,9 +31,9 @@ def _is_valid_type(obj: Any, class_or_tuple: Type | tuple[Type, ...]) -> bool:
3031
unpacked_class_or_tuple = []
3132
for t in class_or_tuple:
3233
origin = get_origin(t)
33-
is_union = origin is Union or (_UnionType is not None and origin is _UnionType)
34+
is_union = origin is Union or origin is UnionType
3435
# For PEP 604 unions (e.g. int | float), origin can be None but the object itself is a UnionType
35-
if not is_union and _UnionType is not None and isinstance(t, _UnionType):
36+
if not is_union and isinstance(t, UnionType):
3637
is_union = True
3738
if is_union:
3839
unpacked_class_or_tuple.extend(get_args(t))

0 commit comments

Comments
 (0)