haive.core.schema.compatibility.convertersΒΆ
Type conversion system for schema compatibility.
ClassesΒΆ
Registry for type converters. |
|
Abstract base class for type converters. |
FunctionsΒΆ
Get the global converter registry. |
|
|
Register a converter in the global registry. |
Module ContentsΒΆ
- class haive.core.schema.compatibility.converters.ConverterRegistry[source]ΒΆ
Registry for type converters.
Init .
- convert(value, source_type, target_type)[source]ΒΆ
Convert a value using the best available converter.
- get_converter(source_type, target_type)[source]ΒΆ
Get the best converter for a type pair.
- Parameters:
- Return type:
TypeConverter | None
- register(converter)[source]ΒΆ
Register a type converter.
- Parameters:
converter (TypeConverter)
- Return type:
None
- class haive.core.schema.compatibility.converters.TypeConverter[source]ΒΆ
Bases:
abc.ABC
Abstract base class for type converters.
- abstractmethod can_convert(source_type, target_type)[source]ΒΆ
Check if this converter can handle the conversion.
- abstractmethod convert(value, context)[source]ΒΆ
Convert a value from source to target type.
- Parameters:
value (Any)
context (haive.core.schema.compatibility.types.ConversionContext)
- Return type:
Any
- haive.core.schema.compatibility.converters.get_converter_registry()[source]ΒΆ
Get the global converter registry.
- Return type:
- haive.core.schema.compatibility.converters.register_converter(converter)[source]ΒΆ
Register a converter in the global registry.
- Parameters:
converter (TypeConverter)
- Return type:
None