Skip to content

Commit

Permalink
Merge pull request #350 from hhatto/fix-issue-338
Browse files Browse the repository at this point in the history
Fix issue 338
  • Loading branch information
hhatto committed Oct 10, 2017
2 parents c13cf86 + 2e411b0 commit 7aaf921
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def fix_e702(self, result, logical):
# Avoid applying this when indented.
# https://docs.python.org/reference/compound_stmts.html
for line in logical_lines:
if ':' in line:
if ':' in line and STARTSWITH_DEF_REGEX.match(line):
return []

line_index = result['line'] - 1
Expand Down
3 changes: 2 additions & 1 deletion test/suite/out/E70.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
#: E703
import shlex
#: E702 E703
del a[:]; a.append(42);
del a[:]
a.append(42)
#:
16 changes: 16 additions & 0 deletions test/test_autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -3725,6 +3725,22 @@ def test_e702_with_semicolon_after_string(self):
fixed = """\
raise IOError('abc '
'def.')
"""
with autopep8_context(line) as result:
self.assertEqual(fixed, result)

def test_e702_with_dict_semicolon(self):
line = """\
MY_CONST = [
{'A': 1},
{'B': 2}
];
"""
fixed = """\
MY_CONST = [
{'A': 1},
{'B': 2}
]
"""
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
Expand Down

0 comments on commit 7aaf921

Please sign in to comment.