Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions scripts/ci/prek/check_trigger_serialize_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<path relative to the providers/ directory>::<ClassName>".

# 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: "<path relative to the providers/ directory>::<ClassName>".

# 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
Expand All @@ -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)."""
Expand Down Expand Up @@ -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
Expand Down
Loading