ferruzzi commented on code in PR #73294:
URL: https://github.com/apache/airflow/pull/73294#discussion_r4067263152
##########
task-sdk/src/airflow/sdk/definitions/deadline.py:
##########
@@ -154,14 +154,22 @@ def __init__(
callback: Callback,
name: str | None = None,
):
+ if not isinstance(interval, (timedelta, VariableInterval)):
+ raise ValueError(
+ f"Interval must be a `timedelta` or a `VariableInterval`,
received {type(interval).__name__}."
+ )
+
+ # Serializing blocks subclasses for security reasons, so isinstance is
too loose.
Review Comment:
Another fair point. I've simplified it and dropped the "not timedelta"
part; we don't lose anything by casting a timedelta to a timedelta in addition
to casting timedelta subclasses intio timedeltas ((not technically true,
apparently we lose timedelta.max, but anybody setting a Deadline for 3 million
years from now has a lot more faith in my work than I do :P ))
`pendulum.duration(hours=1)` now normalises to a plain `timedelta` instead
of dying in serde later, and I've added
`test_deadline_init_normalizes_timedelta_subclass` to cover that case.
--
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]