Skip to content

Doesn't find columns on parent abstract classes #93

@bochecha

Description

@bochecha

SQLAlchemy allows defining models as follows:

from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class BaseModel(Base):
    __abstract__ = True

    id = Column(Integer, primary_key=True)
    name =  Column(String(50))

class MyModel(BaseModel):
    __tablename__ = 'my-model'

    whatever = Column(String)

Then you can create new instances as expected:

MyModel(name='the name', whatever='something here')

When doing that, Mypy reports:

error: Unexpected column "name" for model "MyModel"

It appears the stubs in this project don't let Mypy follow model inheritance?

This is with sqlalchemy-stubs==0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions