summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2023-03-17 08:35:56 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2023-03-17 08:43:22 -0400
commitf898d55be0e6c1ef0ce3105d563d599afe7556bc (patch)
tree0e7b47e36f9651a2f3fa3dfd86d9a3ca7a4ac562 /test
parentd9539e3990acf19ee1a03690d4a7441d26a7fbfd (diff)
downloadsqlalchemy-f898d55be0e6c1ef0ce3105d563d599afe7556bc.tar.gz
add explicit overload for composite -> callable
Fixed typing issue where :func:`_orm.composite` would not allow an arbitrary callable as the source of the composite class. Fixes: #9502 Change-Id: I5b098b70b2fb7b48f54eaccbb7d5d3d9bdebc781
Diffstat (limited to 'test')
-rw-r--r--test/ext/mypy/plain_files/composite.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/ext/mypy/plain_files/composite.py b/test/ext/mypy/plain_files/composite.py
index c69963314..8ac1f504c 100644
--- a/test/ext/mypy/plain_files/composite.py
+++ b/test/ext/mypy/plain_files/composite.py
@@ -33,6 +33,10 @@ class Point:
def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)
+ @classmethod
+ def _generate(cls, x1: int, y1: int) -> "Point":
+ return Point(x1, y1)
+
class Vertex(Base):
__tablename__ = "vertices"
@@ -47,7 +51,7 @@ class Vertex(Base):
start = composite(Point, "x1", "y1")
# taken from left hand side
- end: Mapped[Point] = composite(Point, "x2", "y2")
+ end: Mapped[Point] = composite(Point._generate, "x2", "y2")
v1 = Vertex(start=Point(3, 4), end=Point(5, 6))