MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / RootRegistry

Class RootRegistry

lib/sqlalchemy/orm/path_registry.py:370–405  ·  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

368
369
370class RootRegistry(_CreatesToken):
371 """Root registry, defers to mappers so that
372 paths are maintained per-root-mapper.
373
374 """
375
376 __slots__ = ()
377
378 inherit_cache = True
379
380 path = natural_path = ()
381 has_entity = False
382 is_aliased_class = False
383 is_root = True
384 is_unnatural = False
385
386 def _getitem(
387 self, entity: Any
388 ) -> Union[_TokenRegistry, _AbstractEntityRegistry]:
389 if entity in PathToken._intern:
390 if TYPE_CHECKING:
391 assert isinstance(entity, _StrPathToken)
392 return _TokenRegistry(self, PathToken._intern[entity])
393 else:
394 try:
395 return entity._path_registry # type: ignore
396 except AttributeError:
397 raise IndexError(
398 f"invalid argument for RootRegistry.__getitem__: {entity}"
399 )
400
401 def _truncate_recursive(self) -> RootRegistry:
402 return self
403
404 if not TYPE_CHECKING:
405 __getitem__ = _getitem
406
407
408PathRegistry.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