katana_public_api_client.models_pydantic._registry¶
katana_public_api_client.models_pydantic._registry
¶
Registry for mapping between attrs and Pydantic model classes.
This module provides a registry that maps attrs model classes to their corresponding Pydantic model classes and vice versa. This is essential for the bi-directional conversion functionality in _base.py.
The registry is populated automatically when models are generated, via the _auto_registry.py module.
Classes¶
Functions¶
clear_registry()
¶
Clear all registrations. Mainly for testing purposes.
get_attrs_class(pydantic_class)
¶
Get the attrs class for a given Pydantic class.
Parameters:
-
pydantic_class(type[KatanaPydanticBase]) –A Pydantic model class.
Returns:
-
type | None–The corresponding attrs model class, or None if not registered.
Source code in katana_public_api_client/models_pydantic/_registry.py
get_attrs_class_by_name(name)
¶
get_pydantic_class(attrs_class)
¶
Get the Pydantic class for a given attrs class.
Parameters:
-
attrs_class(type) –An attrs model class.
Returns:
-
type[KatanaPydanticBase] | None–The corresponding Pydantic model class, or None if not registered.
Source code in katana_public_api_client/models_pydantic/_registry.py
get_pydantic_class_by_name(name)
¶
Get a Pydantic class by its name.
Parameters:
-
name(str) –The class name to look up.
Returns:
-
type[KatanaPydanticBase] | None–The Pydantic model class, or None if not found.
Source code in katana_public_api_client/models_pydantic/_registry.py
get_registration_stats()
¶
Get statistics about the current registry state.
Returns:
Source code in katana_public_api_client/models_pydantic/_registry.py
is_registered(model_class)
¶
Check if a model class is registered (either attrs or pydantic).
Parameters:
-
model_class(type) –A model class to check.
Returns:
-
bool–True if the class is registered in either direction.
Source code in katana_public_api_client/models_pydantic/_registry.py
list_registered_models()
¶
List all registered model pairs.
Returns:
Source code in katana_public_api_client/models_pydantic/_registry.py
register(attrs_class, pydantic_class)
¶
Register a mapping between an attrs class and a Pydantic class.
This function should be called for each model pair after generation. It enables the from_attrs() and to_attrs() conversion methods to work.
Parameters:
-
attrs_class(type) –The attrs model class (from models/).
-
pydantic_class(type[KatanaPydanticBase]) –The corresponding Pydantic model class.
Raises:
-
TypeError–If attrs_class is not an attrs class or pydantic_class is not a subclass of KatanaPydanticBase.
-
ValueError–If the classes are already registered with different mappings.