Skip to content

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

Open
@aberres

Description

@aberres

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmypy pluginsomething that has to do with the sqlalchemy mypy plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions