|
From: <mi...@us...> - 2022-03-04 15:55:29
|
Revision: 9024
http://sourceforge.net/p/docutils/code/9024
Author: milde
Date: 2022-03-04 15:55:26 +0000 (Fri, 04 Mar 2022)
Log Message:
-----------
Fix (some) missing blank lines
flake8 rules
E301: expected 1 blank line, found 0
E306: expected 1 blank line before a nested definition, found 0
Modified Paths:
--------------
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_settings.py
trunk/docutils/test/test_statemachine.py
trunk/docutils/test/test_writers/test_odt.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/docutils/nodes.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -283,10 +283,10 @@
# implementations that use only new-style classes, like PyPy).
if isinstance(condition, type):
node_class = condition
+
def condition(node, node_class=node_class):
return isinstance(node, node_class)
-
if include_self and (condition is None or condition(self)):
yield self
if descend and len(self.children):
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -363,8 +363,10 @@
# see `docutils.nodes.Element` for dict/list interface
def __getitem__(self, key):
return self.attributes[key]
+
def __setitem__(self, key, item):
self.attributes[key] = item
+
def get(self, *args, **kwargs):
return self.attributes.get(*args, **kwargs)
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -143,7 +143,6 @@
if not self.in_simple:
self.output.append(self.newline)
-
# specific visit and depart methods
# ---------------------------------
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -215,7 +215,7 @@
self.colspecs.append(node)
# "stubs" list is an attribute of the tgroup element:
node.parent.stubs.append(node.attributes.get('stub'))
- #
+
def depart_colspec(self, node):
# write out <colgroup> when all colspecs are processed
if isinstance(node.next_node(descend=False, siblings=True),
@@ -542,7 +542,7 @@
# html4css1 strives for IE6 compatibility.)
object_image_types = {'.svg': 'image/svg+xml',
'.swf': 'application/x-shockwave-flash'}
- #
+
def visit_image(self, node):
atts = {}
uri = node['uri']
@@ -864,7 +864,7 @@
# hard-coded vertical alignment
def visit_tbody(self, node):
self.body.append(self.starttag(node, 'tbody', valign='top'))
- #
+
def depart_tbody(self, node):
self.body.append('</tbody>\n')
@@ -880,7 +880,7 @@
# hard-coded vertical alignment
def visit_thead(self, node):
self.body.append(self.starttag(node, 'thead', valign='bottom'))
- #
+
def depart_thead(self, node):
self.body.append('</thead>\n')
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -158,6 +158,7 @@
# use HTML block-level tags if matching class value found
supported_block_tags = {'ins', 'del'}
+
def visit_container(self, node):
# If there is exactly one of the "supported block tags" in
# the list of class values, use it as tag name:
@@ -175,7 +176,6 @@
def depart_container(self, node):
self.body.append('</%s>\n' % node.html5tagname)
-
# no standard meta tag name in HTML5, use dcterms.rights
# see https://wiki.whatwg.org/wiki/MetaExtensions
def visit_copyright(self, node):
@@ -310,8 +310,9 @@
supported_inline_tags = {'code', 'kbd', 'dfn', 'samp', 'var',
'bdi', 'del', 'ins', 'mark', 'small',
'b', 'i', 'q', 's', 'u'}
+
+ # Use `supported_inline_tags` if found in class values
def visit_inline(self, node):
- # Use `supported_inline_tags` if found in class values
classes = node['classes']
tags = [cls for cls in self.supported_inline_tags
if cls in classes]
@@ -389,6 +390,7 @@
node['xml:lang'] = node['lang']
meta = self.emptytag(node, 'meta', **node.non_default_attributes())
self.add_meta(meta)
+
def depart_meta(self, node):
pass
@@ -395,6 +397,7 @@
# no standard meta tag name in HTML5
def visit_organization(self, node):
self.visit_docinfo_item(node, 'organization', meta=False)
+
def depart_organization(self, node):
self.depart_docinfo_item()
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -3057,6 +3057,7 @@
pass
_thead_depth = 0
+
def thead_depth(self):
return self._thead_depth
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/docutils/writers/manpage.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -113,11 +113,14 @@
self._options = ['center']
self._tab_char = '\t'
self._coldefs = []
+
def new_row(self):
self._rows.append([])
+
def append_separator(self, separator):
"""Append the separator for table head."""
self._rows.append([separator])
+
def append_cell(self, cell_lines):
"""cell_lines is an array of lines"""
start = 0
@@ -126,6 +129,7 @@
self._rows[-1].append(cell_lines[start:])
if len(self._coldefs) < len(self._rows[-1]):
self._coldefs.append('l')
+
def _minimize_cell(self, cell_lines):
"""Remove leading and trailing blank and ``.sp`` lines"""
while cell_lines and cell_lines[0] in ('\n', '.sp\n'):
@@ -132,6 +136,7 @@
del cell_lines[0]
while cell_lines and cell_lines[-1] in ('\n', '.sp\n'):
del cell_lines[-1]
+
def as_list(self):
text = ['.TS\n']
text.append(' '.join(self._options) + ';\n')
@@ -349,6 +354,7 @@
def get_width(self):
return self._indent
+
def __repr__(self):
return 'enum_style-%s' % list(self._style)
Modified: trunk/docutils/test/test_settings.py
===================================================================
--- trunk/docutils/test/test_settings.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/test/test_settings.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -282,6 +282,7 @@
('no', False),
('false', False),
)
+
def test_validate_boolean(self):
for t in self.boolean_settings:
self.assertEqual(
Modified: trunk/docutils/test/test_statemachine.py
===================================================================
--- trunk/docutils/test/test_statemachine.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/test/test_statemachine.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -271,6 +271,7 @@
s2l_string = "hello\tthere\thow are\tyou?\n\tI'm fine\tthanks.\n"
s2l_expected = ['hello there how are you?',
" I'm fine thanks."]
+
def test_string2lines(self):
self.assertEqual(statemachine.string2lines(self.s2l_string),
self.s2l_expected)
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/test/test_writers/test_odt.py 2022-03-04 15:55:26 UTC (rev 9024)
@@ -172,6 +172,7 @@
def test_odt_footnotes(self):
self.process_test('odt_footnotes.txt', 'odt_footnotes.odt',
save_output_name='odt_footnotes.odt')
+
def test_odt_raw(self):
self.process_test('odt_raw.txt', 'odt_raw.odt',
save_output_name='odt_raw.odt')
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-04 15:55:13 UTC (rev 9023)
+++ trunk/docutils/tox.ini 2022-03-04 15:55:26 UTC (rev 9024)
@@ -38,11 +38,9 @@
# whitespace around the operators with the lowest priority(ies).
# Use your own judgment; …"
- E301, # expected 1 blank line, found 0
E302, # expected 2 blank lines, found 1
E303, # too many blank lines (N)
E305, # expected 2 blank lines after class or function definition, found 1
- E306, # expected 1 blank line before a nested definition, found 0
E401, # multiple imports on one line
E402, # module level import not at top of file
E501, # line too long (N > 79 characters)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|