demessaging.config.registry module

API registry class for demessaging.

Classes:

ApiRegistry(*, imports, str] =, objects)

A registry for imports and encoders

class demessaging.config.registry.ApiRegistry(*, imports: ~typing.Dict[str, str] = <factory>, objects: ~typing.List[str] = <factory>)[source]

Bases: BaseModel

A registry for imports and encoders

Parameters:
  • imports (Dict[str, str]) – Modules to import at the top of every file. The first item is the module, the second is the alias

  • objects (List[str]) – Source code for objects that should be inlined in the generated Python API.

Methods:

can_import_import(imports)

hard_code(python_code)

Register some code to be implemented in the generated module.

register_import(module[, alias])

Register a module that needs to be imported in generated API files.

register_type(obj)

Register a class or function to be available in the generated API.

Attributes:

imports

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

objects

classmethod can_import_import(imports: Dict[str, str]) Dict[str, str][source]
hard_code(python_code: str) None[source]

Register some code to be implemented in the generated module.

Parameters:

python_code (str) – The code that is supposed to be executed on a module level.

imports: Dict[str, str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

objects: List[str]
register_import(module: str, alias: str | None = None) None[source]

Register a module that needs to be imported in generated API files.

Parameters:

module (str) – The name of the module, e.g. matplotlib.pyplot

register_type(obj: T) T[source]

Register a class or function to be available in the generated API.

Use this function if you want to have certain functions of classes available in the generated API module, but they should not be transformed to a call to the backend module.