diff --git a/pycodestyle.py b/pycodestyle.py index 0d8ed50f..934f1997 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -984,7 +984,7 @@ def missing_whitespace_around_operator(logical_line, tokens): @register_check -def whitespace_around_comma(logical_line): +def whitespace_around_comma(logical_line, noqa): r"""Avoid extraneous whitespace after a comma or a colon. Note: these checks are disabled by default @@ -993,6 +993,8 @@ def whitespace_around_comma(logical_line): E241: a = (1, 2) E242: a = (1,\t2) """ + if noqa: + return line = logical_line for m in WHITESPACE_AFTER_COMMA_REGEX.finditer(line): found = m.start() + 1 diff --git a/testsuite/noqa.py b/testsuite/noqa.py index 02fdd4f8..19844db3 100644 --- a/testsuite/noqa.py +++ b/testsuite/noqa.py @@ -13,3 +13,19 @@ if a == None: # noqa pass #: + + +#: Okay +a = [ + 1, 2, 3, # noqa: E241 + 10, 20, 30 # noqa: E241 +] +#: + +# Still reported as error by default if noqa not added +#: E126 E131 E241 E241 +b = [ + 1, 2, 3, + 10, 20, 30 +] +#: