demessaging.config.registry module

API registry class for demessaging.

Classes:

ApiRegistry(*[, imports, objects])

A registry for imports and encoders

class demessaging.config.registry.ApiRegistry(*, imports: Dict[str, str] = None, objects: List[str] = None)[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_computed_fields

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config

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

model_fields

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

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

model_fields: ClassVar[dict[str, FieldInfo]] = {'imports': FieldInfo(annotation=Dict[str, str], required=False, default_factory=dict, description='Modules to import at the top of every file. The first item is the module, the second is the alias'), 'objects': FieldInfo(annotation=List[str], required=False, default_factory=list, description='Source code for objects that should be inlined in the generated Python API.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

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.