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

jscheffl 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 d52c4fb4176 Enable ruff PLW0602 rule (#57588)
d52c4fb4176 is described below

commit d52c4fb417663803ab7e2cc26baa9d4234382b81
Author: Jens Scheffler <[email protected]>
AuthorDate: Fri Oct 31 11:22:56 2025 +0100

    Enable ruff PLW0602 rule (#57588)
---
 airflow-core/src/airflow/api_fastapi/app.py                 |  2 --
 airflow-core/src/airflow/configuration.py                   |  2 +-
 airflow-core/src/airflow/logging_config.py                  |  1 -
 airflow-core/src/airflow/plugins_manager.py                 | 13 -------------
 airflow-ctl-tests/tests/airflowctl_tests/conftest.py        |  1 -
 .../prepare_providers/provider_documentation.py             |  1 -
 .../standard/tests/unit/standard/operators/test_python.py   |  1 -
 pyproject.toml                                              |  3 +++
 .../ci/prek/check_providers_subpackages_all_have_init.py    |  2 --
 9 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/airflow-core/src/airflow/api_fastapi/app.py 
b/airflow-core/src/airflow/api_fastapi/app.py
index e74863dd3c1..337d09b2ce3 100644
--- a/airflow-core/src/airflow/api_fastapi/app.py
+++ b/airflow-core/src/airflow/api_fastapi/app.py
@@ -161,8 +161,6 @@ def init_auth_manager(app: FastAPI | None = None) -> 
BaseAuthManager:
 
 def get_auth_manager() -> BaseAuthManager:
     """Return the auth manager, provided it's been initialized before."""
-    global auth_manager
-
     if auth_manager is None:
         raise RuntimeError(
             "Auth Manager has not been initialized yet. "
diff --git a/airflow-core/src/airflow/configuration.py 
b/airflow-core/src/airflow/configuration.py
index 936c1166aba..8798a1907dd 100644
--- a/airflow-core/src/airflow/configuration.py
+++ b/airflow-core/src/airflow/configuration.py
@@ -1886,7 +1886,7 @@ class AirflowConfigParser(ConfigParser):
         """
         # We need those globals before we run "get_all_expansion_variables" 
because this is where
         # the variables are expanded from in the configuration
-        global FERNET_KEY, AIRFLOW_HOME, JWT_SECRET_KEY
+        global FERNET_KEY, JWT_SECRET_KEY
         from cryptography.fernet import Fernet
 
         unit_test_config_file = pathlib.Path(__file__).parent / 
"config_templates" / "unit_tests.cfg"
diff --git a/airflow-core/src/airflow/logging_config.py 
b/airflow-core/src/airflow/logging_config.py
index 495011d89d2..16f256d396f 100644
--- a/airflow-core/src/airflow/logging_config.py
+++ b/airflow-core/src/airflow/logging_config.py
@@ -38,7 +38,6 @@ DEFAULT_REMOTE_CONN_ID: str | None = None
 
 def __getattr__(name: str):
     if name == "REMOTE_TASK_LOG":
-        global REMOTE_TASK_LOG
         load_logging_config()
         return REMOTE_TASK_LOG
 
diff --git a/airflow-core/src/airflow/plugins_manager.py 
b/airflow-core/src/airflow/plugins_manager.py
index aa228342c1d..5a70dbcd8f0 100644
--- a/airflow-core/src/airflow/plugins_manager.py
+++ b/airflow-core/src/airflow/plugins_manager.py
@@ -214,8 +214,6 @@ def is_valid_plugin(plugin_obj):
     :return: Whether or not the obj is a valid subclass of
         AirflowPlugin
     """
-    global plugins
-
     if (
         inspect.isclass(plugin_obj)
         and issubclass(plugin_obj, AirflowPlugin)
@@ -234,8 +232,6 @@ def register_plugin(plugin_instance):
 
     :param plugin_instance: subclass of AirflowPlugin
     """
-    global plugins
-
     if plugin_instance.name in loaded_plugins:
         return
 
@@ -250,8 +246,6 @@ def load_entrypoint_plugins():
 
     The entry_point group should be 'airflow.plugins'.
     """
-    global import_errors
-
     log.debug("Loading plugins from entrypoints")
 
     for entry_point, dist in entry_points_with_dist("airflow.plugins"):
@@ -271,7 +265,6 @@ def load_entrypoint_plugins():
 
 def load_plugins_from_plugin_directory():
     """Load and register Airflow Plugins from plugins directory."""
-    global import_errors
     log.debug("Loading plugins from directory: %s", settings.PLUGINS_FOLDER)
     files = find_path_from_directory(settings.PLUGINS_FOLDER, ".airflowignore")
     plugin_search_locations: list[tuple[str, Generator[str, None, None]]] = 
[("", files)]
@@ -373,7 +366,6 @@ def ensure_plugins_loaded():
 
 def initialize_ui_plugins():
     """Collect extension points for the UI."""
-    global plugins
     global external_views
     global react_apps
 
@@ -456,7 +448,6 @@ def initialize_ui_plugins():
 
 def initialize_flask_plugins():
     """Collect flask extension points for WEB UI (legacy)."""
-    global plugins
     global flask_blueprints
     global flask_appbuilder_views
     global flask_appbuilder_menu_links
@@ -496,7 +487,6 @@ def initialize_flask_plugins():
 
 def initialize_fastapi_plugins():
     """Collect extension points for the API."""
-    global plugins
     global fastapi_apps
     global fastapi_root_middlewares
 
@@ -593,7 +583,6 @@ def initialize_hook_lineage_readers_plugins():
 
 def integrate_macros_plugins() -> None:
     """Integrates macro plugins."""
-    global plugins
     global macros_modules
 
     from airflow.sdk.execution_time import macros
@@ -626,8 +615,6 @@ def integrate_macros_plugins() -> None:
 
 def integrate_listener_plugins(listener_manager: ListenerManager) -> None:
     """Add listeners from plugins."""
-    global plugins
-
     ensure_plugins_loaded()
 
     if plugins:
diff --git a/airflow-ctl-tests/tests/airflowctl_tests/conftest.py 
b/airflow-ctl-tests/tests/airflowctl_tests/conftest.py
index 720403e3c64..13dacf5d8c5 100644
--- a/airflow-ctl-tests/tests/airflowctl_tests/conftest.py
+++ b/airflow-ctl-tests/tests/airflowctl_tests/conftest.py
@@ -182,7 +182,6 @@ def docker_compose_up(tmp_path_factory):
 
 def docker_compose_down():
     """Tear down Docker Compose environment."""
-    global docker_client
     if docker_client:
         docker_client.compose.down(remove_orphans=True, volumes=True, 
quiet=True)
 
diff --git 
a/dev/breeze/src/airflow_breeze/prepare_providers/provider_documentation.py 
b/dev/breeze/src/airflow_breeze/prepare_providers/provider_documentation.py
index fbd4c7a5ada..4bddd8d0def 100644
--- a/dev/breeze/src/airflow_breeze/prepare_providers/provider_documentation.py
+++ b/dev/breeze/src/airflow_breeze/prepare_providers/provider_documentation.py
@@ -836,7 +836,6 @@ def update_release_notes(
                 return with_breaking_changes, maybe_with_new_features, False
             change_table_len = len(list_of_list_of_changes[0])
             table_iter = 0
-            global SHORT_HASH_TO_TYPE_DICT
             type_of_current_package_changes: list[TypeOfChange] = []
             while table_iter < change_table_len:
                 get_console().print()
diff --git a/providers/standard/tests/unit/standard/operators/test_python.py 
b/providers/standard/tests/unit/standard/operators/test_python.py
index fe33cad1ce0..6b3c864c186 100644
--- a/providers/standard/tests/unit/standard/operators/test_python.py
+++ b/providers/standard/tests/unit/standard/operators/test_python.py
@@ -955,7 +955,6 @@ class BaseTestPythonVirtualenvOperator(BasePythonTest):
 
     def test_string_args(self):
         def f():
-            global virtualenv_string_args
             print(virtualenv_string_args)
             if virtualenv_string_args[0] != virtualenv_string_args[2]:
                 raise RuntimeError
diff --git a/pyproject.toml b/pyproject.toml
index e82c529be75..b107b4dc9aa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -595,6 +595,9 @@ extend-select = [
     "PLW0128", # Redeclared variable {name} in assignment
     "PLW0129", # Asserting on an empty string literal will never pass
     "PLW0133", # Missing raise statement on exception
+    "PLW0245", # super call is missing parentheses
+    "PLW0406", # Module {name} imports itself
+    "PLW0602", # Using global for {name} but no assignment is done
     # Per rule enables
     "RUF006", # Checks for asyncio dangling task
     "RUF015", # Checks for unnecessary iterable allocation for first element
diff --git a/scripts/ci/prek/check_providers_subpackages_all_have_init.py 
b/scripts/ci/prek/check_providers_subpackages_all_have_init.py
index 3a935a963b6..85bf55626bc 100755
--- a/scripts/ci/prek/check_providers_subpackages_all_have_init.py
+++ b/scripts/ci/prek/check_providers_subpackages_all_have_init.py
@@ -105,7 +105,6 @@ def _determine_init_py_action(need_path_extension: bool, 
root_path: Path):
 
 
 def check_dir_init_test_folders(folders: list[Path]) -> None:
-    global should_fail
     folders = list(folders)
     for root_distribution_path in folders:
         # We need init folders for all folders and for the common ones we need 
path extension
@@ -121,7 +120,6 @@ def check_dir_init_test_folders(folders: list[Path]) -> 
None:
 
 
 def check_dir_init_src_folders(folders: list[Path]) -> None:
-    global should_fail
     folders = list(folders)
     for root_distribution_path in folders:
         # We need init folders for all folders and for the common ones we need 
path extension

Reply via email to