haive.core.graph.common.referencesΒΆ
Reference classes for serializing callables and types.
ClassesΒΆ
Serializable reference to a callable. |
|
Reference to a type that can be serialized. |
Module ContentsΒΆ
- class haive.core.graph.common.references.CallableReference(/, **data)[source]ΒΆ
Bases:
pydantic.BaseModel
Serializable reference to a callable.
This class can store and resolve references to: - Module-level functions - Lambda functions - Methods - Partial functions - Directly passed callables
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- classmethod from_callable(callable_obj)[source]ΒΆ
Create reference from a callable.
- Parameters:
callable_obj (collections.abc.Callable)
- Return type:
Optional[CallableReference]
- resolve()[source]ΒΆ
Resolve reference to a callable.
Priority: 1. Direct function reference if available 2. Module/name resolution for regular functions 3. Source code evaluation for lambdas 4. Partial function reconstruction
- Return type:
collections.abc.Callable | None
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.core.graph.common.references.TypeReference(/, **data)[source]ΒΆ
Bases:
pydantic.BaseModel
Reference to a type that can be serialized.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- classmethod from_type(type_obj)[source]ΒΆ
Create a TypeReference from a type object.
- Parameters:
type_obj (type | None)
- Return type:
Optional[TypeReference]
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].