Skip to content

Commit 1541d93

Browse files
authored
chore: remove deprecated deserialize tools inplace function (#9379)
* rm deserialize_tools_inplace + clean up * release note
1 parent 9f2c067 commit 1541d93

File tree

4 files changed

+11
-34
lines changed

4 files changed

+11
-34
lines changed

haystack/tools/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# ruff: noqa: I001 (ignore import order as we need to import Tool before ComponentTool)
88
from .from_function import create_tool_from_function, tool
9-
from .tool import Tool, _check_duplicate_tool_names, deserialize_tools_inplace
9+
from .tool import Tool, _check_duplicate_tool_names
1010
from .component_tool import ComponentTool
1111
from .serde_utils import deserialize_tools_or_toolset_inplace, serialize_tools_or_toolset
1212
from .toolset import Toolset
@@ -15,7 +15,6 @@
1515
"_check_duplicate_tool_names",
1616
"ComponentTool",
1717
"create_tool_from_function",
18-
"deserialize_tools_inplace",
1918
"deserialize_tools_or_toolset_inplace",
2019
"serialize_tools_or_toolset",
2120
"Tool",

haystack/tools/serde_utils.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,23 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
from typing import TYPE_CHECKING, Any, Dict, List, Union
5+
from typing import Any, Dict, List, Union
66

77
from haystack.core.errors import DeserializationError
88
from haystack.core.serialization import import_class_by_name
9-
10-
if TYPE_CHECKING:
11-
from haystack.tools.tool import Tool
12-
from haystack.tools.toolset import Toolset
9+
from haystack.tools.tool import Tool
10+
from haystack.tools.toolset import Toolset
1311

1412

1513
def serialize_tools_or_toolset(
16-
tools: Union["Toolset", List["Tool"], None],
14+
tools: Union[Toolset, List[Tool], None],
1715
) -> Union[Dict[str, Any], List[Dict[str, Any]], None]:
1816
"""
1917
Serialize a Toolset or a list of Tools to a dictionary or a list of tool dictionaries.
2018
2119
:param tools: A Toolset, a list of Tools, or None
2220
:returns: A dictionary, a list of tool dictionaries, or None if tools is None
2321
"""
24-
from haystack.tools.toolset import Toolset
25-
2622
if tools is None:
2723
return None
2824
if isinstance(tools, Toolset):
@@ -39,9 +35,6 @@ def deserialize_tools_or_toolset_inplace(data: Dict[str, Any], key: str = "tools
3935
:param key:
4036
The key in the dictionary where the list of Tools or Toolset is stored.
4137
"""
42-
from haystack.tools.tool import Tool
43-
from haystack.tools.toolset import Toolset
44-
4538
if key in data:
4639
serialized_tools = data[key]
4740

haystack/tools/tool.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
import warnings
65
from dataclasses import asdict, dataclass
76
from typing import Any, Callable, Dict, List, Optional
87

@@ -11,7 +10,6 @@
1110

1211
from haystack.core.serialization import generate_qualified_class_name
1312
from haystack.tools.errors import ToolInvocationError
14-
from haystack.tools.serde_utils import deserialize_tools_or_toolset_inplace
1513
from haystack.utils import deserialize_callable, serialize_callable
1614

1715

@@ -175,22 +173,3 @@ def _check_duplicate_tool_names(tools: Optional[List[Tool]]) -> None:
175173
duplicate_tool_names = {name for name in tool_names if tool_names.count(name) > 1}
176174
if duplicate_tool_names:
177175
raise ValueError(f"Duplicate tool names found: {duplicate_tool_names}")
178-
179-
180-
def deserialize_tools_inplace(data: Dict[str, Any], key: str = "tools"):
181-
"""
182-
Deserialize a list of Tools or a Toolset in a dictionary inplace.
183-
184-
Deprecated in favor of `deserialize_tools_or_toolset_inplace`. It will be removed in Haystack 2.14.0.
185-
186-
:param data:
187-
The dictionary with the serialized data.
188-
:param key:
189-
The key in the dictionary where the list of Tools or Toolset is stored.
190-
"""
191-
warnings.warn(
192-
"`deserialize_tools_inplace` is deprecated and will be removed in Haystack 2.14.0. "
193-
"Use `deserialize_tools_or_toolset_inplace` instead.",
194-
DeprecationWarning,
195-
)
196-
deserialize_tools_or_toolset_inplace(data, key)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
upgrade:
3+
- |
4+
The deprecated `deserialize_tools_inplace` utility function has been removed.
5+
Use `deserialize_tools_or_toolset_inplace` instead, importing it as follows:
6+
`from haystack.tools import deserialize_tools_or_toolset_inplace`.

0 commit comments

Comments
 (0)