|
From: <mi...@us...> - 2022-03-03 22:15:03
|
Revision: 9015
http://sourceforge.net/p/docutils/code/9015
Author: milde
Date: 2022-03-03 22:15:00 +0000 (Thu, 03 Mar 2022)
Log Message:
-----------
Fix whitespace before/after delimiters and colon.
Flake rules
E201 whitespace after '('
E202 whitespace before '}'
E203 whitespace before ':'
E211 whitespace before '('
Exception: : as binary operator in extended slices
(cf. https://www.python.org/dev/peps/pep-0008/#pet-peeves).
Modified Paths:
--------------
trunk/docutils/docutils/languages/he.py
trunk/docutils/docutils/languages/sv.py
trunk/docutils/docutils/parsers/rst/languages/he.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/parts.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/docutils/writers/odf_odt/pygmentsformatter.py
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/test/test_parsers/test_rst/test_tables.py
trunk/docutils/test/test_settings.py
trunk/docutils/test/test_transforms/test_doctitle.py
trunk/docutils/test/test_writers/test_html4css1_parts.py
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
trunk/docutils/tools/quicktest.py
trunk/docutils/tools/test/test_buildhtml.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/languages/he.py
===================================================================
--- trunk/docutils/docutils/languages/he.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/languages/he.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -30,7 +30,7 @@
'attention': '\u05ea\u05e9\u05d5\u05de\u05ea \u05dc\u05d1',
'caution': '\u05d6\u05d4\u05d9\u05e8\u05d5\u05ea',
'danger': '\u05e1\u05db\u05e0\u05d4',
- 'error': '\u05e9\u05d2\u05d9\u05d0\u05d4' ,
+ 'error': '\u05e9\u05d2\u05d9\u05d0\u05d4',
'hint': '\u05e8\u05de\u05d6',
'important': '\u05d7\u05e9\u05d5\u05d1',
'note': '\u05d4\u05e2\u05e8\u05d4',
Modified: trunk/docutils/docutils/languages/sv.py
===================================================================
--- trunk/docutils/docutils/languages/sv.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/languages/sv.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -35,7 +35,7 @@
'note': 'Notera',
'tip': 'Tips',
'warning': 'Varning',
- 'contents': 'Innehåll' }
+ 'contents': 'Innehåll'}
"""Mapping of node class name to label text."""
bibliographic_fields = {
@@ -51,7 +51,7 @@
'datum': 'date',
'copyright': 'copyright',
'dedikation': 'dedication',
- 'sammanfattning': 'abstract' }
+ 'sammanfattning': 'abstract'}
"""Swedish (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ',']
Modified: trunk/docutils/docutils/parsers/rst/languages/he.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/languages/he.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/parsers/rst/languages/he.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -21,7 +21,7 @@
'\u05d6\u05d4\u05d9\u05e8\u05d5\u05ea': 'caution',
'code (translation required)': 'code',
'\u05e1\u05db\u05e0\u05d4': 'danger',
- '\u05e9\u05d2\u05d9\u05d0\u05d4' : 'error',
+ '\u05e9\u05d2\u05d9\u05d0\u05d4': 'error',
'\u05e8\u05de\u05d6': 'hint',
'\u05d7\u05e9\u05d5\u05d1': 'important',
'\u05d4\u05e2\u05e8\u05d4': 'note',
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/parsers/rst/states.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -1356,8 +1356,8 @@
break # yes; keep `format`
else: # shouldn't happen
raise ParserError('enumerator format not matched')
- text = groupdict[format][self.enum.formatinfo[format].start
- :self.enum.formatinfo[format].end]
+ text = groupdict[format][self.enum.formatinfo[format].start # noqa: E203
+ : self.enum.formatinfo[format].end]
if text == '#':
sequence = '#'
elif expected_sequence:
@@ -1408,8 +1408,8 @@
if result:
next_enumerator, auto_enumerator = result
try:
- if ( next_line.startswith(next_enumerator) or
- next_line.startswith(auto_enumerator) ):
+ if (next_line.startswith(next_enumerator)
+ or next_line.startswith(auto_enumerator)):
return 1
except TypeError:
pass
@@ -2135,7 +2135,7 @@
) = self.state_machine.get_first_known_indented(match.end(),
strip_top=0)
block_text = '\n'.join(self.state_machine.input_lines[
- initial_line_offset : self.state_machine.line_offset + 1])
+ initial_line_offset : self.state_machine.line_offset + 1]) # noqa: E203
try:
arguments, options, content, content_offset = (
self.parse_directive_block(indented, line_offset,
@@ -2554,11 +2554,11 @@
"""Enumerated list item."""
format, sequence, text, ordinal = self.parse_enumerator(
match, self.parent['enumtype'])
- if ( format != self.format
- or (sequence != '#' and (sequence != self.parent['enumtype']
- or self.auto
- or ordinal != (self.lastordinal + 1)))
- or not self.is_enumerated_list_item(ordinal, sequence, format)):
+ if (format != self.format
+ or (sequence != '#' and (sequence != self.parent['enumtype']
+ or self.auto
+ or ordinal != (self.lastordinal + 1)))
+ or not self.is_enumerated_list_item(ordinal, sequence, format)):
# different enumeration: new list
self.invalid_input()
if sequence == '#':
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/statemachine.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -1144,8 +1144,9 @@
self.items[i.start:i.stop] = item.items
assert len(self.data) == len(self.items), 'data mismatch'
if self.parent:
- self.parent[(i.start or 0) + self.parent_offset
- : (i.stop or len(self)) + self.parent_offset] = item
+ k = (i.start or 0) + self.parent_offset
+ l = (i.stop or len(self)) + self.parent_offset
+ self.parent[k:l] = item
else:
self.data[i] = item
if self.parent:
@@ -1162,8 +1163,9 @@
del self.data[i.start:i.stop]
del self.items[i.start:i.stop]
if self.parent:
- del self.parent[(i.start or 0) + self.parent_offset
- : (i.stop or len(self)) + self.parent_offset]
+ k = (i.start or 0) + self.parent_offset
+ l = (i.stop or len(self)) + self.parent_offset
+ del self.parent[k:l]
def __add__(self, other):
if isinstance(other, ViewList):
Modified: trunk/docutils/docutils/transforms/parts.py
===================================================================
--- trunk/docutils/docutils/transforms/parts.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/transforms/parts.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -128,8 +128,8 @@
suggested_prefix='toc-entry')
entry = nodes.paragraph('', '', reference)
item = nodes.list_item('', entry)
- if ( self.backlinks in ('entry', 'top')
- and title.next_node(nodes.reference) is None):
+ if (self.backlinks in ('entry', 'top')
+ and title.next_node(nodes.reference) is None):
if self.backlinks == 'entry':
title['refid'] = ref_id
elif self.backlinks == 'top':
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/utils/math/math2html.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -1301,7 +1301,7 @@
"Extract the next string of the given length, or None if not enough text."
if self.pos + length > len(self.text):
return None
- return self.text[self.pos : self.pos + length]
+ return self.text[self.pos : self.pos + length] # noqa: E203
class Container:
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -1414,8 +1414,8 @@
atts = {'class': 'reference'}
if 'refuri' in node:
atts['href'] = node['refuri']
- if ( self.settings.cloak_email_addresses
- and atts['href'].startswith('mailto:')):
+ if (self.settings.cloak_email_addresses
+ and atts['href'].startswith('mailto:')):
atts['href'] = self.cloak_mailto(atts['href'])
self.in_mailto = True
atts['class'] += ' external'
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -458,8 +458,8 @@
atts['class'] = 'docinfo-name'
else:
atts['class'] = 'field-name'
- if ( self.settings.field_name_limit
- and len(node.astext()) > self.settings.field_name_limit):
+ if (self.settings.field_name_limit
+ and len(node.astext()) > self.settings.field_name_limit):
atts['colspan'] = 2
self.context.append('</tr>\n'
+ self.starttag(node.parent, 'tr', '',
@@ -674,8 +674,8 @@
# use table for option list
def visit_option_group(self, node):
atts = {}
- if ( self.settings.option_limit
- and len(node.astext()) > self.settings.option_limit):
+ if (self.settings.option_limit
+ and len(node.astext()) > self.settings.option_limit):
atts['colspan'] = 2
self.context.append('</tr>\n<tr><td> </td>')
else:
@@ -733,9 +733,9 @@
return False
parent_length = len([n for n in node.parent if not isinstance(
n, (nodes.Invisible, nodes.label))])
- if ( self.compact_simple
- or self.compact_field_list
- or self.compact_p and parent_length == 1):
+ if (self.compact_simple
+ or self.compact_field_list
+ or self.compact_p and parent_length == 1):
return True
return False
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -3054,7 +3054,7 @@
pass
_thead_depth = 0
- def thead_depth (self):
+ def thead_depth(self):
return self._thead_depth
def visit_thead(self, node):
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -2840,11 +2840,11 @@
self.in_paragraph = False
self.set_to_parent()
if self.in_header:
- self.header_content.append( self.current_element[-1] )
- self.current_element.remove( self.current_element[-1] )
+ self.header_content.append(self.current_element[-1])
+ self.current_element.remove(self.current_element[-1])
elif self.in_footer:
- self.footer_content.append( self.current_element[-1] )
- self.current_element.remove( self.current_element[-1] )
+ self.footer_content.append(self.current_element[-1])
+ self.current_element.remove(self.current_element[-1])
def visit_problematic(self, node):
pass
Modified: trunk/docutils/docutils/writers/odf_odt/pygmentsformatter.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/pygmentsformatter.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/writers/odf_odt/pygmentsformatter.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -19,7 +19,7 @@
self.rststyle_function = rststyle_function
self.escape_function = escape_function
- def rststyle(self, name, parameters=( )):
+ def rststyle(self, name, parameters=()):
return self.rststyle_function(name, parameters)
Modified: trunk/docutils/docutils/writers/s5_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/s5_html/__init__.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/docutils/writers/s5_html/__init__.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -207,8 +207,8 @@
for f in os.listdir(path): # copy all files from each theme
if f == self.base_theme_file:
continue # ... except the "__base__" file
- if ( self.copy_file(f, path, dest)
- and f in self.required_theme_files):
+ if (self.copy_file(f, path, dest)
+ and f in self.required_theme_files):
required_files_copied[f] = 1
if default:
break # "default" theme has no base theme
Modified: trunk/docutils/test/test_parsers/test_rst/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_tables.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/test/test_parsers/test_rst/test_tables.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -571,7 +571,7 @@
| (The first cell of this table may expand |
| to accommodate long filesystem paths.) |
+------------------------------------------------------------------------------+
-""") % ('\n'.join('| %-70s |' % include2[part * 70 : (part + 1) * 70]
+""") % ('\n'.join('| %-70s |' % include2[part * 70 : (part + 1) * 70] # noqa: E203
for part in range(len(include2) // 70 + 1))),
"""\
<document source="test data">
@@ -606,7 +606,7 @@
Something afterwards.
And more.
-""") % ('\n'.join('| %-70s |' % include2[part * 70 : (part + 1) * 70]
+""") % ('\n'.join('| %-70s |' % include2[part * 70 : (part + 1) * 70] # noqa: E203
for part in range(len(include2) // 70 + 1))),
"""\
<document source="test data">
@@ -1274,7 +1274,7 @@
Note The first row of this table may expand
to accommodate long filesystem paths.
========= =====================================================================
-""" % ('\n'.join(' %-65s' % include2[part * 65 : (part + 1) * 65]
+""" % ('\n'.join(' %-65s' % include2[part * 65 : (part + 1) * 65] # noqa: E203
for part in range(len(include2) // 65 + 1))),
"""\
<document source="test data">
Modified: trunk/docutils/test/test_settings.py
===================================================================
--- trunk/docutils/test/test_settings.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/test/test_settings.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -272,15 +272,15 @@
self.assertEqual(pathdict['spam'], 'spam')
boolean_settings = (
- (True, True ),
- ('1', True ),
- ('on', True ),
- ('yes', True ),
- ('true', True ),
- ('0', False ),
- ('off', False ),
- ('no', False ),
- ('false', False ),
+ (True, True),
+ ('1', True),
+ ('on', True),
+ ('yes', True),
+ ('true', True),
+ ('0', False),
+ ('off', False),
+ ('no', False),
+ ('false', False),
)
def test_validate_boolean(self):
for t in self.boolean_settings:
@@ -300,10 +300,10 @@
def test_validate_colon_separated_string_list(self):
tests = (
- ('a', ['a',] ),
- ('a:b', ['a', 'b'] ),
- (['a',], ['a',] ),
- (['a', 'b:c'], ['a', 'b', 'c'] ),
+ ('a', ['a',]),
+ ('a:b', ['a', 'b']),
+ (['a',], ['a',]),
+ (['a', 'b:c'], ['a', 'b', 'c']),
)
for t in tests:
self.assertEqual(
@@ -312,10 +312,10 @@
def test_validate_comma_separated_list(self):
tests = (
- ('a', ['a',] ),
- ('a,b', ['a', 'b'] ),
- (['a',], ['a',] ),
- (['a', 'b,c'], ['a', 'b', 'c'] ),
+ ('a', ['a',]),
+ ('a,b', ['a', 'b']),
+ (['a',], ['a',]),
+ (['a', 'b,c'], ['a', 'b', 'c']),
)
for t in tests:
self.assertEqual(
@@ -324,10 +324,10 @@
def test_validate_url_trailing_slash(self):
tests = (
- ('', './' ),
- (None, './' ),
- ('http://example.org', 'http://example.org/' ),
- ('http://example.org/', 'http://example.org/' ),
+ ('', './'),
+ (None, './'),
+ ('http://example.org', 'http://example.org/'),
+ ('http://example.org/', 'http://example.org/'),
)
for t in tests:
self.assertEqual(
Modified: trunk/docutils/test/test_transforms/test_doctitle.py
===================================================================
--- trunk/docutils/test/test_transforms/test_doctitle.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/test/test_transforms/test_doctitle.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -21,7 +21,7 @@
required_arguments = 0
optional_arguments = 0
final_argument_whitespace = True
- option_spec = { }
+ option_spec = {}
has_content = False
def run(self):
Modified: trunk/docutils/test/test_writers/test_html4css1_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_parts.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/test/test_writers/test_html4css1_parts.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -197,7 +197,7 @@
"""]
])
-totest['No title promotion'] = ({'doctitle_xform' : 0,
+totest['No title promotion'] = ({'doctitle_xform': 0,
'stylesheet_path': '',
'embed_stylesheet': 0}, [
["""\
Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -205,7 +205,7 @@
"""]
])
-totest['No title promotion'] = ({'doctitle_xform' : 0,
+totest['No title promotion'] = ({'doctitle_xform': 0,
'stylesheet_path': '',
'embed_stylesheet': 0}, [
["""\
Modified: trunk/docutils/tools/quicktest.py
===================================================================
--- trunk/docutils/tools/quicktest.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/tools/quicktest.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -96,7 +96,7 @@
%s
%s],
]
-""" % ( tq, escape(input.rstrip()), tq, tq, escape(output.rstrip()), tq )
+""" % (tq, escape(input.rstrip()), tq, tq, escape(output.rstrip()), tq)
def escape(text):
"""
@@ -111,7 +111,7 @@
'rawxml': _rawxml,
'styledxml': _styledxml,
'xml': _prettyxml,
- 'pretty' : _pretty,
+ 'pretty': _pretty,
'test': _test}
def format(outputFormat, input, document, optargs):
Modified: trunk/docutils/tools/test/test_buildhtml.py
===================================================================
--- trunk/docutils/tools/test/test_buildhtml.py 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/tools/test/test_buildhtml.py 2022-03-03 22:15:00 UTC (rev 9015)
@@ -57,19 +57,19 @@
return dirs, files
class BuildHtmlTests(unittest.TestCase):
- tree = ( "_tmp_test_tree",
- "_tmp_test_tree/one.txt",
- "_tmp_test_tree/two.txt",
- "_tmp_test_tree/dir1",
- "_tmp_test_tree/dir1/one.txt",
- "_tmp_test_tree/dir1/two.txt",
- "_tmp_test_tree/dir2",
- "_tmp_test_tree/dir2/one.txt",
- "_tmp_test_tree/dir2/two.txt",
- "_tmp_test_tree/dir2/sub",
- "_tmp_test_tree/dir2/sub/one.txt",
- "_tmp_test_tree/dir2/sub/two.txt",
- )
+ tree = ("_tmp_test_tree",
+ "_tmp_test_tree/one.txt",
+ "_tmp_test_tree/two.txt",
+ "_tmp_test_tree/dir1",
+ "_tmp_test_tree/dir1/one.txt",
+ "_tmp_test_tree/dir1/two.txt",
+ "_tmp_test_tree/dir2",
+ "_tmp_test_tree/dir2/one.txt",
+ "_tmp_test_tree/dir2/two.txt",
+ "_tmp_test_tree/dir2/sub",
+ "_tmp_test_tree/dir2/sub/one.txt",
+ "_tmp_test_tree/dir2/sub/two.txt",
+ )
def setUp(self):
self.root = tempfile.mkdtemp()
@@ -94,14 +94,14 @@
def test_1(self):
opts = ["--dry-run", self.root]
- dirs, files = process_and_return_filelist( opts )
+ dirs, files = process_and_return_filelist(opts)
self.assertEqual(files.count("one.txt"), 4)
def test_local(self):
opts = ["--dry-run", "--local", self.root]
- dirs, files = process_and_return_filelist( opts )
- self.assertEqual( len(dirs), 1)
- self.assertEqual( files, [])
+ dirs, files = process_and_return_filelist(opts)
+ self.assertEqual(len(dirs), 1)
+ self.assertEqual(files, [])
if __name__ == '__main__':
unittest.main()
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-03 22:14:41 UTC (rev 9014)
+++ trunk/docutils/tox.ini 2022-03-03 22:15:00 UTC (rev 9015)
@@ -31,10 +31,6 @@
E129, # visually indented line with same indent as next logical line
# allowed by PEP8
- E201, # whitespace after '('
- E202, # whitespace before '}'
- E203, # whitespace before ':'
- E211, # whitespace before '('
E221, # multiple spaces before operator
E222, # multiple spaces after operator
E225, # missing whitespace around operator
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|