Skip to contentSkip to conversation

semanage: use instance check

RFC PATCH In review Christian Göttsche 3 participants 3 messages Aug 7, 2023 – Aug 8, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 semanage: use instance check

Please flake8:

./python/semanage/seobject.py:250:16: E721 do not compare types, for exact checks use is / is not, for instance checks use isinstance()

---
This currently breaks the GitHub CI.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -1
index 361205d1..cc944ae2 100644
@@ -247,7 +247,7 @@ class semanageRecords:
         global handle
         if args:
             # legacy code - args was store originally
-            if type(args) == str:
+            if isinstance(args, str):
                 self.store = args
             else:
                 self.args = args
Signature · 1 line
2.40.1
#1 lore raw
Quoted 4 lines · Christian Göttsche

Please flake8:

./python/semanage/seobject.py:250:16: E721 do not compare types, for exact checks use is / is not, for instance checks use isinstance()

Thanks, but it's already proposed

https://lore.kernel.org/selinux/[email protected]/T/#u

Quoted 21 lines

---
This currently breaks the GitHub CI.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -1
index 361205d1..cc944ae2 100644
@@ -247,7 +247,7 @@ class semanageRecords:
         global handle
         if args:
             # legacy code - args was store originally
-            if type(args) == str:
+            if isinstance(args, str):
                 self.store = args
             else:
                 self.args = args
Signature · 1 line
2.40.1
#2 lore raw
In reply to Christian Göttsche
Quoted 5 lines · Christian Göttsche

Please flake8:

./python/semanage/seobject.py:250:16: E721 do not compare types, for exact checks use is / is not, for instance checks use isinstance()

Another patch just like this has been merged.
Thanks,
Jim

Quoted 22 lines

---
This currently breaks the GitHub CI.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -2
index 361205d1..cc944ae2 100644
@@ -247,7 +247,7 @@ class semanageRecords:
         global handle
         if args:
             # legacy code - args was store originally
-            if type(args) == str:
+            if isinstance(args, str):
                 self.store = args
             else:
                 self.args = args
--

2.40.1