hyped.core.registry.registry module¶
Type Register.
- class hyped.core.registry.registry.RegisterMeta(name, bases, attrs, **kwargs)[source]¶
Bases:
objectregister type metaclass mixin.
- property type_registry: RootedTypeRegistryView¶
Type Registry rooted at the current type.
- class hyped.core.registry.registry.RegisterTypeMeta(name, bases, attrs, **kwargs)[source]¶
Bases:
RegisterMeta,ABCMetaRegister type meta.
meta-class to automatically register sub-types of a specific type in a type registry.
- class hyped.core.registry.registry.RegisterTypeMixin[source]¶
Bases:
RegistrableRegister Types.
Base class that automatically registers sub-types to the default type registry.
- class hyped.core.registry.registry.Registrable[source]¶
Bases:
ABCBase Class for Registrable Types.
- class property type_hash: str¶
Get type hash.
The computed hash-code is based on the source code of the type and not runtime specific. This allows for type resolving by hash accross python runtimes.
When the source code of the class is not available, the hash of the class module and name is computed instead. This is the case for pre-compiled classes or classes defined in jupyter notebooks.
- Returns:
hash code of type
- Return type:
h (str)
- class hyped.core.registry.registry.RootedTypeRegistryView(root: type, registry: TypeRegistry)[source]¶
Bases:
objectRooted Type Registry View.
Only has access to registered types that inherit the specified root.
- property hash_register: dict[str, str]¶
Hash Register.
Immutable hash register mapping type id to the corresponding type hash.
- class hyped.core.registry.registry.TypeRegistry[source]¶
Bases:
objectType Registry.
Stores registrable types and holds functionality to get all registered sub-types of a given root type.
Registrable types must inherit from the Registrable type.
- get_hash_register(root: type) dict[str, str][source]¶
Get the hash register for sub-types of a given root type.
- Parameters:
root (type) – root type
- Returns:
the hash register mapping type identifiers to type hashes for types that inherit the root type
- Return type:
hash_register (dict[str, str])
- get_type_register(root: type) dict[str, type][source]¶
Get the type register for sub-types of a given root type.
- Parameters:
root (type) – root type
- Returns:
the type register mapping type hashes to types for types that inherit the root type
- Return type:
type_register (dict[str, type])
- hyped.core.registry.registry.default_registry = <hyped.core.registry.registry.TypeRegistry object>¶
Default type registry tracking all registrable types