dropbox / dropbox/sqlalchemy-stubs

Support collection_class in relationship()

Open
#107 7 comments 1 reaction 0 assignees View on GitHub
enhancement priority-normal topic-plugins
Dominant language
Python
Stars
583
Forks
96
PR merge metrics
No merged PRs in 30d

Description

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.

```python
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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.