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 a bug causing both W503 and W504 to be ignored #525

Merged
merged 1 commit into from Mar 11, 2020
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
4 changes: 2 additions & 2 deletions autopep8.py
Expand Up @@ -3742,8 +3742,8 @@ def parse_args(arguments, apply_config=False):

if args.ignore:
args.ignore = _split_comma_separated(args.ignore)
if not all(
any(
if all(
not any(
conflicting_code.startswith(ignore_code)
for ignore_code in args.ignore
)
Expand Down
26 changes: 26 additions & 0 deletions test/test_autopep8.py
Expand Up @@ -4402,6 +4402,32 @@ def test_w503(self):
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)

def test_w503_with_ignore_w504(self):
line = '(width == 0\n + height == 0)\n'
fixed = '(width == 0 +\n height == 0)\n'
with autopep8_context(line, options=['--ignore=E,W504']) as result:
self.assertEqual(fixed, result)

def test_w504_with_ignore_w503(self):
line = '(width == 0 +\n height == 0)\n'
fixed = '(width == 0\n + height == 0)\n'
with autopep8_context(line, options=['--ignore=E,W503']) as result:
self.assertEqual(fixed, result)

def test_w503_w504_none_ignored(self):
line = '(width == 0 +\n height == 0\n+ depth == 0)\n'
fixed = '(width == 0 +\n height == 0\n+ depth == 0)\n'
with autopep8_context(line, options=['--ignore=E']) as result:
self.assertEqual(fixed, result)

def test_w503_w504_both_ignored(self):
line = '(width == 0 +\n height == 0\n+ depth == 0)\n'
fixed = '(width == 0 +\n height == 0\n+ depth == 0)\n'
with autopep8_context(
line, options=['--ignore=E,W503, W504'],
) as result:
self.assertEqual(fixed, result)

def test_w503_skip_default(self):
line = '(width == 0\n + height == 0)\n'
with autopep8_context(line) as result:
Expand Down