Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyagentspec/src/pyagentspec/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,11 @@ def build_from_partial_config(
partial_component, validation_errors = deserializer.from_partial_dict(partial_config)
# Deserialization ignores min and max agentspec versions (besides validation), so we set them manually
if "min_agentspec_version" in partial_config:
partial_component.min_agentspec_version = AgentSpecVersionEnum( # type: ignore
partial_component.min_agentspec_version = AgentSpecVersionEnum(
partial_config["min_agentspec_version"]
)
if "max_agentspec_version" in partial_config:
partial_component.max_agentspec_version = AgentSpecVersionEnum( # type: ignore
partial_component.max_agentspec_version = AgentSpecVersionEnum(
partial_config["max_agentspec_version"]
)
return cast(ComponentT, partial_component)
Expand Down
79 changes: 70 additions & 9 deletions pyagentspec/src/pyagentspec/serialization/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def from_dict(self, dict_content: ComponentAsDictT) -> Component: ...
def from_dict(
self,
dict_content: ComponentAsDictT,
components_registry: Optional[ComponentsRegistryT],
components_registry: ComponentsRegistryT | None,
) -> Component: ...

@overload
Expand All @@ -270,46 +270,46 @@ def from_dict(
dict_content: ComponentAsDictT,
*,
import_only_referenced_components: Literal[True],
) -> Dict[str, Component]: ...
) -> dict[str, Component]: ...

@overload
def from_dict(
self,
dict_content: ComponentAsDictT,
*,
import_only_referenced_components: bool,
) -> Union[Component, Dict[str, Component]]: ...
) -> Component | dict[str, Component]: ...

@overload
def from_dict(
self,
dict_content: ComponentAsDictT,
components_registry: Optional[ComponentsRegistryT],
components_registry: ComponentsRegistryT | None,
import_only_referenced_components: Literal[False],
) -> Component: ...

@overload
def from_dict(
self,
dict_content: ComponentAsDictT,
components_registry: Optional[ComponentsRegistryT],
components_registry: ComponentsRegistryT | None,
import_only_referenced_components: Literal[True],
) -> Dict[str, Component]: ...
) -> dict[str, Component]: ...

@overload
def from_dict(
self,
dict_content: ComponentAsDictT,
components_registry: Optional[ComponentsRegistryT],
import_only_referenced_components: bool,
) -> Union[Component, Dict[str, Component]]: ...
) -> Component | dict[str, Component]: ...

def from_dict(
self,
dict_content: ComponentAsDictT,
components_registry: Optional[ComponentsRegistryT] = None,
components_registry: ComponentsRegistryT | None = None,
import_only_referenced_components: bool = False,
) -> Union[Component, Dict[str, Component]]:
) -> Component | dict[str, Component]:
"""
Load a component and its sub-components from dictionary.

Expand Down Expand Up @@ -422,6 +422,67 @@ def from_dict(

return referenced_components

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
) -> tuple[Component, list[PyAgentSpecErrorDetails]]: ...

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
components_registry: ComponentsRegistryT | None,
) -> tuple[Component, list[PyAgentSpecErrorDetails]]: ...

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
*,
import_only_referenced_components: Literal[False],
) -> tuple[Component, list[PyAgentSpecErrorDetails]]: ...

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
*,
import_only_referenced_components: Literal[True],
) -> tuple[dict[str, Component], list[PyAgentSpecErrorDetails]]: ...

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
*,
import_only_referenced_components: bool,
) -> tuple[Component | dict[str, Component], list[PyAgentSpecErrorDetails]]: ...

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
components_registry: ComponentsRegistryT | None,
import_only_referenced_components: Literal[False],
) -> tuple[Component, list[PyAgentSpecErrorDetails]]: ...

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
components_registry: ComponentsRegistryT | None,
import_only_referenced_components: Literal[True],
) -> tuple[dict[str, Component], list[PyAgentSpecErrorDetails]]: ...

@overload
def from_partial_dict(
self,
dict_content: ComponentAsDictT,
components_registry: ComponentsRegistryT | None,
import_only_referenced_components: bool,
) -> tuple[Component | dict[str, Component], list[PyAgentSpecErrorDetails]]: ...

def from_partial_dict(
self,
dict_content: ComponentAsDictT,
Expand Down