Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no type checking with __eq__ in all the graph classes #2524

Closed
RJ-Infinity opened this issue Dec 20, 2022 · 0 comments · Fixed by #2531
Closed

no type checking with __eq__ in all the graph classes #2524

RJ-Infinity opened this issue Dec 20, 2022 · 0 comments · Fixed by #2531
Labels
bug Bug

Comments

@RJ-Infinity
Copy link

Version: redis-py version 4.4.0 (redis version shouldnt matter but i'm using redis-stack 6.2.4-v3)

Platform: python version 3.10.9 (but should effect all versions) on wsl Ubuntu 20.04.5 LTS

Description: none of the redis graph classes check the types when checking equality

import redis.commands.graph as redisGraph
foo = redisGraph.Node()

foo == None # this line causes the error
AttributeError: 'NoneType' object has no attribute 'label'

you get the same error when checking against any type that is not a Node

it also happens with the Edge class

bar = redisGraph.Edge(foo,"",foo)
bar == ""
AttributeError: 'str' object has no attribute 'src_node'

and also the Path class

baz = redisGraph.Path([],[])
baz == 4
AttributeError: 'int' object has no attribute 'nodes'

i suspect adding this sort of code in would fix it

# Check that the rhs the correct type
if not isinstance(rhs, type(self)):
    return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants