-
Notifications
You must be signed in to change notification settings - Fork 99
Support collection_class in relationship() #107
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
Comments
repositories: RelationshipProperty[Set['Repository']] = relationship('Repository', back_populates="installation", uselist=True, collection_class=set) That one should work I hope, otherwise it is a bug in |
I will try tomorrow with your suggestion. but I am afraid that it will not behave correctly for intellisense |
The code repositories: RelationshipProperty[Set['Repository']] = relationship('Repository', back_populates="installation", uselist=True, collection_class=set) The error error: Incompatible types in assignment (expression has type "RelationshipProperty[Iterable[Repository]]", variable has type "RelationshipProperty[Set[Repository]]") |
OK, the latter error can be fixed by adding support for |
may you give more information about the "correct annotation" ? |
repositories: RelationshipProperty[Set['Repository']] = relationship('Repository', back_populates="installation", uselist=True, collection_class=set) # type: ignore |
thx I finally had the time to try this, and I have a funny case again. the annotation this does not work repositories: Set['Repository'] = relationship('Repository', back_populates="installation", uselist=True, collection_class=set,
cascade="all, delete-orphan") # type: ignore error src/models.py:30: error: Incompatible types in assignment (expression has type "RelationshipProperty[Iterable[Repository]]", variable has type "Set[Repository]") this works repositories: Set['Repository'] = relationship('Repository', back_populates="installation", uselist=True, collection_class=set, # type: ignore
cascade="all, delete-orphan") looks like the annotation has to be on the same line instead of the instruction. Is this wanted behaviour ? |
I do not know if #82 will fix the issue but I have the following problem with mypy. I use
typing
in order to simplify coding.This is the error I get when running
mypy
withsqlalchemy-stubs
I also tried with
InstrumentedSet
which is the instance returned byrelationship
in my case. but no success. The code works btw, so it's reallymypy
that is not able to understand.Do you think it's the scope of
sqlalchemy-stubs
?Information
The text was updated successfully, but these errors were encountered: