From: Stephen F. <st...@th...> - 2019-08-25 15:57:23
|
This one is more stylistic than anything. Signed-off-by: Stephen Finucane <st...@th...ru> --- docutils/docutils/parsers/rst/directives/tables.py | 4 ++-- docutils/docutils/parsers/rst/states.py | 2 +- docutils/docutils/statemachine.py | 2 +- docutils/docutils/utils/math/latex2mathml.py | 2 +- docutils/test/package_unittest.py | 4 ++-- docutils/test/test_nodes.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docutils/docutils/parsers/rst/directives/tables.py b/docutils/docutils/parsers/rst/directives/tables.py index fe4664aea..670b1ffc3 100644 --- a/docutils/docutils/parsers/rst/directives/tables.py +++ b/docutils/docutils/parsers/rst/directives/tables.py @@ -104,7 +104,7 @@ class Table(Directive): return self.options.get('widths', '') def get_column_widths(self, max_cols): - if type(self.widths) == list: + if isinstance(self.widths, list): if len(self.widths) != max_cols: error = self.state_machine.reporter.error( '"%s" widths do not match the number of columns in table ' @@ -152,7 +152,7 @@ class RSTTable(Table): if 'align' in self.options: table_node['align'] = self.options.get('align') tgroup = table_node[0] - if type(self.widths) == list: + if isinstance(self.widths, list): colspecs = [child for child in tgroup.children if child.tagname == 'colspec'] for colspec, col_width in zip(colspecs, self.widths): diff --git a/docutils/docutils/parsers/rst/states.py b/docutils/docutils/parsers/rst/states.py index 456115633..4e338b5a0 100644 --- a/docutils/docutils/parsers/rst/states.py +++ b/docutils/docutils/parsers/rst/states.py @@ -447,7 +447,7 @@ def build_regexp(definition, compile=True): name, prefix, suffix, parts = definition part_strings = [] for part in parts: - if type(part) is tuple: + if isinstance(part, tuple): part_strings.append(build_regexp(part, None)) else: part_strings.append(part) diff --git a/docutils/docutils/statemachine.py b/docutils/docutils/statemachine.py index 9579a6a57..a992c982f 100644 --- a/docutils/docutils/statemachine.py +++ b/docutils/docutils/statemachine.py @@ -734,7 +734,7 @@ class State(object): names = [] transitions = {} for namestate in name_list: - if type(namestate) is stringtype: + if isinstance(namestate, stringtype): transitions[namestate] = self.make_transition(namestate) names.append(namestate) else: diff --git a/docutils/docutils/utils/math/latex2mathml.py b/docutils/docutils/utils/math/latex2mathml.py index d97005221..f037a8e56 100644 --- a/docutils/docutils/utils/math/latex2mathml.py +++ b/docutils/docutils/utils/math/latex2mathml.py @@ -168,7 +168,7 @@ class math(object): self.children = [] if children is not None: - if type(children) is list: + if isinstance(children, list): for child in children: self.append(child) else: diff --git a/docutils/test/package_unittest.py b/docutils/test/package_unittest.py index 9c35723ab..3f593bd8e 100644 --- a/docutils/test/package_unittest.py +++ b/docutils/test/package_unittest.py @@ -115,7 +115,7 @@ def loadTestModules(path, name='', packages=None): # to cheat: testSuite.addTest(moduleTests) continue - if type(suite) == types.FunctionType: + if isinstance(suite, types.FunctionType): testSuite.addTest(suite()) elif isinstance(suite, unittest.TestSuite): testSuite.addTest(suite) @@ -152,7 +152,7 @@ def main(suite=None): print("Debug: Suite=%s" % suite, file=sys.stderr) testRunner = unittest.TextTestRunner(verbosity=verbosity) # run suites (if we were called from test_all) or suite... - if type(suite) == type([]): + if isinstance(suite, type([])): for s in suite: testRunner.run(s) else: diff --git a/docutils/test/test_nodes.py b/docutils/test/test_nodes.py index e0c7e0da8..fe8d59903 100755 --- a/docutils/test/test_nodes.py +++ b/docutils/test/test_nodes.py @@ -121,7 +121,7 @@ class ElementTests(unittest.TestCase): self.assertEqual(repr(uelement), "<Element: <#text: 'gr\\xfcn'>>") else: self.assertEqual(repr(uelement), u"<Element: <#text: 'grün'>>") - self.assertTrue(isinstance(repr(uelement),str)) + self.assertTrue(isinstance(repr(uelement), str)) self.assertEqual(str(element), '<Element>text\nmore</Element>') self.assertEqual(str(uelement), '<Element>gr\xfcn</Element>') dom = element.asdom() -- 2.21.0 |