Skip to content

Commit d52c4fb

Browse files
authored
Enable ruff PLW0602 rule (apache#57588)
1 parent 26c93bc commit d52c4fb

File tree

9 files changed

+4
-22
lines changed

9 files changed

+4
-22
lines changed

airflow-core/src/airflow/api_fastapi/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ def init_auth_manager(app: FastAPI | None = None) -> BaseAuthManager:
161161

162162
def get_auth_manager() -> BaseAuthManager:
163163
"""Return the auth manager, provided it's been initialized before."""
164-
global auth_manager
165-
166164
if auth_manager is None:
167165
raise RuntimeError(
168166
"Auth Manager has not been initialized yet. "

airflow-core/src/airflow/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ def load_test_config(self):
18861886
"""
18871887
# We need those globals before we run "get_all_expansion_variables" because this is where
18881888
# the variables are expanded from in the configuration
1889-
global FERNET_KEY, AIRFLOW_HOME, JWT_SECRET_KEY
1889+
global FERNET_KEY, JWT_SECRET_KEY
18901890
from cryptography.fernet import Fernet
18911891

18921892
unit_test_config_file = pathlib.Path(__file__).parent / "config_templates" / "unit_tests.cfg"

airflow-core/src/airflow/logging_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
def __getattr__(name: str):
4040
if name == "REMOTE_TASK_LOG":
41-
global REMOTE_TASK_LOG
4241
load_logging_config()
4342
return REMOTE_TASK_LOG
4443

airflow-core/src/airflow/plugins_manager.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ def is_valid_plugin(plugin_obj):
214214
:return: Whether or not the obj is a valid subclass of
215215
AirflowPlugin
216216
"""
217-
global plugins
218-
219217
if (
220218
inspect.isclass(plugin_obj)
221219
and issubclass(plugin_obj, AirflowPlugin)
@@ -234,8 +232,6 @@ def register_plugin(plugin_instance):
234232
235233
:param plugin_instance: subclass of AirflowPlugin
236234
"""
237-
global plugins
238-
239235
if plugin_instance.name in loaded_plugins:
240236
return
241237

@@ -250,8 +246,6 @@ def load_entrypoint_plugins():
250246
251247
The entry_point group should be 'airflow.plugins'.
252248
"""
253-
global import_errors
254-
255249
log.debug("Loading plugins from entrypoints")
256250

257251
for entry_point, dist in entry_points_with_dist("airflow.plugins"):
@@ -271,7 +265,6 @@ def load_entrypoint_plugins():
271265

272266
def load_plugins_from_plugin_directory():
273267
"""Load and register Airflow Plugins from plugins directory."""
274-
global import_errors
275268
log.debug("Loading plugins from directory: %s", settings.PLUGINS_FOLDER)
276269
files = find_path_from_directory(settings.PLUGINS_FOLDER, ".airflowignore")
277270
plugin_search_locations: list[tuple[str, Generator[str, None, None]]] = [("", files)]
@@ -373,7 +366,6 @@ def ensure_plugins_loaded():
373366

374367
def initialize_ui_plugins():
375368
"""Collect extension points for the UI."""
376-
global plugins
377369
global external_views
378370
global react_apps
379371

@@ -456,7 +448,6 @@ def _remove_list_item(lst, item):
456448

457449
def initialize_flask_plugins():
458450
"""Collect flask extension points for WEB UI (legacy)."""
459-
global plugins
460451
global flask_blueprints
461452
global flask_appbuilder_views
462453
global flask_appbuilder_menu_links
@@ -496,7 +487,6 @@ def initialize_flask_plugins():
496487

497488
def initialize_fastapi_plugins():
498489
"""Collect extension points for the API."""
499-
global plugins
500490
global fastapi_apps
501491
global fastapi_root_middlewares
502492

@@ -593,7 +583,6 @@ def initialize_hook_lineage_readers_plugins():
593583

594584
def integrate_macros_plugins() -> None:
595585
"""Integrates macro plugins."""
596-
global plugins
597586
global macros_modules
598587

599588
from airflow.sdk.execution_time import macros
@@ -626,8 +615,6 @@ def integrate_macros_plugins() -> None:
626615

627616
def integrate_listener_plugins(listener_manager: ListenerManager) -> None:
628617
"""Add listeners from plugins."""
629-
global plugins
630-
631618
ensure_plugins_loaded()
632619

633620
if plugins:

airflow-ctl-tests/tests/airflowctl_tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ def docker_compose_up(tmp_path_factory):
182182

183183
def docker_compose_down():
184184
"""Tear down Docker Compose environment."""
185-
global docker_client
186185
if docker_client:
187186
docker_client.compose.down(remove_orphans=True, volumes=True, quiet=True)
188187

dev/breeze/src/airflow_breeze/prepare_providers/provider_documentation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,6 @@ def update_release_notes(
836836
return with_breaking_changes, maybe_with_new_features, False
837837
change_table_len = len(list_of_list_of_changes[0])
838838
table_iter = 0
839-
global SHORT_HASH_TO_TYPE_DICT
840839
type_of_current_package_changes: list[TypeOfChange] = []
841840
while table_iter < change_table_len:
842841
get_console().print()

providers/standard/tests/unit/standard/operators/test_python.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ def f():
955955

956956
def test_string_args(self):
957957
def f():
958-
global virtualenv_string_args
959958
print(virtualenv_string_args)
960959
if virtualenv_string_args[0] != virtualenv_string_args[2]:
961960
raise RuntimeError

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ extend-select = [
595595
"PLW0128", # Redeclared variable {name} in assignment
596596
"PLW0129", # Asserting on an empty string literal will never pass
597597
"PLW0133", # Missing raise statement on exception
598+
"PLW0245", # super call is missing parentheses
599+
"PLW0406", # Module {name} imports itself
600+
"PLW0602", # Using global for {name} but no assignment is done
598601
# Per rule enables
599602
"RUF006", # Checks for asyncio dangling task
600603
"RUF015", # Checks for unnecessary iterable allocation for first element

scripts/ci/prek/check_providers_subpackages_all_have_init.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ def _determine_init_py_action(need_path_extension: bool, root_path: Path):
105105

106106

107107
def check_dir_init_test_folders(folders: list[Path]) -> None:
108-
global should_fail
109108
folders = list(folders)
110109
for root_distribution_path in folders:
111110
# 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:
121120

122121

123122
def check_dir_init_src_folders(folders: list[Path]) -> None:
124-
global should_fail
125123
folders = list(folders)
126124
for root_distribution_path in folders:
127125
# We need init folders for all folders and for the common ones we need path extension

0 commit comments

Comments
 (0)