Async Cardinality always throwing type error.
Opened this issue · 3 comments
JoshJarabek7 commented
Expected Behavior (Mandatory)
Be able to set cardinality between two Nodes that should have a One-to-One relationship.
Actual Behavior (Mandatory)
Throwing type error.
Argument of type "type[AsyncOne]" cannot be assigned to parameter "cardinality" of type "type[AsyncZeroOrMore]" in function "__init__"
"type[AsyncOne]" is incompatible with "type[AsyncZeroOrMore]"
Type "type[AsyncOne]" is incompatible with type "type[AsyncZeroOrMore]"Pyright[reportArgumentType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportArgumentType)
How to Reproduce the Problem
Adding a cardinality of AsyncOne within Async RelationshipTo and AsyncRelationshipFrom
Simple Example
from datetime import UTC, datetime
from neomodel import (AsyncOne, AsyncRelationshipFrom, AsyncRelationshipTo,
AsyncStructuredNode, AsyncStructuredRel, AsyncZeroOrOne,
BooleanProperty, DateTimeProperty, IntegerProperty, One,
StringProperty, config)
class PostedRel(AsyncStructuredRel):
is_private = BooleanProperty()
created_at = DateTimeProperty(default=datetime.now(UTC))
class User(AsyncStructuredNode):
user_id = StringProperty(unique_index=True, required=True)
apple_id = StringProperty(unique_index=True, required=True)
email = StringProperty(unique_index=True, required=True)
username = StringProperty()
display_name = StringProperty()
first_name = StringProperty()
last_name = StringProperty()
profile_photo = StringProperty()
header_photo = StringProperty()
profile_song = StringProperty()
account_active = BooleanProperty()
account_private = BooleanProperty()
created_at = DateTimeProperty(default=datetime.now(UTC))
last_login = DateTimeProperty(default=datetime.now(UTC))
last_seen = DateTimeProperty()
follows = AsyncRelationshipTo("User", "FOLLOWS")
blocks = AsyncRelationshipTo("User", "BLOCKS")
mutes = AsyncRelationshipTo("User", "MUTES")
posts = AsyncRelationshipFrom("Post", "POSTED")
reposts = AsyncRelationshipFrom("Post", "REPOSTED")
user_stats = AsyncRelationshipTo("UserStats", "USER_STATS", cardinality=AsyncOne) # Throwing Type Error
class UserStats(AsyncStructuredNode):
user = AsyncRelationshipFrom("User", "USER_STATS", cardinality=AsyncOne) # Throwing Type Error
following_count = IntegerProperty()
followers_count = IntegerProperty()
likes_count = IntegerProperty()
repost_count = IntegerProperty()
quote_count = IntegerProperty()
replies_count = IntegerProperty()
bookmarked_count = IntegerProperty()
correct_prediction_count = IntegerProperty()
predictions_made_count = IntegerProperty()
profile_visits_count = IntegerProperty()
Screenshots (where it's possible)
Can't figure out how to screenshot the hover-over error while screenshotting, the popup goes away.
Specifications (Mandatory)
neomodel = {extras = ["extras"], version = "^5.3.2"}
Currently used versions
Versions
- OS: MacOS 14.5
- Neo4j: Neo4j 5.2.1
mariusconjeaud commented
JoshJarabek7 commented
I use Pyright and Ruff with VSCodium. I believe it was Pyright that was throwing the error. I also have the typing set to Strict, so that might be the issue.
mariusconjeaud commented
OK. If anybody has an idea how to make this right ? Otherwise, it is not technically a bug, so I will mark this for later closure.