Skip to content

Commit 4d50073

Browse files
committed
test: refactor: Simplify CpuMap._cpus
Eliminate the local variable and the for-break-else construct by simply returning early. Signed-off-by: Patrick Roy <[email protected]>
1 parent 4f3d8cd commit 4d50073

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tests/framework/utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,14 @@ def _cpus(cls):
234234
# - cgroupsv1: /cpuset.cpus
235235
# - cgroupsv2: /cpuset.cpus.effective
236236
# For more details, see https://docs.kernel.org/admin-guide/cgroup-v2.html#cpuset-interface-files
237-
cpulist = None
238237
for path in [
239238
Path("/sys/fs/cgroup/cpuset/cpuset.cpus"),
240239
Path("/sys/fs/cgroup/cpuset.cpus.effective"),
241240
]:
242241
if path.exists():
243-
cpulist = path.read_text("ascii").strip()
244-
break
245-
else:
246-
raise RuntimeError("Could not find cgroups cpuset")
247-
return ListFormatParser(cpulist).parse()
242+
return ListFormatParser(path.read_text("ascii").strip()).parse()
243+
244+
raise RuntimeError("Could not find cgroups cpuset")
248245

249246

250247
class ListFormatParser:

0 commit comments

Comments
 (0)