From 2eaa3976009855e0b14fac639f256d7346fc8a81 Mon Sep 17 00:00:00 2001 From: Francis Charette Migneault Date: Thu, 13 May 2021 16:19:26 -0400 Subject: [PATCH] add support of E241 ignore by noqa comment inline --- pycodestyle.py | 4 +++- testsuite/noqa.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pycodestyle.py b/pycodestyle.py index 0d8ed50fa..934f1997b 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 02fdd4f82..19844db3e 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 +] +#: