dropbox / dropbox/sqlalchemy-stubs

incompatible type "Column[int]"; expected "str" [list-item]

Open
#156 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
583
Forks
96
PR merge metrics
No merged PRs in 30d

Description

Hi,

First off, thanks a lot for your work on this plugin!

I am encountering a (somewhat logical) incompatible type error, and was wondering if this is something we should expect the plugin to address:

```python
class MyTable(Model):
id = db.Column(db.Integer, db.ForeignKey(User.id), nullable=False)
b_id = Column(db.Integer, nullable=False)
b_version = Column(db.Integer, nullable=False)

__table_args__: tp.Union[tp.Dict, tp.Tuple] = (
db.ForeignKeyConstraint([b_id, b_version], [B.id, B.version]),
# List item 0 has incompatible type "Column[int]"; expected "str" [list-item]
# List item 1 has incompatible type "Column[int]"; expected "str" [list-item]
{}
)
```

Column implicitly converts to a string representing the column name, and I believe the above is the recommended way to use it. But, unsurprisingly, mypy does not like that. Could we either add `Column` to the signature of these functions in the stubs, or define a `[str, Column]` type alias?

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.