]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests/cgroup: satisfy E721 in Cgroup.exists()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 2 Feb 2026 06:52:57 +0000 (12:22 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 19 Mar 2026 17:17:59 +0000 (11:17 -0600)
flake8 reported:
tests/ftests/cgroup.py:1171:33: E721 do not compare types, for exact
checks use is / is not, for instance checks use isinstance()
tests/ftests/cgroup.py:1173:14: E721 do not compare types, for exact
checks use is / is not, for instance checks use isinstance()

The helper only needs to distinguish between string, list, or None
inputs, so replace the raw type() comparisons with isinstance() calls.
That keeps the behaviour unchanged while removing the lint warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/ftests/cgroup.py

index 842dfeff831a301018fb96d3f01b9db06be1b69b..b0a8e850a3bb2ef837e26a9f1f0115caea43255c 100644 (file)
@@ -1168,9 +1168,9 @@ class Cgroup(object):
     # path for all three cgroup setup modes, including empty cgroup v2.
     @staticmethod
     def exists(config, ctrl_name, cgroup_name, ignore_systemd=False):
-        if ctrl_name is None or type(ctrl_name) == str:
+        if ctrl_name is None or isinstance(ctrl_name, str):
             return Cgroup.__exists(config, ctrl_name, cgroup_name, ignore_systemd)
-        elif type(ctrl_name) == list:
+        elif isinstance(ctrl_name, list):
             for ctrl in ctrl_name:
                 if not Cgroup.__exists(config, ctrl, cgroup_name, ignore_systemd):
                     # if any of the controllers don't exist, fail the check