Fix typing to cypher type impl inside mgp.py (#159)

This commit is contained in:
Marko Budiselić 2021-06-09 10:09:43 -07:00 committed by GitHub
parent cd03e13443
commit 542a324c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: