summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2019-08-26 16:45:33 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2019-08-26 16:45:33 +0000
commit50aae6516c72104563f67f9766862bb5ca7b7f8f (patch)
treeceaa01bc974b42dd3bbd949f348f7fd3fac1af46
parent3ed547a1acf6d70e1120a6ff21392d25e436c112 (diff)
downloaddocutils-50aae6516c72104563f67f9766862bb5ca7b7f8f.tar.gz
Use 'isinstance(foo, bar)' instead of 'type(foo) is bar'
This one is more stylistic than anything. Signed-off-by: Stephen Finucane <stephen@that.guru> git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8359 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--docutils/docutils/parsers/rst/directives/tables.py4
-rw-r--r--docutils/docutils/parsers/rst/states.py2
-rw-r--r--docutils/docutils/statemachine.py2
-rw-r--r--docutils/docutils/utils/math/latex2mathml.py2
-rw-r--r--docutils/test/package_unittest.py4
-rwxr-xr-xdocutils/test/test_nodes.py2
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 6de44f23b..45280a69d 100644
--- a/docutils/docutils/statemachine.py
+++ b/docutils/docutils/statemachine.py
@@ -737,7 +737,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 09b9c8e02..fa6013d4c 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()