Skip to content

Commit 77a2f1c

Browse files
authored
Add and fix SIM107 and B012 Ruff rule (#59770)
* Add and fix SIM107 and B012 Ruff rule * Review by @johnslavik
1 parent 406d616 commit 77a2f1c

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

providers/celery/src/airflow/providers/celery/cli/celery_command.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ def _run_stale_bundle_cleanup():
132132
)
133133
if not check_interval or check_interval <= 0 or not AIRFLOW_V_3_0_PLUS:
134134
# do not start bundle cleanup process
135-
try:
135+
with suppress(BaseException):
136136
yield
137-
finally:
138-
return
137+
return
139138
from airflow.dag_processing.bundles.base import BundleUsageTrackingManager
140139

141140
log.info("starting stale bundle cleanup process")

providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,4 +1095,4 @@ async def fetch_container_logs_before_current_sec(
10951095
print(message_to_log)
10961096
else:
10971097
self.log.info("[%s] %s", container_name, message_to_log)
1098-
return now # Return the current time as the last log time to ensure logs from the current second are read in the next fetch.
1098+
return now # Return the current time as the last log time to ensure logs from the current second are read in the next fetch.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,13 @@ extend-select = [
629629
"PGH004", # Use specific rule codes when using noqa
630630
"PGH005", # Invalid unittest.mock.Mock methods/attributes/properties
631631
"S101", # Checks use `assert` outside the test cases, test cases should be added into the exclusions
632+
"SIM107", # Don't use `return` in `try`-`except` and `finally`
632633
"SIM300", # Checks for conditions that position a constant on the left-hand side of the comparison
633634
# operator, rather than the right-hand side.
634635
"B004", # Checks for use of hasattr(x, "__call__") and replaces it with callable(x)
635636
"B006", # Checks for uses of mutable objects as function argument defaults.
636637
"B007", # Checks for unused variables in the loop
638+
"B012", # Checks for `break`, `continue`, and `return` statements in `finally` blocks
637639
"B017", # Checks for pytest.raises context managers that catch Exception or BaseException.
638640
"B019", # Use of functools.lru_cache or functools.cache on methods can lead to memory leaks
639641
"B028", # No explicit stacklevel keyword argument found

0 commit comments

Comments
 (0)