|
From: <mi...@us...> - 2022-01-26 19:04:05
|
Revision: 8976
http://sourceforge.net/p/docutils/code/8976
Author: milde
Date: 2022-01-26 19:04:01 +0000 (Wed, 26 Jan 2022)
Log Message:
-----------
Remove redundant parentheses
Patch by Adam Turner.
Modified Paths:
--------------
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/parsers/recommonmark_wrapper.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/parsers/rst/tableparser.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/references.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/utils/code_analyzer.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_writers/test_html4css1_misc.py
trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
trunk/docutils/tools/test/test_buildhtml.py
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/frontend.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -311,7 +311,7 @@
other_dict = other_dict.__dict__
other_dict = other_dict.copy()
for setting in option_parser.lists.keys():
- if (hasattr(self, setting) and setting in other_dict):
+ if hasattr(self, setting) and setting in other_dict:
value = getattr(self, setting)
if value:
value += other_dict[setting]
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/io.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -337,7 +337,7 @@
raise InputError(error.errno, error.strerror, source_path)
else:
self.source = sys.stdin
- elif (check_encoding(self.source, self.encoding) is False):
+ elif check_encoding(self.source, self.encoding) is False:
# TODO: re-open, warn or raise error?
raise UnicodeError('Encoding clash: encoding given is "%s" '
'but source is opened with encoding "%s".' %
Modified: trunk/docutils/docutils/parsers/recommonmark_wrapper.py
===================================================================
--- trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -40,7 +40,7 @@
# already cached in `sys.modules` if recommonmark >= 0.5.0
except ImportError:
# stub to prevent errors with recommonmark < 0.5.0
- class addnodes():
+ class addnodes:
pending_xref = nodes.pending
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -318,7 +318,7 @@
return [
self.state_machine.reporter.error(
'Error in "%s" directive: may contain a single paragraph '
- 'only.' % (self.name), line=self.lineno) ]
+ 'only.' % self.name, line=self.lineno)]
if node:
return messages + node.children
return messages
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/parsers/rst/states.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -713,7 +713,7 @@
matchstart = match.start('start')
matchend = match.end('start')
if self.quoted_start(match):
- return (string[:matchend], [], string[matchend:], [], '')
+ return string[:matchend], [], string[matchend:], [], ''
endmatch = end_pattern.search(string[matchend:])
if endmatch and endmatch.start(1): # 1 or more chars
text = endmatch.string[:endmatch.start(1)]
@@ -760,7 +760,7 @@
role = role[1:-1]
position = 'prefix'
elif self.quoted_start(match):
- return (string[:matchend], [], string[matchend:], [])
+ return string[:matchend], [], string[matchend:], []
endmatch = end_pattern.search(string[matchend:])
if endmatch and endmatch.start(1): # 1 or more chars
textend = matchend + endmatch.end()
@@ -966,7 +966,7 @@
self.document.note_footnote_ref(refnode)
if utils.get_trim_footnote_ref_space(self.document.settings):
before = before.rstrip()
- return (before, [refnode], remaining, [])
+ return before, [refnode], remaining, []
def reference(self, match, lineno, anonymous=False):
referencename = match.group('refname')
@@ -983,7 +983,7 @@
string = match.string
matchstart = match.start('whole')
matchend = match.end('whole')
- return (string[:matchstart], [referencenode], string[matchend:], [])
+ return string[:matchstart], [referencenode], string[matchend:], []
def anonymous_reference(self, match, lineno):
return self.reference(match, lineno, anonymous=True)
@@ -1231,7 +1231,7 @@
else:
blank = i
else:
- return (indented, None, None, None, None)
+ return indented, None, None, None, None
def check_attribution(self, indented, attribution_start):
"""
@@ -2206,7 +2206,7 @@
arguments = []
if content and not has_content:
raise MarkupError('no content permitted')
- return (arguments, options, content, content_offset)
+ return arguments, options, content, content_offset
def parse_directive_options(self, option_presets, option_spec, arg_block):
options = option_presets.copy()
@@ -2266,11 +2266,11 @@
try:
options = utils.extract_extension_options(node, option_spec)
except KeyError as detail:
- return 0, ('unknown option: "%s"' % detail.args[0])
+ return 0, 'unknown option: "%s"' % detail.args[0]
except (ValueError, TypeError) as detail:
return 0, ('invalid option value: %s' % ' '.join(detail.args))
except utils.ExtensionOptionError as detail:
- return 0, ('invalid option data: %s' % ' '.join(detail.args))
+ return 0, 'invalid option data: %s' % ' '.join(detail.args)
if blank_finish:
return 1, options
else:
Modified: trunk/docutils/docutils/parsers/rst/tableparser.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/tableparser.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/parsers/rst/tableparser.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -320,7 +320,7 @@
else:
headrows = []
bodyrows = rows
- return (colspecs, headrows, bodyrows)
+ return colspecs, headrows, bodyrows
class SimpleTableParser(TableParser):
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/statemachine.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -371,16 +371,16 @@
try:
src, srcoffset = self.input_lines.info(offset)
srcline = srcoffset + 1
- except (TypeError):
+ except TypeError:
# line is None if index is "Just past the end"
src, srcline = self.get_source_and_line(offset + self.input_offset)
return src, srcline + 1
- except (IndexError): # `offset` is off the list
+ except IndexError: # `offset` is off the list
src, srcline = None, None
# raise AssertionError('cannot find line %d in %s lines' %
# (offset, len(self.input_lines)))
# # list(self.input_lines.lines())))
- return (src, srcline)
+ return src, srcline
def insert_input(self, input_lines, source):
self.input_lines.insert(self.line_offset + 1, '',
@@ -710,7 +710,7 @@
except AttributeError:
raise TransitionMethodNotFound(
'%s.%s' % (self.__class__.__name__, name))
- return (pattern, method, next_state)
+ return pattern, method, next_state
def make_transitions(self, name_list):
"""
@@ -1307,7 +1307,7 @@
def xitems(self):
"""Return iterator yielding (source, offset, value) tuples."""
for (value, (source, offset)) in zip(self.data, self.items):
- yield (source, offset, value)
+ yield source, offset, value
def pprint(self):
"""Print the list in `grep` format (`source:offset:value` lines)"""
Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/transforms/references.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -688,7 +688,7 @@
if len(subdef.astext()) > line_length_limit:
msg = self.document.reporter.error(
'Substitution definition "%s" exceeds the'
- ' line-length-limit.' % (key))
+ ' line-length-limit.' % key)
if msg:
msgid = self.document.set_id(msg)
prb = nodes.problematic(
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/transforms/universal.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -259,12 +259,12 @@
for node in txtnodes:
if (isinstance(node.parent, self.literal_nodes)
or isinstance(node.parent.parent, self.literal_nodes)):
- yield ('literal', str(node))
+ yield 'literal', str(node)
else:
# SmartQuotes uses backslash escapes instead of null-escapes
# Insert backslashes before escaped "active" characters.
txt = re.sub('(?<=\x00)([-\\\'".`])', r'\\\1', str(node))
- yield ('plain', txt)
+ yield 'plain', txt
def apply(self):
smart_quotes = self.document.settings.setdefault('smart_quotes',
Modified: trunk/docutils/docutils/utils/code_analyzer.py
===================================================================
--- trunk/docutils/docutils/utils/code_analyzer.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/utils/code_analyzer.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -82,18 +82,18 @@
if ttype is lasttype:
lastval += value
else:
- yield(lasttype, lastval)
+ yield lasttype, lastval
(lasttype, lastval) = (ttype, value)
if lastval.endswith('\n'):
lastval = lastval[:-1]
if lastval:
- yield(lasttype, lastval)
+ yield lasttype, lastval
def __iter__(self):
"""Parse self.code and yield "classified" tokens.
"""
if self.lexer is None:
- yield ([], self.code)
+ yield [], self.code
return
tokens = pygments.lex(self.code, self.lexer)
for tokentype, value in self.merge(tokens):
@@ -102,7 +102,7 @@
else: # short CSS class args
classes = [_get_ttype_class(tokentype)]
classes = [cls for cls in classes if cls not in unstyled_tokens]
- yield (classes, value)
+ yield classes, value
class NumberLines(object):
@@ -126,11 +126,11 @@
def __iter__(self):
lineno = self.startline
- yield (['ln'], self.fmt_str % lineno)
+ yield ['ln'], self.fmt_str % lineno
for ttype, value in self.tokens:
lines = value.split('\n')
for line in lines[:-1]:
- yield (ttype, line + '\n')
+ yield ttype, line + '\n'
lineno += 1
- yield (['ln'], self.fmt_str % lineno)
- yield (ttype, lines[-1])
+ yield ['ln'], self.fmt_str % lineno
+ yield ttype, lines[-1]
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/utils/error_reporting.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -183,7 +183,7 @@
"""
if stream is None:
stream = sys.stderr
- elif not(stream):
+ elif not stream:
stream = False
# if `stream` is a file name, open it
elif isinstance(stream, str):
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/utils/math/math2html.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -1930,7 +1930,7 @@
"Traverse a formula and yield a flattened structure of (bit, list) pairs."
for element in bit.contents:
if hasattr(element, 'type') and element.type:
- yield (element, bit.contents)
+ yield element, bit.contents
elif isinstance(element, FormulaBit):
yield from self.traverse(element)
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/utils/smartquotes.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -895,15 +895,15 @@
previous_end = 0
while token_match is not None:
if token_match.group(1):
- yield ('text', token_match.group(1))
+ yield 'text', token_match.group(1)
- yield ('tag', token_match.group(2))
+ yield 'tag', token_match.group(2)
previous_end = token_match.end()
token_match = tag_soup.search(text, token_match.end())
if previous_end < len(text):
- yield ('text', text[previous_end:])
+ yield 'text', text[previous_end:]
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -769,7 +769,7 @@
def visit_docinfo(self, node):
self.context.append(len(self.body))
classes = ['docinfo']
- if (self.is_compactable(node)):
+ if self.is_compactable(node):
classes.append('simple')
self.body.append(self.starttag(node, 'dl', classes=classes))
@@ -885,7 +885,7 @@
classes.pop(i)
break
classes.append('field-list')
- if (self.is_compactable(node)):
+ if self.is_compactable(node):
classes.append('simple')
self.body.append(self.starttag(node, 'dl', **atts))
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -328,7 +328,7 @@
if (node.html5tagname == 'small' and node.get('classes') == ['ln']
and isinstance(node.parent, nodes.literal_block)):
self.body.append('<code data-lineno="%s">' % node.astext())
- del(node.html5tagname)
+ del node.html5tagname
# place inside HTML5 <figcaption> element (together with caption)
def visit_legend(self, node):
@@ -434,7 +434,7 @@
def depart_topic(self, node):
self.body.append('</%s>\n'%node.html_tagname)
- del(node.html_tagname)
+ del node.html_tagname
# append self-link
def section_title_tags(self, node):
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -888,7 +888,7 @@
def get_latex_type(self):
if self._latex_type == 'longtable' and not self.caption:
# do not advance the "table" counter (requires "ltcaption" package)
- return('longtable*')
+ return 'longtable*'
return self._latex_type
def set(self, attr, value):
@@ -1060,7 +1060,7 @@
res = [' \\\\\n']
self._cell_in_row = None # remove cell counter
for i in range(len(self._rowspan)):
- if (self._rowspan[i]>0):
+ if self._rowspan[i] > 0:
self._rowspan[i] -= 1
if self.borders == 'standard':
@@ -1664,7 +1664,7 @@
return ''
if isinstance(child, (nodes.container, nodes.compound)):
return self.term_postfix(child)
- if isinstance(child, (nodes.image)):
+ if isinstance(child, nodes.image):
return '\\leavevmode\n' # Images get an additional newline.
if not isinstance(child, (nodes.paragraph, nodes.math_block)):
return '\\leavevmode'
@@ -3113,7 +3113,7 @@
% roman.toRoman(level))
# System messages heading in red:
- if ('system-messages' in node.parent['classes']):
+ if 'system-messages' in node.parent['classes']:
self.requirements['color'] = PreambleCmds.color
section_title = self.encode(node.astext())
self.out.append(r'\%s[%s]{\color{red}' % (
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -1433,14 +1433,14 @@
if mo:
pos2 = mo.start()
if pos2 > pos1:
- yield (ODFTranslator.code_text, text[pos1:pos2])
- yield (ODFTranslator.code_field, mo.group(1))
+ yield ODFTranslator.code_text, text[pos1:pos2]
+ yield ODFTranslator.code_field, mo.group(1)
pos1 = mo.end()
else:
break
trailing = text[pos1:]
if trailing:
- yield (ODFTranslator.code_text, trailing)
+ yield ODFTranslator.code_text, trailing
def astext(self):
root = self.content_tree.getroot()
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/test/test_error_reporting.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -241,7 +241,7 @@
document = utils.new_document('test data', settings)
def test_include(self):
- source = ('.. include:: bogus.txt')
+ source = '.. include:: bogus.txt'
self.assertRaises(utils.SystemMessage,
self.parser.parse, source, self.document)
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/test/test_io.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -215,7 +215,7 @@
self.udata.encode('latin1'))
def test_encoding_clash_nonresolvable(self):
- del(self.mock_stdout.buffer)
+ del self.mock_stdout.buffer
fo = io.FileOutput(destination=self.mock_stdout,
encoding='latin1', autoclose=False)
self.assertRaises(ValueError, fo.write, self.udata)
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/test/test_language.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -102,7 +102,7 @@
for label in l_dict.keys():
if label not in ref_dict:
too_much.append(label)
- return (missing, too_much)
+ return missing, too_much
def _invert(self, adict):
"""Return an inverted (keys & values swapped) dictionary."""
Modified: trunk/docutils/test/test_writers/test_html4css1_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_misc.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/test/test_writers/test_html4css1_misc.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -143,7 +143,7 @@
mathjax_script = '<script type="text/javascript" src="%s">'
default_mathjax_url = ('file:/usr/share/javascript/mathjax/MathJax.js'
'?config=TeX-AMS_CHTML')
- custom_mathjax_url = ('/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML')
+ custom_mathjax_url = '/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
data = ':math:`42`'
def test_math_output_default(self):
Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -158,7 +158,7 @@
mathjax_script = '<script type="text/javascript" src="%s">'
default_mathjax_url = ('file:/usr/share/javascript/mathjax/MathJax.js'
'?config=TeX-AMS_CHTML')
- custom_mathjax_url = ('/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML')
+ custom_mathjax_url = '/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
data = ':math:`42`'
def test_math_output_default(self):
Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -27,7 +27,7 @@
settings_default_overrides = HtmlWriterPublishPartsTestCase.settings_default_overrides.copy()
settings_default_overrides['section_self_link'] = True
- standard_content_type_template = ('<meta charset="%s"/>\n')
+ standard_content_type_template = '<meta charset="%s"/>\n'
standard_generator_template = ('<meta name="generator"'
' content="Docutils %s: https://docutils.sourceforge.io/" />\n')
standard_viewport_template = ('<meta name="viewport"'
Modified: trunk/docutils/tools/test/test_buildhtml.py
===================================================================
--- trunk/docutils/tools/test/test_buildhtml.py 2022-01-26 19:03:43 UTC (rev 8975)
+++ trunk/docutils/tools/test/test_buildhtml.py 2022-01-26 19:04:01 UTC (rev 8976)
@@ -54,7 +54,7 @@
cin.close()
cout.close()
p.wait()
- return (dirs, files)
+ return dirs, files
class BuildHtmlTests(unittest.TestCase):
tree = ( "_tmp_test_tree",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|