Skip to content

Commit

Permalink
Merge pull request #525 from NovaDev94/master
Browse files Browse the repository at this point in the history
Fix a bug causing both W503 and W504 to be ignored
  • Loading branch information
hhatto committed Mar 11, 2020
2 parents fded37b + 7984fe7 commit ef15dd5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
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

0 comments on commit ef15dd5

Please sign in to comment.