ashb commented on a change in pull request #5302: [AIRFLOW-4374] Make
enum-like-classes inherit from enum
URL: https://github.com/apache/airflow/pull/5302#discussion_r292383198
##########
File path: airflow/models/baseoperator.py
##########
@@ -304,12 +304,24 @@ def __init__(
if end_date:
self.end_date = timezone.convert_to_utc(end_date)
- if not TriggerRule.is_valid(trigger_rule):
- raise AirflowException(
- "The trigger_rule must be one of {all_triggers},"
- "'{d}.{t}'; received '{tr}'."
- .format(all_triggers=TriggerRule.all_triggers(),
- d=dag.dag_id if dag else "", t=task_id,
tr=trigger_rule))
+ if trigger_rule not in TriggerRule:
+ try:
+ # trigger_rule values such as "all_done" will be converted to
the TriggerRule enum
+ trigger_rule = TriggerRule(trigger_rule)
+ warnings.warn(
+ "Passing TriggerRule as a string is deprecated. "
+ "Instead the TriggerRule enum should be used:
{tr}.".format(tr=trigger_rule),
+ category=DeprecationWarning,
Review comment:
```suggestion
category=DeprecationWarning,
stacklevel=2,
```
That way the line number will be reported from a useful line number (i.e.
the DAGĀ file), not this file.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services