Skip to content

Commit

Permalink
Fix: UnionType is new in 3.10
Browse files Browse the repository at this point in the history
Signed-off-by: Yorick van Pelt <[email protected]>
  • Loading branch information
yorickvP committed Nov 21, 2023
1 parent 9e33abe commit eacfc52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/cog/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from abc import ABC, abstractmethod
from collections.abc import Iterator
from pathlib import Path
from types import UnionType
import types
from typing import (
Any,
Callable,
Expand Down Expand Up @@ -224,7 +224,7 @@ def validate_input_type(type: Type, name: str) -> None:
f"No input type provided for parameter `{name}`. Supported input types are: {readable_types_list(ALLOWED_INPUT_TYPES)}, or a Union or List of those types."
)
elif type not in ALLOWED_INPUT_TYPES:
if get_origin(type) in (Union, List, UnionType, list):
if get_origin(type) in (Union, List, list) or (hasattr(types, "UnionType") and get_origin(type) is types.UnionType):
for t in get_args(type):
validate_input_type(t, name)
else:
Expand Down

0 comments on commit eacfc52

Please sign in to comment.