Remove is_greedy deprecated argument from @component decorator (#8580)

* Remove 'is_greedy' deprecated argument from @component decorator

* Remove unused import
This commit is contained in:
Michele Pangrazzi 2024-11-26 11:44:50 +01:00 committed by GitHub
parent 59f1e182db
commit f0c3692cf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 13 deletions

View File

@ -71,7 +71,6 @@ method decorated with `@component.input`. This dataclass contains:
import inspect
import sys
import warnings
from collections.abc import Callable
from contextlib import contextmanager
from contextvars import ContextVar
@ -487,21 +486,12 @@ class _Component:
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.")
@ -543,11 +533,11 @@ class _Component:
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

View File

@ -0,0 +1,4 @@
---
upgrade:
- |
Remove 'is_greedy' deprecated argument from `@component` decorator. Change the 'Variadic' input of your Component to 'GreedyVariadic' instead.