From: Mike Bayer Date: Wed, 26 Jun 2024 16:13:28 +0000 (-0400) Subject: add additional test cases re: #11371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b631dff45bbf4539c78eb73529b960acda80efd;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git add additional test cases re: #11371 Just want to make sure aliased() and with_polymorphic() still work in the of_type() context here, since that's likely why we had Any for this parameter in the first place Change-Id: I0a2c4445bc3b91039b3446d31b4a02db28feaee7 --- diff --git a/test/typing/plain_files/orm/relationship.py b/test/typing/plain_files/orm/relationship.py index 683e347f19..44090ad53b 100644 --- a/test/typing/plain_files/orm/relationship.py +++ b/test/typing/plain_files/orm/relationship.py @@ -16,6 +16,7 @@ from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy import select from sqlalchemy import Table +from sqlalchemy.orm import aliased from sqlalchemy.orm import DeclarativeBase from sqlalchemy.orm import joinedload from sqlalchemy.orm import Mapped @@ -24,6 +25,7 @@ from sqlalchemy.orm import registry from sqlalchemy.orm import Relationship from sqlalchemy.orm import relationship from sqlalchemy.orm import Session +from sqlalchemy.orm import with_polymorphic class Base(DeclarativeBase): @@ -164,6 +166,15 @@ if typing.TYPE_CHECKING: # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Engineer\] reveal_type(Team.employees.of_type(Engineer)) + # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Employee\] + reveal_type(Team.employees.of_type(aliased(Employee))) + + # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Engineer\] + reveal_type(Team.employees.of_type(aliased(Engineer))) + + # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Employee\] + reveal_type(Team.employees.of_type(with_polymorphic(Employee, [Engineer]))) + mapper_registry: registry = registry()