Update NOQA regular expression

This allows for other text after `# noqa`.

Related to #180
This commit is contained in:
Ian Cordasco 2016-07-26 06:24:04 -05:00
parent 88d9213962
commit f82b5d62d0
No known key found for this signature in database
GPG key ID: 656D3395E4A9791A
2 changed files with 4 additions and 1 deletions

View file

@ -63,7 +63,7 @@ class StyleGuide(object):
# We do not care about the ``: `` that follows ``noqa``
# We do not care about the casing of ``noqa``
# We want a comma-separated list of errors
'# noqa(?:: )?(?P<codes>[A-Z0-9,]+)?$',
'# noqa(?:: (?P<codes>[A-Z0-9,]+))?',
re.IGNORECASE
)

View file

@ -127,6 +127,9 @@ def test_should_report_error(select_list, ignore_list, error_code, expected):
('E111', 'a = 1 # noqa: E111,W123,F821', True),
('W123', 'a = 1 # noqa: E111,W123,F821', True),
('E111', 'a = 1 # noqa: E11,W123,F821', True),
('E111', 'a = 1 # noqa, analysis:ignore', True),
('E111', 'a = 1 # noqa analysis:ignore', True),
('E111', 'a = 1 # noqa - We do not care', True),
])
def test_is_inline_ignored(error_code, physical_line, expected_result):
"""Verify that we detect inline usage of ``# noqa``."""