• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

deepset-ai / haystack / 15486035323

06 Jun 2025 08:16AM UTC coverage: 90.42% (+0.001%) from 90.419%
15486035323

Pull #9501

github

web-flow
Merge 098861513 into f85ce19a3
Pull Request #9501: Make ComponentTool a proper dataclass

11487 of 12704 relevant lines covered (90.42%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
haystack/dataclasses/state_utils.py
1
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
2
#
3
# SPDX-License-Identifier: Apache-2.0
4

5
import warnings
×
6
from typing import Any, List, TypeVar, Union
×
7

8
T = TypeVar("T")
×
9

10

11
def merge_lists(current: Union[List[T], T, None], new: Union[List[T], T]) -> List[T]:
×
12
    """
13
    Merges two values into a single list.
14

15
    Deprecated in favor of `haystack.components.agents.state.merge_lists`. It will be removed in Haystack 2.16.0.
16

17

18
    If either `current` or `new` is not already a list, it is converted into one.
19
    The function ensures that both inputs are treated as lists and concatenates them.
20

21
    If `current` is None, it is treated as an empty list.
22

23
    :param current: The existing value(s), either a single item or a list.
24
    :param new: The new value(s) to merge, either a single item or a list.
25
    :return: A list containing elements from both `current` and `new`.
26
    """
27

28
    warnings.warn(
×
29
        "`haystack.dataclasses.state_utils.merge_lists` is deprecated and will be removed in Haystack 2.16.0. "
30
        "Use `haystack.components.agents.state.merge_lists` instead.",
31
        DeprecationWarning,
32
    )
33
    current_list = [] if current is None else current if isinstance(current, list) else [current]
×
34
    new_list = new if isinstance(new, list) else [new]
×
35
    return current_list + new_list
×
36

37

38
def replace_values(current: Any, new: Any) -> Any:
×
39
    """
40
    Replace the `current` value with the `new` value.
41

42
    :param current: The existing value
43
    :param new: The new value to replace
44
    :return: The new value
45
    """
46

47
    warnings.warn(
×
48
        "`haystack.dataclasses.state_utils.replace_values` is deprecated and will be removed in Haystack 2.16.0. "
49
        "Use `haystack.components.agents.state.replace_values` instead.",
50
        DeprecationWarning,
51
    )
52
    return new
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc