From 3af2c3a09b7e1ccadc4e8e491263018c2461e281 Mon Sep 17 00:00:00 2001 From: Jacob Hayes Date: Tue, 16 Nov 2021 16:41:06 -0500 Subject: [PATCH] Fix py 3.10 test errors --- src/arti/internal/type_hints.py | 3 ++- tests/arti/internal/test_type_hints.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/arti/internal/type_hints.py b/src/arti/internal/type_hints.py index eaf72d02..cc564c06 100644 --- a/src/arti/internal/type_hints.py +++ b/src/arti/internal/type_hints.py @@ -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) @@ -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 diff --git a/tests/arti/internal/test_type_hints.py b/tests/arti/internal/test_type_hints.py index b4b290a7..5812e17d 100644 --- a/tests/arti/internal/test_type_hints.py +++ b/tests/arti/internal/test_type_hints.py @@ -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