Skip to content

Commit

Permalink
Fix py 3.10 test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHayes committed Nov 17, 2021
1 parent f0d8af0 commit 3af2c3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/arti/internal/type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def lenient_issubclass(klass: Any, class_or_tuple: Union[type, tuple[type, ...]]
if isinstance(class_or_tuple, tuple):
return any(lenient_issubclass(klass, subtype) for subtype in class_or_tuple)
check_type = class_or_tuple
# NOTE: py 3.10 supports issubclass with Unions (eg: `issubclass(str, str | int)`)
if is_union_hint(check_type):
return any(lenient_issubclass(klass, subtype) for subtype in get_args(check_type))
return _check_issubclass(klass, check_type)
Expand Down Expand Up @@ -120,7 +121,7 @@ def signature(
# Focusing on 3.9+ (for now)


if sys.version_info < (3, 10):
if sys.version_info < (3, 10): # pragma: no cover

def is_union(type_: Any) -> bool:
return type_ is Union
Expand Down
2 changes: 1 addition & 1 deletion tests/arti/internal/test_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_lenient_issubclass_false(

def test_lenient_issubclass_error_cases() -> None:
assert not lenient_issubclass(5, 5) # type: ignore
with pytest.raises(TypeError, match="arg 2 must be a class or tuple of classes"):
with pytest.raises(TypeError, match="arg 2 must be a class"):
lenient_issubclass(tuple, 5) # type: ignore


Expand Down

0 comments on commit 3af2c3a

Please sign in to comment.