amoghrajesh commented on PR #53389:
URL: https://github.com/apache/airflow/pull/53389#issuecomment-3174364074
@sunank200 the idea to keep it in the _generated.py is correct, it will be
used in dag authoring.
For the mypy issues, you can easily get past it by not having to rely on
class methods for those classes for task sdk's TriggerRule.
For instance you could do:
```
def validate_trigger_rule_new(rule):
try:
tr = TriggerRule(rule)
return len(tr) > 0
except ValueError:
raise ValueError(
f"The trigger_rule must be one of {[rule.value for rule in
TriggerRule]}, "
f"'{dag_id}.{task_id}'; received '{rule}'."
)
def validate_trigger_rule_old(rule):
try:
return TriggerRule.is_valid(rule)
except ValueError:
raise ValueError(
f"The trigger_rule must be one of {[rule.value for rule in
TriggerRule]}, "
f"'{dag_id}.{task_id}'; received '{rule}'."
)
validate_trigger_rule_new(my_rule) == validate_trigger_rule_old(my_rule)
Out[21]: True
```
`tr = TriggerRule(rule)` is good enough to know if the `rule` is valid or
not. Similarly for the `all_triggers` you could try with
`TriggerRule.__members__` in its usages.
--
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]