From 7984fe708c7916b2f58fb6f1867025b21918b65b Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 17 Feb 2020 19:25:36 +0700 Subject: [PATCH] Fix a bug causing both W503 and W504 to be ignored --- autopep8.py | 4 ++-- test/test_autopep8.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/autopep8.py b/autopep8.py index 37e68529..b13165c0 100755 --- a/autopep8.py +++ b/autopep8.py @@ -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 ) diff --git a/test/test_autopep8.py b/test/test_autopep8.py index 0ecaba7d..42baf32b 100755 --- a/test/test_autopep8.py +++ b/test/test_autopep8.py @@ -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: