This is an automated email from the ASF dual-hosted git repository.
weilee 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 c922dfb54f4 refactor(HITL): make default options class variables to
avoid typo (#53849)
c922dfb54f4 is described below
commit c922dfb54f4943b0293559df0223f6bccf935c44
Author: Wei Lee <[email protected]>
AuthorDate: Thu Jul 31 09:43:49 2025 +0800
refactor(HITL): make default options class variables to avoid typo (#53849)
---
.../src/airflow/providers/standard/operators/hitl.py | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git
a/providers/standard/src/airflow/providers/standard/operators/hitl.py
b/providers/standard/src/airflow/providers/standard/operators/hitl.py
index c16c1fabf93..d469e580a09 100644
--- a/providers/standard/src/airflow/providers/standard/operators/hitl.py
+++ b/providers/standard/src/airflow/providers/standard/operators/hitl.py
@@ -170,6 +170,9 @@ class ApprovalOperator(HITLOperator, SkipMixin):
FIXED_ARGS = ["options", "multiple"]
+ APPROVE = "Approve"
+ REJECT = "Reject"
+
def __init__(self, ignore_downstream_trigger_rules: bool = False,
**kwargs) -> None:
for arg in self.FIXED_ARGS:
if arg in kwargs:
@@ -177,13 +180,17 @@ class ApprovalOperator(HITLOperator, SkipMixin):
self.ignore_downstream_trigger_rules = ignore_downstream_trigger_rules
- super().__init__(options=["Approve", "Reject"], multiple=False,
**kwargs)
+ super().__init__(
+ options=[self.APPROVE, self.REJECT],
+ multiple=False,
+ **kwargs,
+ )
def execute_complete(self, context: Context, event: dict[str, Any]) -> Any:
ret = super().execute_complete(context=context, event=event)
chosen_option = ret["chosen_options"][0]
- if chosen_option == "Approve":
+ if chosen_option == self.APPROVE:
self.log.info("Approved. Proceeding with downstream tasks...")
return ret
@@ -224,11 +231,13 @@ class HITLBranchOperator(HITLOperator):
class HITLEntryOperator(HITLOperator):
"""Human-in-the-loop Operator that is used to accept user input through
TriggerForm."""
+ OK = "OK"
+
def __init__(self, **kwargs) -> None:
if "options" not in kwargs:
- kwargs["options"] = ["OK"]
+ kwargs["options"] = [self.OK]
if "defaults" not in kwargs:
- kwargs["defaults"] = ["OK"]
+ kwargs["defaults"] = [self.OK]
super().__init__(**kwargs)