Skip to content

Doesn't find columns on parent abstract classes #93

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

Closed
bochecha opened this issue Jul 25, 2019 · 1 comment
Closed

Doesn't find columns on parent abstract classes #93

bochecha opened this issue Jul 25, 2019 · 1 comment

Comments

@bochecha
Copy link

bochecha commented Jul 25, 2019

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

@bochecha
Copy link
Author

Ah, it seems this is fixed in master by #80 .

Apologies for the noise, I should have tested with master before reporting.

Now I'm eagerly waiting for 0.3. 🙂

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

No branches or pull requests

1 participant