|
From: <mi...@us...> - 2019-08-26 16:45:35
|
Revision: 8359
http://sourceforge.net/p/docutils/code/8359
Author: milde
Date: 2019-08-26 16:45:33 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
Use 'isinstance(foo, bar)' instead of 'type(foo) is bar'
This one is more stylistic than anything.
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/test/package_unittest.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -104,7 +104,7 @@
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 @@
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):
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -447,7 +447,7 @@
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)
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -737,7 +737,7 @@
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:
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -168,7 +168,7 @@
self.children = []
if children is not None:
- if type(children) is list:
+ if isinstance(children, list):
for child in children:
self.append(child)
else:
Modified: trunk/docutils/test/package_unittest.py
===================================================================
--- trunk/docutils/test/package_unittest.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/test/package_unittest.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -115,7 +115,7 @@
# 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 @@
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:
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/test/test_nodes.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -121,7 +121,7 @@
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()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|