sqlalchemy / sqlalchemy2-stubs

PEP-484 typing stubs for SQLAlchemy 1.4
MIT License
159 stars 41 forks source link

"method" of "AppenderQuery" does not return a value #224

Closed CrafterSvK closed 2 years ago

CrafterSvK commented 2 years ago

Describe the bug When using static typing on relationship which is lazy='dynamic' I used "AppenderQuery", which is the one which SQLAlchemy gave me at runtime. I type ignored it as Mapped does not support it clearly. After I use where/order_by mypy says: error: "where" of "AppenderQuery" does not return a value. Which is clearly not true, typing says it returns None, but at runtime it returns something.

Expected behavior Typing should reflect reality.

To Reproduce

class Page(Base):
    user_pages: AppenderQuery = relationship('UserPage', back_populates='page', lazy='dynamic')  # type: ignore

Error

error: "where" of "AppenderQuery" does not return a value

Versions.

Additional context Still trying to figure out real ways how to type, already existing code.

Thanks and have a nice day!