From 76ecccf8af86568cde5310638b4ac21c1aee0042 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 12 Jan 2017 11:33:58 +0900 Subject: [PATCH] Fix flake8 violations --- utils/check_sources.py | 28 ++++++++++++++-------------- utils/jssplitter_generator.py | 4 ++-- utils/reindent.py | 18 +++++++++--------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/utils/check_sources.py b/utils/check_sources.py index 18d444057..066ed8881 100755 --- a/utils/check_sources.py +++ b/utils/check_sources.py @@ -34,7 +34,7 @@ def checker(*suffixes, **kwds): # this one is a byte regex since it is applied before decoding -coding_re = re.compile(br'coding[:=]\s*([-\w.]+)') +coding_re = re.compile(br'coding[:=]\s*([-\w.]+)') uni_coding_re = re.compile(r'^#.*coding[:=]\s*([-\w.]+).*') name_mail_re = r'[\w ]+(<.*?>)?' @@ -44,8 +44,8 @@ copyright_re = re.compile(r'^ :copyright: Copyright 200\d(-20\d\d)? ' license_re = re.compile(r" :license: (.*?).\n") copyright_2_re = re.compile(r'^ %s(, %s)*[,.]$' % (name_mail_re, name_mail_re)) -not_ix_re = re.compile(r'\bnot\s+\S+?\s+i[sn]\s\S+') -is_const_re = re.compile(r'if.*?==\s+(None|False|True)\b') +not_ix_re = re.compile(r'\bnot\s+\S+?\s+i[sn]\s\S+') +is_const_re = re.compile(r'if.*?==\s+(None|False|True)\b') misspellings = ["developement", "adress", # ALLOW-MISSPELLING "verificate", "informations"] # ALLOW-MISSPELLING @@ -63,7 +63,7 @@ def decode_source(fn, lines): decoded_lines.append(line.decode(encoding)) except UnicodeDecodeError as err: raise UnicodeError("%s:%d: not decodable: %s\n Line: %r" % - (fn, lno+1, err, line)) + (fn, lno + 1, err, line)) except LookupError as err: raise LookupError("unknown encoding: %s" % encoding) return decoded_lines @@ -82,14 +82,14 @@ def check_syntax(fn, lines): def check_style(fn, lines): for lno, line in enumerate(lines): if len(line.rstrip('\n')) > 95: - yield lno+1, "line too long" + yield lno + 1, "line too long" if line.strip().startswith('#'): continue # m = not_ix_re.search(line) # if m: # yield lno+1, '"' + m.group() + '"' if is_const_re.search(line): - yield lno+1, 'using == None/True/False' + yield lno + 1, 'using == None/True/False' @checker('.py', only_pkg=True) @@ -116,11 +116,11 @@ def check_fileheader(fn, lines): if l == '"""\n': # end of docstring if lno <= 4: - yield lno+c, "missing module name in docstring" + yield lno + c, "missing module name in docstring" break if l != '\n' and l[:4] != ' ' and docopen: - yield lno+c, "missing correct docstring indentation" + yield lno + c, "missing correct docstring indentation" if lno == 2: # if not in package, don't check the module name @@ -145,10 +145,10 @@ def check_fileheader(fn, lines): yield 0, "no correct license info" ci = -3 - copyright = llist[ci:ci+1] + copyright = llist[ci:ci + 1] while copyright and copyright_2_re.match(copyright[0]): ci -= 1 - copyright = llist[ci:ci+1] + copyright = llist[ci:ci + 1] if not copyright or not copyright_re.match(copyright[0]): yield 0, "no correct copyright info" @@ -157,12 +157,12 @@ def check_fileheader(fn, lines): def check_whitespace_and_spelling(fn, lines): for lno, line in enumerate(lines): if '\t' in line: - yield lno+1, "OMG TABS!!!1 " + yield lno + 1, "OMG TABS!!!1 " if line[:-1].rstrip(' \t') != line[:-1]: - yield lno+1, "trailing whitespace" + yield lno + 1, "trailing whitespace" for word in misspellings: if word in line and 'ALLOW-MISSPELLING' not in line: - yield lno+1, '"%s" used' % word + yield lno + 1, '"%s" used' % word bad_tags = ['', '', '', '
', '= (3, 0): else: tokens = tokenize.tokenize -verbose = 0 -recurse = 0 -dryrun = 0 +verbose = 0 +recurse = 0 +dryrun = 0 makebackup = True @@ -160,7 +160,7 @@ def _rstrip(line, JUNK='\n \t'): """ i = len(line) - while i > 0 and line[i-1] in JUNK: + while i > 0 and line[i - 1] in JUNK: i -= 1 return line[:i] @@ -204,9 +204,9 @@ class Reindenter: # we see a line with *something* on it. i = stats[0][0] after.extend(lines[1:i]) - for i in range(len(stats)-1): + for i in range(len(stats) - 1): thisstmt, thislevel = stats[i] - nextstmt = stats[i+1][0] + nextstmt = stats[i + 1][0] have = getlspace(lines[thisstmt]) want = thislevel * 4 if want < 0: @@ -218,7 +218,7 @@ class Reindenter: want = have2want.get(have, -1) if want < 0: # Then it probably belongs to the next real stmt. - for j in range(i+1, len(stats)-1): + for j in range(i + 1, len(stats) - 1): jline, jlevel = stats[j] if jlevel >= 0: if have == getlspace(lines[jline]): @@ -228,10 +228,10 @@ class Reindenter: # comment like this one, # in which case we should shift it like its base # line got shifted. - for j in range(i-1, -1, -1): + for j in range(i - 1, -1, -1): jline, jlevel = stats[j] if jlevel >= 0: - want = (have + getlspace(after[jline-1]) - + want = (have + getlspace(after[jline - 1]) - getlspace(lines[jline])) break if want < 0: