Support collection_class in relationship()
See original GitHub issueI 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.
repositories: Set['Repository'] = relationship('Repository', back_populates="installation", uselist=True, collection_class=set)
This is the error I get when running mypy
with sqlalchemy-stubs
error: Incompatible types in assignment (expression has type "RelationshipProperty[Iterable[Repository]]", variable has type "Set['Repository']")
I also tried with InstrumentedSet
which is the instance returned by relationship
in my case. but no success. The code works btw, so it’s really mypy
that is not able to understand.
Do you think it’s the scope of sqlalchemy-stubs
?
Information
python 3.6
sqlalchemy 1.3.8 Database Abstraction Library
sqlalchemy-stubs 0.2 SQLAlchemy stubs and mypy plugin
├── mypy >=0.660
│ ├── mypy-extensions >=0.4.0,<0.5.0
│ ├── typed-ast >=1.4.0,<1.5.0
│ └── typing-extensions >=3.7.4
│ └── typing >=3.7.4
└── typing-extensions >=3.6.5
└── typing >=3.7.4
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Collection Configuration and Techniques
The relationship() function defines a linkage between two classes. ... AppenderQuery. A dynamic query that supports basic collection storage operations.
Read more >Defining and Using Relationships - InterSystems Documentation
Describes how to define and use relationships, a special kind of property used to ... In this case, we use the RemoveAt() method...
Read more >Does a class with has-a relationship with a Collection object ...
I would say yes. The collection is almost immaterial here, more just an implementation detail of the "has-a" relationship between the class and ......
Read more >Return eloquent collection from relationship method - Laracasts
This works fine and returns an eloquent collection of all consultations of a user. I have a Practice model that has a members()...
Read more >Relationship Class (Microsoft.AnalysisServices.Tabular)
Represents a logical relationship between two Table objects. It is a child of a Model object.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK, the latter error can be fixed by adding support for
collection_class
. On one hand this doesn’t look like high priority (there is a simple workaround like adding correct annotation plus a# type: ignore
), but on other hand this should not be hard to fix.