This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 6838072102 Fix bug in validate-operators-init pre-commit (#38014)
6838072102 is described below

commit 6838072102e9c8bc4415eb27f51da8d63ad91a93
Author: Shahar Epstein <60007259+shah...@users.noreply.github.com>
AuthorDate: Sun Mar 10 20:24:45 2024 +0200

    Fix bug in validate-operators-init pre-commit (#38014)
---
 .pre-commit-config.yaml                                     | 13 +++++++++++++
 scripts/ci/pre_commit/pre_commit_validate_operators_init.py |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f6f647075e..540598d089 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -330,6 +330,19 @@ repos:
         pass_filenames: true
         files: ^airflow/providers/.*/(operators|transfers|sensors)/.*\.py$
         additional_dependencies: [ 'rich>=12.4.4' ]
+        # TODO: Handle the provider-specific exclusions and remove them from 
the list, see:
+        #       https://github.com/apache/airflow/issues/36484
+        exclude: |
+          (?x)^(
+              ^airflow\/providers\/google\/cloud\/operators\/mlengine.py$|
+              
^airflow\/providers\/google\/cloud\/operators\/vertex_ai\/custom_job.py$|
+              
^airflow\/providers\/google\/cloud\/operators\/cloud_storage_transfer_service.py$|
+              
^airflow\/providers\/apache\/spark\/operators\/spark_submit.py\.py$|
+              
^airflow\/providers\/google\/cloud\/operators\/vertex_ai\/auto_ml\.py$|
+              ^airflow\/providers\/apache\/spark\/operators\/spark_submit\.py$|
+              ^airflow\/providers\/apache\/spark\/operators\/spark_sql\.py$|
+              ^airflow\/providers\/databricks\/operators\/databricks_sql\.py$|
+          )$
       - id: ruff
         name: Run 'ruff' for extremely fast Python linting
         description: "Run 'ruff' for extremely fast Python linting"
diff --git a/scripts/ci/pre_commit/pre_commit_validate_operators_init.py 
b/scripts/ci/pre_commit/pre_commit_validate_operators_init.py
index aab3a4d47b..4340402091 100755
--- a/scripts/ci/pre_commit/pre_commit_validate_operators_init.py
+++ b/scripts/ci/pre_commit/pre_commit_validate_operators_init.py
@@ -162,7 +162,7 @@ def _handle_assigned_field(
     :param target: The target field.
     :param value: The value of the field.
     """
-    if not isinstance(value, ast.Name):
+    if not isinstance(value, ast.Name) or target.attr != value.id:
         invalid_assignments.append(target.attr)
     else:
         assigned_template_fields.append(target.attr)

Reply via email to