Skip to content

Commit

Permalink
Merge branch 'master' into Hanaasagi-fix-parse-incomplete-code-when-f…
Browse files Browse the repository at this point in the history
…ix-e402
  • Loading branch information
hhatto committed Aug 11, 2019
2 parents 62feb87 + 2b18159 commit 4038184
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -2,7 +2,6 @@ language: python

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "pypy"
Expand Down
13 changes: 13 additions & 0 deletions autopep8.py
Expand Up @@ -646,6 +646,19 @@ def fix_e116(self, result):

self.source[line_index] = indent[1:] + stripped

def fix_e117(self, result):
"""Fix over-indented."""
line_index = result['line'] - 1
target = self.source[line_index]

indent = _get_indentation(target)
if indent == '\t':
return []

stripped = target.lstrip()

self.source[line_index] = indent[1:] + stripped

def fix_e125(self, result):
"""Fix indentation undistinguish from the next logical line."""
num_indent_spaces = int(result['info'].split()[1])
Expand Down
20 changes: 18 additions & 2 deletions test/test_autopep8.py
Expand Up @@ -1029,8 +1029,8 @@ def test_e101_with_comments(self):
"""
fixed = """\
while True: # My inline comment
# with a hanging
# comment.
# with a hanging
# comment.
# Hello
if True:
# My comment
Expand Down Expand Up @@ -1229,6 +1229,22 @@ def test_e116(self):
fixed = """\
a = 1
# b = 2
"""
with autopep8_context(line) as result:
self.assertEqual(fixed, result)

def test_e117(self):
line = """\
for a in [1, 2, 3]:
print('hello world')
for b in [1, 2, 3]:
print(a, b)
"""
fixed = """\
for a in [1, 2, 3]:
print('hello world')
for b in [1, 2, 3]:
print(a, b)
"""
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
Expand Down

0 comments on commit 4038184

Please sign in to comment.