Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: net: py: coding style improvements

We're about to add more features here and finding new issues with old
ones in place is hard. Address ruff checks:
- bare exceptions
- f-string with no params
- unused import

We need to use BaseException when handling defer(), as Petr points out.
This retains the old behavior of ignoring SIGTERM while running cleanups.

Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/20251120021024.2944527-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+3 -4
+3 -4
tools/testing/selftests/net/lib/py/ksft.py
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - import builtins 4 3 import functools 5 4 import inspect 6 5 import signal ··· 162 163 entry = global_defer_queue.pop() 163 164 try: 164 165 entry.exec_only() 165 - except: 166 + except BaseException: 166 167 ksft_pr(f"Exception while handling defer / cleanup (callback {i} of {qlen_start})!") 167 168 tb = traceback.format_exc() 168 169 for line in tb.strip().split('\n'): ··· 180 181 @functools.wraps(func) 181 182 def wrapper(*args, **kwargs): 182 183 if not KSFT_DISRUPTIVE: 183 - raise KsftSkipEx(f"marked as disruptive") 184 + raise KsftSkipEx("marked as disruptive") 184 185 return func(*args, **kwargs) 185 186 return wrapper 186 187 ··· 198 199 return False 199 200 try: 200 201 return bool(int(value)) 201 - except: 202 + except Exception: 202 203 raise Exception(f"failed to parse {name}") 203 204 204 205 if "DISRUPTIVE" in env: