From d7b04ae7a713412ac2882d1c6c2fce70ebb5766e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 29 Jul 2019 04:43:49 +0200 Subject: [PATCH] py: flake8 fixes --- contrib/gdb/nvim-gdb-pretty-printers.py | 4 ++-- scripts/check-includes.py | 2 -- scripts/gen_help_html.py | 2 +- scripts/gen_vimdoc.py | 15 ++++++++------- src/clint.py | 13 +++++++++---- src/nvim/testdir/test_makeencoding.py | 4 +++- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/contrib/gdb/nvim-gdb-pretty-printers.py b/contrib/gdb/nvim-gdb-pretty-printers.py index 609ceeb7ab..a6a3d90ce4 100644 --- a/contrib/gdb/nvim-gdb-pretty-printers.py +++ b/contrib/gdb/nvim-gdb-pretty-printers.py @@ -26,13 +26,13 @@ def get_color_code(bg, color_num): prefix += 1 color_num %= 8 else: - prefix = '48;5;' if bg else '38;5;' + prefix = '48;5;' if bg else '38;5;' return '\x1b[{0}{1}m'.format(prefix, color_num) def highlight(attrs): fg, bg = [int(attrs['foreground']), int(attrs['background'])] - rv = [SGR0] # start with sgr0 + rv = [SGR0] # start with sgr0 if fg != -1: rv.append(get_color_code(False, fg)) if bg != -1: diff --git a/scripts/check-includes.py b/scripts/check-includes.py index 735fb393dd..ed1fe407c5 100755 --- a/scripts/check-includes.py +++ b/scripts/check-includes.py @@ -22,8 +22,6 @@ def main(argv): args = argparser.parse_args(argv) with args.file: - include_dirs = [] - iwyu = Popen(['include-what-you-use', '-xc'] + args.iwyu_args + ['/dev/stdin'], stdin=PIPE, stdout=PIPE, stderr=PIPE) diff --git a/scripts/gen_help_html.py b/scripts/gen_help_html.py index a319cde64e..0b8e77ac22 100644 --- a/scripts/gen_help_html.py +++ b/scripts/gen_help_html.py @@ -86,7 +86,7 @@ SITENAVI_SEARCH = '
' + SITENAVI_LINKS_WEB + \ TEXTSTART = """
-
                                                                                
+
""" + (" " * 80) + """
 """
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py
index 3364a83206..edfb38e617 100755
--- a/scripts/gen_vimdoc.py
+++ b/scripts/gen_vimdoc.py
@@ -36,7 +36,6 @@ import shutil
 import textwrap
 import subprocess
 import collections
-import pprint
 
 from xml.dom import minidom
 
@@ -295,10 +294,9 @@ def render_params(parent, width=62):
         out += '{}{}\n'.format(name, desc)
     return out.rstrip()
 
-# Renders a node as Vim help text, recursively traversing all descendants.
-
 
 def render_node(n, text, prefix='', indent='', width=62):
+    """Renders a node as Vim help text, recursively traversing all descendants."""
     text = ''
     # space_preceding = (len(text) > 0 and ' ' == text[-1][-1])
     # text += (int(not space_preceding) * ' ')
@@ -322,9 +320,11 @@ def render_node(n, text, prefix='', indent='', width=62):
         text += ' [verbatim] {}'.format(get_text(n))
     elif n.nodeName == 'listitem':
         for c in n.childNodes:
-            text += indent + prefix + \
-                render_node(c, text, indent=indent +
-                            (' ' * len(prefix)), width=width)
+            text += (
+                indent
+                + prefix
+                + render_node(c, text, indent=indent + (' ' * len(prefix)), width=width)
+            )
     elif n.nodeName in ('para', 'heading'):
         for c in n.childNodes:
             text += render_node(c, text, indent=indent, width=width)
@@ -693,7 +693,8 @@ def gen_docs(config):
         for filename in CONFIG[mode]['section_order']:
             if filename not in sections:
                 raise RuntimeError(
-                    'found new module "{}"; update the "section_order" map'.format(filename))
+                    'found new module "{}"; update the "section_order" map'.format(
+                        filename))
             title, helptag, section_doc = sections.pop(filename)
             i += 1
             if filename not in CONFIG[mode]['append_only']:
diff --git a/src/clint.py b/src/clint.py
index 3994ffbb14..675b67ccef 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -2610,9 +2610,13 @@ def CheckBraces(filename, clean_lines, linenum, error):
                   'Brace starting function body must be placed on its own line')
         else:
             func_start_linenum = end_linenum + 1
-            while not clean_lines.lines[func_start_linenum] == '{':
-                attrline = Match(r'^((?!# *define).*?)(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+(?:\(\d+(, \d+)*\))?',
-                                 clean_lines.lines[func_start_linenum])
+            while not clean_lines.lines[func_start_linenum] == "{":
+                attrline = Match(
+                    r'^((?!# *define).*?)'
+                    r'(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+'
+                    r'(?:\(\d+(, \d+)*\))?',
+                    clean_lines.lines[func_start_linenum],
+                )
                 if attrline:
                     if len(attrline.group(1)) != 2:
                         error(filename, func_start_linenum,
@@ -3182,7 +3186,8 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
                        r'|li_(?:next|prev|tv))\b', line)
         if match:
             error(filename, linenum, 'runtime/deprecated', 4,
-                  'Accessing list_T internals directly is prohibited (hint: see commit d46e37cb4c71)')
+                  'Accessing list_T internals directly is prohibited '
+                  '(hint: see commit d46e37cb4c71)')
 
     # Check for suspicious usage of "if" like
     # } if (a == b) {
diff --git a/src/nvim/testdir/test_makeencoding.py b/src/nvim/testdir/test_makeencoding.py
index 041edadc0a..f6dc0f8d1c 100644
--- a/src/nvim/testdir/test_makeencoding.py
+++ b/src/nvim/testdir/test_makeencoding.py
@@ -8,6 +8,7 @@ import locale
 import io
 import sys
 
+
 def set_output_encoding(enc=None):
     """Set the encoding of stdout and stderr
 
@@ -20,7 +21,7 @@ def set_output_encoding(enc=None):
 
     def get_text_writer(fo, **kwargs):
         kw = dict(kwargs)
-        kw.setdefault('errors', 'backslashreplace') # use \uXXXX style
+        kw.setdefault('errors', 'backslashreplace')  # use \uXXXX style
         kw.setdefault('closefd', False)
 
         if sys.version_info[0] < 3:
@@ -29,6 +30,7 @@ def set_output_encoding(enc=None):
             writer = io.open(fo.fileno(), mode='w', newline='', **kw)
             write = writer.write    # save the original write() function
             enc = locale.getpreferredencoding()
+
             def convwrite(s):
                 if isinstance(s, bytes):
                     write(s.decode(enc))    # convert to unistr