[PATCHv2 01/25] apibuild: Use isinstance for type checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The isinstance() function [1] returns true if an object argument is an
instance of a classinfo argument or of a direct, indirect subclass
thereof.

1: https://docs.python.org/3/library/functions.html#isinstance

Signed-off-by: Radostin Stoyanov <rstoyanov1@xxxxxxxxx>
---
 docs/apibuild.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 17d14a0c5..832f04ab1 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -742,7 +742,7 @@ class CParser:
         return line
 
     def cleanupComment(self):
-        if type(self.comment) != type(""):
+        if not isinstance(self.comment, str):
             return
         # remove the leading * on multi-line comments
         lines = self.comment.splitlines(True)
@@ -2223,9 +2223,8 @@ class docBuilder:
             output.write("    <struct name='%s' file='%s' type='%s'" % (
                      name, self.modulename_file(id.header), id.info))
             name = id.info[7:]
-            if name in self.idx.structs and ( \
-               type(self.idx.structs[name].info) == type(()) or
-                type(self.idx.structs[name].info) == type([])):
+            if (name in self.idx.structs and
+                    isinstance(self.idx.structs[name].info, (list, tuple))):
                 output.write(">\n")
                 try:
                     for field in self.idx.structs[name].info:
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux