This is an automated email from the ASF dual-hosted git repository.

uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 6e011185bb Support the unpack operator in signature (#41316)
6e011185bb is described below

commit 6e011185bb4bb7611c53a919e58f1a95624b4b1a
Author: Mike <[email protected]>
AuthorDate: Fri Aug 30 02:23:59 2024 -0400

    Support the unpack operator in signature (#41316)
    
    Co-authored-by: Tzu-ping Chung <[email protected]>
    Co-authored-by: jabbera <[email protected]>
    Co-authored-by: jabbera <[email protected]>
---
 airflow/utils/operator_helpers.py    |  8 +++++++-
 tests/utils/test_operator_helpers.py | 12 ++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/airflow/utils/operator_helpers.py 
b/airflow/utils/operator_helpers.py
index dbbe562120..108a84a9ea 100644
--- a/airflow/utils/operator_helpers.py
+++ b/airflow/utils/operator_helpers.py
@@ -162,7 +162,13 @@ class KeywordParameters:
         signature = inspect.signature(func)
         has_wildcard_kwargs = any(p.kind == p.VAR_KEYWORD for p in 
signature.parameters.values())
 
-        for name in itertools.islice(signature.parameters.keys(), len(args)):
+        for name, param in itertools.islice(signature.parameters.items(), 
len(args)):
+            # Keyword-only arguments can't be passed positionally and are not 
checked.
+            if param.kind == inspect.Parameter.KEYWORD_ONLY:
+                continue
+            if param.kind == inspect.Parameter.VAR_KEYWORD:
+                continue
+
             # Check if args conflict with names in kwargs.
             if name in kwargs:
                 raise ValueError(f"The key {name!r} in args is a part of 
kwargs and therefore reserved.")
diff --git a/tests/utils/test_operator_helpers.py 
b/tests/utils/test_operator_helpers.py
index f46ad2e98a..9ebd9d08ae 100644
--- a/tests/utils/test_operator_helpers.py
+++ b/tests/utils/test_operator_helpers.py
@@ -224,3 +224,15 @@ def test_make_kwargs_callable_conflict():
         kwargs_callable(*args, **kwargs)
 
     assert "ds_nodash" in str(exc_info)
+
+
[email protected](
+    "func,args,kwargs,expected",
+    [
+        (callable10, (1, 2), {"ds_nodash": 1}, {"ds_nodash": 1}),
+        (callable11, (1, 2), {"ds_nodash": 1}, {"ds_nodash": 1}),
+    ],
+)
+def test_args_and_kwargs_conflicts(func, args, kwargs, expected):
+    kwargs_result = operator_helpers.determine_kwargs(func, args=args, 
kwargs=kwargs)
+    assert expected == kwargs_result

Reply via email to