summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-01-12 11:33:58 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2017-01-12 11:33:58 +0900
commit76ecccf8af86568cde5310638b4ac21c1aee0042 (patch)
tree11cb38b09b584f112b7266ddfa1dcb5e6a8ae8b0
parent7dcb40d135927930a3df2c10191736ae5bf975ef (diff)
downloadsphinx-git-76ecccf8af86568cde5310638b4ac21c1aee0042.tar.gz
Fix flake8 violations
-rwxr-xr-xutils/check_sources.py28
-rw-r--r--utils/jssplitter_generator.py4
-rwxr-xr-xutils/reindent.py18
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 = ['<u>', '<s>', '<strike>', '<center>', '<font']
@@ -173,7 +173,7 @@ def check_xhtml(fn, lines):
for lno, line in enumerate(lines):
for bad_tag in bad_tags:
if bad_tag in line:
- yield lno+1, "used " + bad_tag
+ yield lno + 1, "used " + bad_tag
def main(argv):
diff --git a/utils/jssplitter_generator.py b/utils/jssplitter_generator.py
index e236f00d0..078dd7591 100644
--- a/utils/jssplitter_generator.py
+++ b/utils/jssplitter_generator.py
@@ -35,8 +35,8 @@ def fold(jsonData, splitter):
lines.append(' ' + code)
break
index = code.index(splitter, 70)
- lines.append(' ' + code[:index+len(splitter)])
- code = code[index+len(splitter):]
+ lines.append(' ' + code[:index + len(splitter)])
+ code = code[index + len(splitter):]
lines[0] = lines[0][8:]
return '\n'.join(lines)
diff --git a/utils/reindent.py b/utils/reindent.py
index a4fe93e24..b79657636 100755
--- a/utils/reindent.py
+++ b/utils/reindent.py
@@ -55,9 +55,9 @@ if sys.version_info >= (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: