Skip to content

Commit 8298807

Browse files
authored
fix: action parameter breaking change (#46)
Signed-off-by: develop-cs <43383361+develop-cs@users.noreply.github.com>
1 parent 9756e52 commit 8298807

File tree

6 files changed

+25
-6
lines changed

6 files changed

+25
-6
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- id: check-added-large-files
2727
args: [--maxkb=500]
2828
- repo: https://github.com/astral-sh/ruff-pre-commit
29-
rev: v0.11.2
29+
rev: v0.11.4
3030
hooks:
3131
- id: ruff
3232
args: [--fix]
@@ -43,7 +43,7 @@ repos:
4343
hooks:
4444
- id: gitleaks
4545
- repo: https://github.com/pypa/pip-audit
46-
rev: v2.8.0
46+
rev: v2.9.0
4747
hooks:
4848
- id: pip-audit
4949
args: [--skip-editable]

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.10.1] - April, 2025
8+
9+
### Fixes
10+
11+
* Unintentional breaking change on the action function parameter `input_data` (now deprecated).
12+
713
## [0.10.0] - April, 2025
814

915
### Features

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "arta"
7-
version = "0.10.0"
7+
version = "0.10.1"
88
requires-python = ">3.8.0"
99
description = "A Python Rules Engine - Make rule handling simple"
1010
readme = "README.md"

src/arta/rule.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import inspect
99
import re
1010
from typing import Any, Callable
11+
from warnings import warn
1112

1213
from arta.condition import BaseCondition, StandardCondition
1314
from arta.exceptions import ConditionExecutionError, RuleExecutionError
@@ -111,6 +112,18 @@ def apply(
111112
if arg_spec.varkw is not None:
112113
parameters["input_data"] = input_data
113114

115+
# Backward compatibility case (now deprecated)
116+
if "input_data" in arg_spec.args or "input_data" in arg_spec.kwonlyargs:
117+
warn(
118+
(
119+
"Using 'input_data' directly as an action function parameter is deprecated. "
120+
"Use '**kwargs' instead. See how at https://maif.github.io/arta/value_sharing/"
121+
),
122+
DeprecationWarning,
123+
stacklevel=2,
124+
)
125+
parameters["input_data"] = input_data
126+
114127
# Run action
115128
rule_results["action_result"] = self._action(**parameters)
116129

tests/examples/code/actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def send_email(mail_to: str, mail_content: str, meal: str) -> bool:
3030
return is_ok
3131

3232

33-
def concatenate_list(list_str: list[Any], **extra: Any) -> str:
33+
def concatenate_list(list_str: list[Any], input_data: dict[str, Any]) -> str:
3434
"""Demo function: return the concatenation of a list of string using input_data (two levels max)."""
3535
list_str = [str(element) for element in list_str]
3636
return "".join(list_str)
@@ -41,7 +41,7 @@ def do_nothing(**kwargs: Any) -> None:
4141
pass
4242

4343

44-
def compute_sum(value1: float, value2: float, **kwargs: Any) -> float:
44+
def compute_sum(value1: float, value2: float, **extra: Any) -> float:
4545
"""Demo function: return sum of two values."""
4646
return value1 + value2
4747

tests/test_example_code/test_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_send_email(mail_to, mail_content, meal, expected):
5151

5252
def test_concatenate_list():
5353
"""Action function unit test."""
54-
result = actions.concatenate_list(["a", "b", "c"])
54+
result = actions.concatenate_list(["a", "b", "c"], {})
5555
assert result == "abc"
5656

5757

0 commit comments

Comments
 (0)