Skip to content

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

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

Open
zedrdave opened this issue May 22, 2020 · 0 comments · May be fixed by #203
Open

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

zedrdave opened this issue May 22, 2020 · 0 comments · May be fixed by #203

Comments

@zedrdave
Copy link

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:

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?

@ghost ghost mentioned this issue Dec 20, 2020
@ghost ghost linked a pull request Jan 13, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant