amoghrajesh commented on code in PR #53929:
URL: https://github.com/apache/airflow/pull/53929#discussion_r2253937817
##########
task-sdk/src/airflow/sdk/definitions/mappedoperator.py:
##########
@@ -144,6 +154,21 @@ def is_mappable_value(value: Any) -> TypeGuard[Collection]:
return True
+def prevent_duplicates(kwargs1: dict[str, Any], kwargs2: Mapping[str, Any], *,
fail_reason: str) -> None:
+ """
+ Ensure *kwargs1* and *kwargs2* do not contain common keys.
+
+ :raises TypeError: If common keys are found.
+ """
+ duplicated_keys = set(kwargs1).intersection(kwargs2)
+ if not duplicated_keys:
+ return
+ if len(duplicated_keys) == 1:
+ raise TypeError(f"{fail_reason} argument: {duplicated_keys.pop()}")
+ duplicated_keys_display = ", ".join(sorted(duplicated_keys))
+ raise TypeError(f"{fail_reason} arguments: {duplicated_keys_display}")
Review Comment:
Checked again, there was one occurence in core which I have already handled
using a private method, so getting rid of that
##########
airflow-core/src/airflow/models/mappedoperator.py:
##########
@@ -46,6 +46,21 @@
log = structlog.get_logger(__name__)
+def _prevent_duplicates(kwargs1: dict[str, Any], kwargs2: Mapping[str, Any],
*, fail_reason: str) -> None:
+ """
+ Ensure *kwargs1* and *kwargs2* do not contain common keys.
+
+ :raises TypeError: If common keys are found.
+ """
+ duplicated_keys = set(kwargs1).intersection(kwargs2)
+ if not duplicated_keys:
+ return
+ if len(duplicated_keys) == 1:
+ raise TypeError(f"{fail_reason} argument: {duplicated_keys.pop()}")
+ duplicated_keys_display = ", ".join(sorted(duplicated_keys))
+ raise TypeError(f"{fail_reason} arguments: {duplicated_keys_display}")
Review Comment:
Yeah that should not be a TypeError, its a copy paste from the original
location, i will add that in a follow up, limiting this PR to ONLY what its
supposed to do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]