diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-08-25 13:12:55 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-08-25 13:15:33 -0400 |
| commit | 07b7e1594deecc6c9c64893a63f56403da0dcf05 (patch) | |
| tree | ce5eb76781d7d2cdb286a754eb15f07557ae13e5 /test | |
| parent | 00fe746366d910d9328543a194afb52a115a1837 (diff) | |
| download | sqlalchemy-07b7e1594deecc6c9c64893a63f56403da0dcf05.tar.gz | |
ensure "sqlalchemy" info set for all considered classes
Fixed issue in mypy plugin where columns on a mixin would not be correctly
interpreted if the mapped class relied upon a ``__tablename__`` routine
that came from a superclass.
Fixes: #6937
Change-Id: I74aed4862d0545008ee67f781aaa794ab6866926
Diffstat (limited to 'test')
| -rw-r--r-- | test/ext/mypy/files/mixin_w_tablename.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ext/mypy/files/mixin_w_tablename.py b/test/ext/mypy/files/mixin_w_tablename.py new file mode 100644 index 000000000..cfbe83d35 --- /dev/null +++ b/test/ext/mypy/files/mixin_w_tablename.py @@ -0,0 +1,27 @@ +# test #6937 +from sqlalchemy import Column +from sqlalchemy import Integer +from sqlalchemy.orm import declarative_base +from sqlalchemy.orm import declared_attr +from sqlalchemy.orm import Mapped + + +Base = declarative_base() + + +class UpdatedCls: + @declared_attr + def __tablename__(cls) -> Mapped[str]: + return cls.__name__.lower() + + updated_at = Column(Integer) + + +class Bar(UpdatedCls, Base): + id = Column(Integer(), primary_key=True) + num = Column(Integer) + + +Bar.updated_at.in_([1, 2, 3]) + +b1 = Bar(num=5, updated_at=6) |
