From 14d2e4575d81269fd3884442d8bdaea31561a966 Mon Sep 17 00:00:00 2001 From: Joseph Perez Date: Mon, 12 Dec 2022 00:34:17 +0100 Subject: [PATCH] Quick fix #515 --- apischema/conversions/utils.py | 3 ++- apischema/json_schema/types.py | 2 +- apischema/typing.py | 2 +- tests/unit/test_subscriptions.py | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apischema/conversions/utils.py b/apischema/conversions/utils.py index 14294178..26807336 100644 --- a/apischema/conversions/utils.py +++ b/apischema/conversions/utils.py @@ -76,5 +76,6 @@ def converter_types( def is_convertible(tp: AnyType) -> bool: origin = get_origin_or_type(tp) return is_new_type(tp) or ( - is_type(origin) and not (is_literal(tp) or is_annotated(tp) or is_union(origin)) + is_type(origin) + and not (tp is Any or is_literal(tp) or is_annotated(tp) or is_union(origin)) ) diff --git a/apischema/json_schema/types.py b/apischema/json_schema/types.py index daf4b9ee..016e688b 100644 --- a/apischema/json_schema/types.py +++ b/apischema/json_schema/types.py @@ -34,7 +34,7 @@ class JsonType(str, Enum): def from_type(cls: Type) -> "JsonType": return TYPE_TO_JSON_TYPE[cls] - def __str__(self) -> str: + def __str__(self): return self.value diff --git a/apischema/typing.py b/apischema/typing.py index 132163c4..e558fef7 100644 --- a/apischema/typing.py +++ b/apischema/typing.py @@ -276,7 +276,7 @@ def typing_origin(origin: Any) -> Any: def is_type(tp: Any) -> bool: """isinstance is not enough because in py39: isinstance(list[int], type) == True""" - return isinstance(tp, type) and not get_args(tp) and tp is not Any + return isinstance(tp, type) and not get_args(tp) def is_union(tp: Any) -> bool: diff --git a/tests/unit/test_subscriptions.py b/tests/unit/test_subscriptions.py index e451fb15..6c30ed72 100644 --- a/tests/unit/test_subscriptions.py +++ b/tests/unit/test_subscriptions.py @@ -46,7 +46,6 @@ def hello() -> str: @pytest.mark.parametrize("conversion", [None, event_name]) @pytest.mark.parametrize("error_handler", [Undefined, None]) @pytest.mark.parametrize("resolver", [None, events2]) -@pytest.mark.asyncio async def test_subscription(alias, conversion, error_handler, resolver): if alias is not None: sub_name = alias