MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / RootRegistry

Class RootRegistry

lib/sqlalchemy/orm/path_registry.py:404–439  ·  view source on GitHub ↗

Root registry, defers to mappers so that paths are maintained per-root-mapper.

Source from the content-addressed store, hash-verified

402
403
404class RootRegistry(CreatesToken):
405 """Root registry, defers to mappers so that
406 paths are maintained per-root-mapper.
407
408 """
409
410 __slots__ = ()
411
412 inherit_cache = True
413
414 path = natural_path = ()
415 has_entity = False
416 is_aliased_class = False
417 is_root = True
418 is_unnatural = False
419
420 def _getitem(
421 self, entity: Any
422 ) -> Union[TokenRegistry, AbstractEntityRegistry]:
423 if entity in PathToken._intern:
424 if TYPE_CHECKING:
425 assert isinstance(entity, _StrPathToken)
426 return TokenRegistry(self, PathToken._intern[entity])
427 else:
428 try:
429 return entity._path_registry # type: ignore
430 except AttributeError:
431 raise IndexError(
432 f"invalid argument for RootRegistry.__getitem__: {entity}"
433 )
434
435 def _truncate_recursive(self) -> RootRegistry:
436 return self
437
438 if not TYPE_CHECKING:
439 __getitem__ = _getitem
440
441
442PathRegistry.root = RootRegistry()

Callers 2

test_root_registryMethod · 0.90
path_registry.pyFile · 0.85

Calls

no outgoing calls

Tested by 1

test_root_registryMethod · 0.72