From d718d8232aa7b88f4e0dea1ca2148e76c0fc42fc Mon Sep 17 00:00:00 2001 From: Shahar Epstein <60007259+shahar1@users.noreply.github.com> Date: Sun, 17 May 2026 23:06:33 +0300 Subject: [PATCH] Remove resolved triggers from KNOWN_VIOLATIONS allowlist All five trigger entries originally allowlisted in check-trigger-serialize-init.py have been fixed in separate PRs (#66965, #66966, #66968, #67053). With every parameter now round-tripping through serialize(), the allowlist itself can go: drop KNOWN_VIOLATIONS and have the check consult BY_DESIGN_EXCLUSIONS directly, so any future regression trips the hook instead of being silently re-added. closes: #66961 --- .../ci/prek/check_trigger_serialize_init.py | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/scripts/ci/prek/check_trigger_serialize_init.py b/scripts/ci/prek/check_trigger_serialize_init.py index 6e91056e07249..f1050a9340ea5 100755 --- a/scripts/ci/prek/check_trigger_serialize_init.py +++ b/scripts/ci/prek/check_trigger_serialize_init.py @@ -54,21 +54,7 @@ class defined in another file cannot be resolved statically and are skipped -- t "https://github.com/apache/airflow/blob/main/airflow-core/docs/authoring-and-scheduling/deferring.rst" ) -# Key format for both sets below: "::". - -# Trigger classes that genuinely violate the __init__/serialize() contract today. They predate -# the check and are excluded so it can be enabled without a tree-wide fix; each is tracked for a -# follow-up fix in a separate PR. Do NOT add new entries here -- fix the trigger instead. -KNOWN_VIOLATIONS: set[str] = { - # `caller` is passed straight to DatabricksHook(caller=...) and never stored/serialized, so it - # falls back to the class-name default on a triggerer round-trip. - "databricks/src/airflow/providers/databricks/triggers/databricks.py::DatabricksExecutionTrigger", - "databricks/src/airflow/providers/databricks/triggers/databricks.py::DatabricksSQLStatementExecutionTrigger", - # `poll_interval` and `impersonation_chain` are stored and used but missing from serialize(). - "google/src/airflow/providers/google/cloud/triggers/datafusion.py::DataFusionStartPipelineTrigger", - # `endpoint_prefix` is stored as self._endpoint_prefix and used in run() but missing from serialize(). - "apache/livy/src/airflow/providers/apache/livy/triggers/livy.py::LivyTrigger", -} +# Key format: "::". # Trigger classes that the check flags but which are correct *by design*: an old/aliased parameter # is folded into its replacement at construction time, so it does not need to round-trip. These are @@ -83,8 +69,6 @@ class defined in another file cannot be resolved statically and are skipped -- t "cncf/kubernetes/src/airflow/providers/cncf/kubernetes/triggers/job.py::KubernetesJobTrigger", } -_EXCLUDED = KNOWN_VIOLATIONS | BY_DESIGN_EXCLUSIONS - def _get_init_param_names(func: ast.FunctionDef) -> set[str]: """Return the names of reconstructable __init__ parameters (``*args``/``**kwargs`` excluded).""" @@ -223,7 +207,7 @@ def get_violations(self) -> list[tuple[str, list[str]]]: results: list[tuple[str, list[str]]] = [] rel = self.path.relative_to(AIRFLOW_PROVIDERS_ROOT_PATH).as_posix() for name, cls in self.classes.items(): - if f"{rel}::{name}" in _EXCLUDED: + if f"{rel}::{name}" in BY_DESIGN_EXCLUSIONS: continue if not self.is_trigger(cls): continue