diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-18 15:26:05 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-18 16:13:10 -0400 |
| commit | ea844985d08ec6de49e82bb6a5878765bbeeb17b (patch) | |
| tree | f03a52681ef6098a1722ceb97e974cc19a2059fe /test | |
| parent | 3fec5028e695ad138aa46a0ae66c55e8bcb653f6 (diff) | |
| download | sqlalchemy-ea844985d08ec6de49e82bb6a5878765bbeeb17b.tar.gz | |
check for MemberExpr looking for column argument
Fixed issue in MyPy extension which crashed on detecting the type of a
:class:`.Column` if the type were given with a module prefix like
``sa.Integer()``.
Fixes: sqlalchemy/sqlalchemy2-stubs/#2
Change-Id: I71f53a6ced501ae144e28ce255cf3f50ea2b2e84
Diffstat (limited to 'test')
| -rw-r--r-- | test/ext/mypy/files/sa_module_prefix.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ext/mypy/files/sa_module_prefix.py b/test/ext/mypy/files/sa_module_prefix.py new file mode 100644 index 000000000..a37ae6b06 --- /dev/null +++ b/test/ext/mypy/files/sa_module_prefix.py @@ -0,0 +1,33 @@ +from typing import List +from typing import Optional + +import sqlalchemy as sa +from sqlalchemy import orm as saorm + + +Base = saorm.declarative_base() + + +class B(Base): + __tablename__ = "b" + id = sa.Column(sa.Integer, primary_key=True) + a_id: int = sa.Column(sa.ForeignKey("a.id")) + data = sa.Column(sa.String) + + a: Optional["A"] = saorm.relationship("A", back_populates="bs") + + +class A(Base): + __tablename__ = "a" + + id = sa.Column(sa.Integer, primary_key=True) + data = sa.Column(sa.String) + bs = saorm.relationship(B, uselist=True, back_populates="a") + + +a1 = A(bs=[B(data="b"), B(data="b")]) + +x: List[B] = a1.bs + + +b1 = B(a=A()) |
