Skip to content
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

Indirection when specifying column type leads to missing __init__ parameter #203

Open
aberres opened this issue Feb 9, 2022 · 0 comments
Labels
bug Something isn't working mypy plugin something that has to do with the sqlalchemy mypy plugin

Comments

@aberres
Copy link

aberres commented Feb 9, 2022

Describe the bug

When a column type is not directly using an SA column class but instead an indirection is in place, the column is not added to __init__ and mypy complains about an invalid argument.

Maybe (or maybe not) related to #141.

Expected behavior

No error.

To Reproduce

from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, String

Base = declarative_base()

class DummyTable(Base):
    id = Column(String, primary_key=True)

# This causes the problem
# I stumbled upon this in my code with an ENUM(...) beeing used in multiple places
MyString = String

class DummyTable2(Base):
    id = Column(MyString, primary_key=True)


DummyTable(id="wer")
# error: Unexpected keyword argument "id" for "DummyTable2"  [call-arg]
DummyTable2(id="wer")

Error

foo.py:16: error: Unexpected keyword argument "id" for "DummyTable2"  [call-arg]
    DummyTable2(id="wer")
    ^
Found 1 error in 1 file (checked 1 source file)

Versions.

mypy==0.931
SQLAlchemy==1.4.31
sqlalchemy2-stubs==0.0.2a19

@aberres aberres added the requires triage New issue that requires categorization label Feb 9, 2022
@zzzeek zzzeek added bug Something isn't working mypy plugin something that has to do with the sqlalchemy mypy plugin and removed requires triage New issue that requires categorization labels Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mypy plugin something that has to do with the sqlalchemy mypy plugin
Projects
None yet
Development

No branches or pull requests

2 participants