Skip to content

Commit

Permalink
Put "and" in the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
myint committed Oct 17, 2014
1 parent 322127a commit 6331373
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions autopep8.py
Expand Up @@ -295,8 +295,11 @@ def continued_indentation(logical_line, tokens, indent_level, indent_char,
yield (start, '{0} {1}'.format(*error))

# Look for visual indenting.
if (parens[row] and token_type not in (tokenize.NL, tokenize.COMMENT)
and not indent[depth]):
if (
parens[row] and
token_type not in (tokenize.NL, tokenize.COMMENT) and
not indent[depth]
):
indent[depth] = start[1]
indent_chances[start[1]] = True
# Deal with implicit string concatenation.
Expand Down Expand Up @@ -1176,9 +1179,9 @@ def fix_e265(source, aggressive=False): # pylint: disable=unused-argument
if len(line) > 1:
if (
# Leave multiple spaces like '# ' alone.
(line.count('#') > 1 or line[1].isalnum())
(line.count('#') > 1 or line[1].isalnum()) and
# Leave stylistic outlined blocks alone.
and not line.rstrip().endswith('#')
not line.rstrip().endswith('#')
):
line = '# ' + line.lstrip('# \t')

Expand Down Expand Up @@ -3053,8 +3056,10 @@ def local_fix(source, start_log, end_log,
# subset up until last_line, this assumes that the number of lines
# does not change in this multiline line.
changed_lines = len(fixed_subsource)
if (start_lines[end_log] != end_lines[end_log]
and end_lines[end_log] > last_line):
if (
start_lines[end_log] != end_lines[end_log] and
end_lines[end_log] > last_line
):
after_end = end_lines[end_log] - last_line
fixed_subsource = (fixed_subsource[:-after_end] +
source[sl][-after_end:])
Expand Down Expand Up @@ -3087,8 +3092,8 @@ def is_continued_stmt(line,
# Just blank lines, this should imply that it will become '\n' ?
return apply_global_fixes(source, options)

start_lines, indents = zip(*logical[0])
end_lines, _ = zip(*logical[1])
(start_lines, indents) = zip(*logical[0])
(end_lines, _) = zip(*logical[1])

source = source.splitlines(True)

Expand All @@ -3098,9 +3103,11 @@ def is_continued_stmt(line,
# Look behind one line, if it's indented less than current indent
# then we can move to this previous line knowing that its
# indentation level will not be changed.
if (start_log > 0
and indents[start_log - 1] < indents[start_log]
and not is_continued_stmt(source[start_log - 1])):
if (
start_log > 0 and
indents[start_log - 1] < indents[start_log] and
not is_continued_stmt(source[start_log - 1])
):
start_log -= 1
start = start_lines[start_log]

Expand Down Expand Up @@ -3133,8 +3140,10 @@ def is_continued_stmt(line,
(start_log, start) = find_ge(start_lines, start + 1)
continue

if (indents[after_end_log] == indents[start_log]
and is_continued_stmt(source[after_end])):
if (
indents[after_end_log] == indents[start_log] and
is_continued_stmt(source[after_end])
):
# Find n, the beginning of the last continued statement.
# Apply fix to previous block if there is one.
only_block = True
Expand Down

0 comments on commit 6331373

Please sign in to comment.