(
self, with_polymorphic: Optional[_WithPolymorphicArg]
)
| 1388 | ) |
| 1389 | |
| 1390 | def _set_with_polymorphic( |
| 1391 | self, with_polymorphic: Optional[_WithPolymorphicArg] |
| 1392 | ) -> None: |
| 1393 | if with_polymorphic == "*": |
| 1394 | self.with_polymorphic = ("*", None) |
| 1395 | elif isinstance(with_polymorphic, (tuple, list)): |
| 1396 | if isinstance(with_polymorphic[0], (str, tuple, list)): |
| 1397 | self.with_polymorphic = cast( |
| 1398 | """Tuple[ |
| 1399 | Union[ |
| 1400 | Literal["*"], |
| 1401 | Sequence[Union["Mapper[Any]", Type[Any]]], |
| 1402 | ], |
| 1403 | Optional["FromClause"], |
| 1404 | ]""", |
| 1405 | with_polymorphic, |
| 1406 | ) |
| 1407 | else: |
| 1408 | self.with_polymorphic = (with_polymorphic, None) |
| 1409 | elif with_polymorphic is not None: |
| 1410 | raise sa_exc.ArgumentError( |
| 1411 | f"Invalid setting for with_polymorphic: {with_polymorphic!r}" |
| 1412 | ) |
| 1413 | else: |
| 1414 | self.with_polymorphic = None |
| 1415 | |
| 1416 | if self.with_polymorphic and self.with_polymorphic[1] is not None: |
| 1417 | self.with_polymorphic = ( |
| 1418 | self.with_polymorphic[0], |
| 1419 | coercions.expect( |
| 1420 | roles.StrictFromClauseRole, |
| 1421 | self.with_polymorphic[1], |
| 1422 | allow_select=True, |
| 1423 | ), |
| 1424 | ) |
| 1425 | |
| 1426 | if self.configured: |
| 1427 | self._expire_memoizations() |
| 1428 | |
| 1429 | def _add_with_polymorphic_subclass(self, mapper): |
| 1430 | subcl = mapper.class_ |
no test coverage detected