Skip to content

Commit b4468f9

Browse files
author
matmoncon
committed
fix: convert list to set before comparing contents
1 parent be4eacf commit b4468f9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pyneo4j_ogm/core/node.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
It provides base functionality like de-/inflation, validation and methods for interacting with
44
the database for CRUD operations on nodes.
55
"""
6+
67
import json
78
from copy import deepcopy
89
from functools import wraps
@@ -363,12 +364,16 @@ async def find_connected_nodes(
363364
if "$node" not in filters or "$labels" not in filters["$node"]:
364365
raise InvalidFilters()
365366

366-
labels = cast(List[str], filters["$node"]["$labels"])
367+
labels = set(filters["$node"]["$labels"])
367368

368369
# Get target node model from the models registered with the client
369370
# If no model is found, someone forgot to register it
370371
for model in self._client.models:
371-
if hasattr(model._settings, "labels") and list(getattr(model._settings, "labels", [])) == labels:
372+
if not issubclass(model, NodeModel):
373+
continue
374+
375+
model_labels = set(getattr(model._settings, "labels", []))
376+
if not model_labels.difference(labels):
372377
target_node_model = cast("NodeModel", model)
373378
break
374379

tests/test_validators.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# pylint: disable=missing-module-docstring, missing-class-docstring
2-
# pyright: reportUnboundVariable=false
32

43
from pydantic import BaseModel
54
from pydantic.class_validators import root_validator

0 commit comments

Comments
 (0)