Registry
hya.registry ¶
Implement the resolver registry to easily register resolvers.
hya.registry.ResolverRegistry ¶
Implement a resolver registry.
Example usage:
>>> from hya.registry import ResolverRegistry
>>> registry = ResolverRegistry()
>>> @registry.register("my_key")
... def my_resolver(value):
... pass
...
hya.registry.ResolverRegistry.state
property
¶
state: dict[str, Callable]
The state of the registry.
hya.registry.ResolverRegistry.register ¶
register(key: str, exist_ok: bool = False) -> Callable
Register a resolver to registry with key
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
Specifies the key used to register the resolver. |
required |
exist_ok
|
bool
|
If |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
if the resolver is not callable |
TypeError
|
if the key already exists and |
Example usage:
>>> from hya.registry import registry
>>> @registry.register("my_key")
... def my_resolver(value):
... pass
...
hya.registry.register_resolvers ¶
register_resolvers() -> None
Register the resolvers.
Example usage:
>>> from hya import register_resolvers
>>> register_resolvers()