Skip to content

Commit

Permalink
Remove is_greedy deprecated argument from @component decorator (#…
Browse files Browse the repository at this point in the history
…8580)

* Remove 'is_greedy' deprecated argument from @component decorator

* Remove unused import
  • Loading branch information
mpangrazzi authored Nov 26, 2024
1 parent 59f1e18 commit f0c3692
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
16 changes: 3 additions & 13 deletions haystack/core/component/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@

import inspect
import sys
import warnings
from collections.abc import Callable
from contextlib import contextmanager
from contextvars import ContextVar
Expand Down Expand Up @@ -487,21 +486,12 @@ class available here, we temporarily store the output types as an attribute of

return output_types_decorator

def _component(self, cls, is_greedy: Optional[bool] = None):
def _component(self, cls: Any):
"""
Decorator validating the structure of the component and registering it in the components registry.
"""
logger.debug("Registering {component} as a component", component=cls)

if is_greedy is not None:
msg = (
"The 'is_greedy' argument is deprecated and will be removed in version '2.7.0'. "
"Change the 'Variadic' input of your Component to 'GreedyVariadic' instead."
)
warnings.warn(msg, DeprecationWarning)
else:
is_greedy = False

# Check for required methods and fail as soon as possible
if not hasattr(cls, "run"):
raise ComponentError(f"{cls.__name__} must have a 'run()' method. See the docs for more information.")
Expand Down Expand Up @@ -543,11 +533,11 @@ def copy_class_namespace(namespace):

return cls

def __call__(self, cls: Optional[type] = None, is_greedy: Optional[bool] = None):
def __call__(self, cls: Optional[type] = None):
# We must wrap the call to the decorator in a function for it to work
# correctly with or without parens
def wrap(cls):
return self._component(cls, is_greedy=is_greedy)
return self._component(cls)

if cls:
# Decorator is called without parens
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
Remove 'is_greedy' deprecated argument from `@component` decorator. Change the 'Variadic' input of your Component to 'GreedyVariadic' instead.

0 comments on commit f0c3692

Please sign in to comment.