From 542a324c96cb317d8fbfd36563c1d53b5b152f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Budiseli=C4=87?= Date: Wed, 9 Jun 2021 10:09:43 -0700 Subject: [PATCH] Fix typing to cypher type impl inside mgp.py (#159) --- include/mgp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/mgp.py b/include/mgp.py index a0f7bab50..a7044a77d 100644 --- a/include/mgp.py +++ b/include/mgp.py @@ -627,8 +627,11 @@ def _typing_to_cypher_type(type_): if complex_type == typing.Union: # If we have a Union with NoneType inside, it means we are building # a nullable type. - if isinstance(None, type_args): - types = tuple(t for t in type_args if not isinstance(None, t)) + # isinstance doesn't work here because subscripted generics cannot + # be used with class and instance checks. type comparison should be + # fine because subclasses are not used. + if type(None) in type_args: + types = tuple(t for t in type_args if t is not type(None)) # noqa E721 if len(types) == 1: type_arg, = types else: