haive.core.schema.compatibility.convertersΒΆ

Type conversion system for schema compatibility.

ClassesΒΆ

ConverterRegistry

Registry for type converters.

TypeConverter

Abstract base class for type converters.

FunctionsΒΆ

get_converter_registry()

Get the global converter registry.

register_converter(converter)

Register a converter in the global registry.

Module ContentsΒΆ

class haive.core.schema.compatibility.converters.ConverterRegistry[source]ΒΆ

Registry for type converters.

Init .

can_convert(source_type, target_type)[source]ΒΆ

Check if conversion is possible.

Parameters:
  • source_type (type[Any])

  • target_type (type[Any])

Return type:

bool

convert(value, source_type, target_type)[source]ΒΆ

Convert a value using the best available converter.

Parameters:
  • value (Any)

  • source_type (type[Any])

  • target_type (type[Any])

Return type:

Any

get_converter(source_type, target_type)[source]ΒΆ

Get the best converter for a type pair.

Parameters:
  • source_type (type[Any])

  • target_type (type[Any])

Return type:

TypeConverter | None

list_converters()[source]ΒΆ

List all registered converter names.

Return type:

list[str]

register(converter)[source]ΒΆ

Register a type converter.

Parameters:

converter (TypeConverter)

Return type:

None

unregister(name)[source]ΒΆ

Unregister a type converter.

Parameters:

name (str)

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.

Parameters:
  • source_type (type[Any])

  • target_type (type[Any])

Return type:

bool

abstractmethod convert(value, context)[source]ΒΆ

Convert a value from source to target type.

Parameters:
Return type:

Any

estimate_quality(source_type, target_type)[source]ΒΆ

Estimate the quality of conversion.

Parameters:
  • source_type (type[Any])

  • target_type (type[Any])

Return type:

haive.core.schema.compatibility.types.ConversionQuality

property name: strΒΆ
Abstractmethod:

Return type:

str

Unique name for this converter.

property priority: intΒΆ

Priority for converter selection (higher = preferred).

Return type:

int

haive.core.schema.compatibility.converters.get_converter_registry()[source]ΒΆ

Get the global converter registry.

Return type:

ConverterRegistry

haive.core.schema.compatibility.converters.register_converter(converter)[source]ΒΆ

Register a converter in the global registry.

Parameters:

converter (TypeConverter)

Return type:

None