| 432 | |
| 433 | |
| 434 | class _TokenRegistry(PathRegistry): |
| 435 | __slots__ = ("token", "parent", "path", "natural_path") |
| 436 | |
| 437 | inherit_cache = True |
| 438 | |
| 439 | token: _StrPathToken |
| 440 | parent: _CreatesToken |
| 441 | |
| 442 | def __init__(self, parent: _CreatesToken, token: _StrPathToken): |
| 443 | token = PathToken.intern(token) |
| 444 | |
| 445 | self.token = token |
| 446 | self.parent = parent |
| 447 | self.path = parent.path + (token,) |
| 448 | self.natural_path = parent.natural_path + (token,) |
| 449 | |
| 450 | has_entity = False |
| 451 | |
| 452 | is_token = True |
| 453 | |
| 454 | def generate_for_superclasses(self) -> Iterator[PathRegistry]: |
| 455 | # NOTE: this method is no longer used. consider removal |
| 456 | parent = self.parent |
| 457 | if is_root(parent): |
| 458 | yield self |
| 459 | return |
| 460 | |
| 461 | if TYPE_CHECKING: |
| 462 | assert isinstance(parent, _AbstractEntityRegistry) |
| 463 | if not parent.is_aliased_class: |
| 464 | for mp_ent in parent.mapper.iterate_to_root(): |
| 465 | yield _TokenRegistry(parent.parent[mp_ent], self.token) |
| 466 | elif ( |
| 467 | parent.is_aliased_class |
| 468 | and cast( |
| 469 | "AliasedInsp[Any]", |
| 470 | parent.entity, |
| 471 | )._is_with_polymorphic |
| 472 | ): |
| 473 | yield self |
| 474 | for ent in cast( |
| 475 | "AliasedInsp[Any]", parent.entity |
| 476 | )._with_polymorphic_entities: |
| 477 | yield _TokenRegistry(parent.parent[ent], self.token) |
| 478 | else: |
| 479 | yield self |
| 480 | |
| 481 | def _generate_natural_for_superclasses( |
| 482 | self, |
| 483 | ) -> Iterator[_PathRepresentation]: |
| 484 | parent = self.parent |
| 485 | if is_root(parent): |
| 486 | yield self.natural_path |
| 487 | return |
| 488 | |
| 489 | if TYPE_CHECKING: |
| 490 | assert isinstance(parent, _AbstractEntityRegistry) |
| 491 | for mp_ent in parent.mapper.iterate_to_root(): |
no outgoing calls
no test coverage detected