Skip to content

Commit 0220f0a

Browse files
committed
Merge remote-tracking branch 'origin/topic/bbannier/lint-return'
2 parents 1092e9c + 4268969 commit 0220f0a

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

CHANGES

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
1.2-11 | 2025-04-28 11:42:33 +0200
2+
3+
* Enable lints around return statements (Benjamin Bannier, Corelight)
4+
5+
This enables a class of return-related lints[^1] around return
6+
statements. I mainly came here for redundant returns after `else`[^2],
7+
but they all seemed useful. In general this seems to reduce nesting, and
8+
also make overall flow clearer.
9+
10+
[^1]: https://docs.astral.sh/ruff/rules/#flake8-return-ret
11+
[^2]: https://docs.astral.sh/ruff/rules/superfluous-else-return/
12+
113
1.2-9 | 2025-04-22 17:56:49 +0200
214

315
* Bump pre-commit hooks (Benjamin Bannier, Corelight)

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
..
33
.. Version number is filled in automatically.
44

5-
.. |version| replace:: 1.2-9
5+
.. |version| replace:: 1.2-11
66

77
==================================================
88
BTest - A Generic Driver for Powerful System Tests

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2-9
1+
1.2-11

btest

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ else:
5656
import multiprocessing.managers as mp_managers
5757
import multiprocessing.sharedctypes as mp_sharedctypes
5858

59-
VERSION = "1.2-9" # Automatically filled in.
59+
VERSION = "1.2-11" # Automatically filled in.
6060

6161
Name = "btest"
6262
Config = None
@@ -263,9 +263,7 @@ def ExpandBackticks(origvalue):
263263

264264
return out.strip()
265265

266-
value = reBackticks.sub(_exec, origvalue)
267-
268-
return value
266+
return reBackticks.sub(_exec, origvalue)
269267

270268

271269
# We monkey-patch the config parser to provide an alternative method that
@@ -1488,12 +1486,11 @@ class Test:
14881486
self.diagmsgs += [f"'{cmdline}' succeeded unexpectedly (exit code 0)"]
14891487
return (False, 0)
14901488

1491-
else:
1492-
if not cmd.expect_success:
1493-
return (True, rc)
1489+
if not cmd.expect_success:
1490+
return (True, rc)
14941491

1495-
self.diagmsgs += [f"'{cmdline}' failed unexpectedly (exit code {rc})"]
1496-
return (False, rc)
1492+
self.diagmsgs += [f"'{cmdline}' failed unexpectedly (exit code {rc})"]
1493+
return (False, rc)
14971494

14981495
def rmTmp(self, *, with_close=False):
14991496
if with_close:
@@ -1553,8 +1550,8 @@ class Test:
15531550
def timePostfix(self):
15541551
if self.utime_base >= 0 and self.utime >= 0:
15551552
return f" ({self.utime_perc:+.1f}%)"
1556-
else:
1557-
return ""
1553+
1554+
return ""
15581555

15591556
# Picks up any progress output that has a test has written out.
15601557
def parseProgress(self):
@@ -1612,8 +1609,8 @@ class OutputHandler:
16121609
# requested, plus 1 for "#".
16131610
width = len(str(self.options().threads)) + 1
16141611
return f"[{mp.current_process().name:>{width}}]"
1615-
else:
1616-
return ""
1612+
1613+
return ""
16171614

16181615
def _output(self, msg, nl=True, file=None):
16191616
if not file:
@@ -2555,10 +2552,10 @@ def readTestFile(filename):
25552552
t = Test(filename)
25562553
if t.parse(content, filename):
25572554
return t
2558-
else:
2559-
return None
2560-
else:
2561-
return previous.clone(content)
2555+
2556+
return None
2557+
2558+
return previous.clone(content)
25622559

25632560
if os.path.basename(filename) == ".btest-ignore":
25642561
return []

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ per-file-ignores = """
7373
"""
7474

7575
[tool.ruff.lint]
76-
select = ["C4", "F", "I", "ISC", "UP"]
76+
select = ["C4", "F", "I", "ISC", "RET", "UP"]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
py_modules = ["btest-sphinx"]
66

77
setup(
8-
version="1.2.dev9", # Filled in automatically.
8+
version="1.2.dev11", # Filled in automatically.
99
py_modules=py_modules,
1010
)

0 commit comments

Comments
 (0)