Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: e265, e266 #663

Merged
merged 1 commit into from Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion autopep8.py
Expand Up @@ -3330,7 +3330,7 @@ def filter_results(source, results, aggressive):
continue

if r['line'] in commented_out_code_line_numbers:
if issue_id.startswith(('e26', 'e501')):
if issue_id.startswith(('e261', 'e262', 'e501')):
continue

# Do not touch indentation if there is a token error caused by
Expand Down
23 changes: 20 additions & 3 deletions test/test_autopep8.py
Expand Up @@ -271,7 +271,7 @@ def test_format_block_comments_should_only_touch_real_comments(self):
commented_out_code = '#x = 1'
self.assertEqual(
commented_out_code,
fix_e265_and_e266(commented_out_code))
fix_e266(commented_out_code))

def test_fix_file(self):
self.assertIn(
Expand Down Expand Up @@ -2238,6 +2238,12 @@ def test_e265_only(self):
with autopep8_context(line, options=['--select=E265']) as result:
self.assertEqual(fixed, result)

def test_e265_issue662(self):
line = "#print(\" \")\n"
fixed = "# print(\" \")\n"
with autopep8_context(line, options=['--select=E265']) as result:
self.assertEqual(fixed, result)

def test_ignore_e265(self):
line = "## A comment\n#B comment\n123\n"
fixed = "# A comment\n#B comment\n123\n"
Expand All @@ -2256,6 +2262,12 @@ def test_e266_only(self):
with autopep8_context(line, options=['--select=E266']) as result:
self.assertEqual(fixed, result)

def test_e266_issue662(self):
line = "## comment\n"
fixed = "# comment\n"
with autopep8_context(line) as result:
self.assertEqual(fixed, result)

def test_ignore_e266(self):
line = "##A comment\n#B comment\n123\n"
fixed = "## A comment\n# B comment\n123\n"
Expand Down Expand Up @@ -3167,7 +3179,7 @@ def test_e501_with_comment(self):
# http://foo.bar/abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-

# The following is ugly commented-out code and should not be touched.
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
"""
with autopep8_context(line, options=['--aggressive']) as result:
self.assertEqual(fixed, result)
Expand Down Expand Up @@ -6442,7 +6454,7 @@ def test_e501_experimental_with_comment(self):
# http://foo.bar/abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-abc-

# The following is ugly commented-out code and should not be touched.
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1
"""
with autopep8_context(line, options=['--experimental',
'--aggressive']) as result:
Expand Down Expand Up @@ -7287,6 +7299,11 @@ def test_e501_experimental_with_in(self):
self.assertEqual(fixed, result)


def fix_e266(source):
with autopep8_context(source, options=['--select=E266']) as result:
return result


def fix_e265_and_e266(source):
with autopep8_context(source, options=['--select=E265,E266']) as result:
return result
Expand Down