You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2025/12/26 00:34:41 UTC

(airflow) branch main updated: Add and fix SIM107 and B012 Ruff rule (#59770)

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 77a2f1cb6f9 Add and fix SIM107 and B012 Ruff rule (#59770)
77a2f1cb6f9 is described below

commit 77a2f1cb6f9c3de1a2a9428d9a38de3c4896768b
Author: Jens Scheffler <95...@users.noreply.github.com>
AuthorDate: Fri Dec 26 01:34:34 2025 +0100

    Add and fix SIM107 and B012 Ruff rule (#59770)
    
    * Add and fix SIM107 and B012 Ruff rule
    
    * Review by @johnslavik
---
 providers/celery/src/airflow/providers/celery/cli/celery_command.py  | 5 ++---
 .../src/airflow/providers/cncf/kubernetes/utils/pod_manager.py       | 2 +-
 pyproject.toml                                                       | 2 ++
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/providers/celery/src/airflow/providers/celery/cli/celery_command.py b/providers/celery/src/airflow/providers/celery/cli/celery_command.py
index 9b92d70299e..01c87635b8d 100644
--- a/providers/celery/src/airflow/providers/celery/cli/celery_command.py
+++ b/providers/celery/src/airflow/providers/celery/cli/celery_command.py
@@ -132,10 +132,9 @@ def _run_stale_bundle_cleanup():
         )
     if not check_interval or check_interval <= 0 or not AIRFLOW_V_3_0_PLUS:
         # do not start bundle cleanup process
-        try:
+        with suppress(BaseException):
             yield
-        finally:
-            return
+        return
     from airflow.dag_processing.bundles.base import BundleUsageTrackingManager
 
     log.info("starting stale bundle cleanup process")
diff --git a/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py b/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py
index 5e454d1930d..c9b48158d96 100644
--- a/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py
+++ b/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py
@@ -1095,4 +1095,4 @@ class AsyncPodManager(LoggingMixin):
                     print(message_to_log)
                 else:
                     self.log.info("[%s] %s", container_name, message_to_log)
-            return now  # Return the current time as the last log time to ensure logs from the current second are read in the next fetch.
+        return now  # Return the current time as the last log time to ensure logs from the current second are read in the next fetch.
diff --git a/pyproject.toml b/pyproject.toml
index 423326157a4..1c50e784096 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -629,11 +629,13 @@ extend-select = [
     "PGH004",  # Use specific rule codes when using noqa
     "PGH005", # Invalid unittest.mock.Mock methods/attributes/properties
     "S101", # Checks use `assert` outside the test cases, test cases should be added into the exclusions
+    "SIM107", # Don't use `return` in `try`-`except` and `finally`
     "SIM300", # Checks for conditions that position a constant on the left-hand side of the comparison
               # operator, rather than the right-hand side.
     "B004", # Checks for use of hasattr(x, "__call__") and replaces it with callable(x)
     "B006", # Checks for uses of mutable objects as function argument defaults.
     "B007", # Checks for unused variables in the loop
+    "B012", # Checks for `break`, `continue`, and `return` statements in `finally` blocks
     "B017", # Checks for pytest.raises context managers that catch Exception or BaseException.
     "B019", # Use of functools.lru_cache or functools.cache on methods can lead to memory leaks
     "B028", # No explicit stacklevel keyword argument found