Merge branch 'patch-1' into 'master'

Identify error codes with more than one letter in noqa-flags correctly

Closes #549

See merge request pycqa/flake8!326
This commit is contained in:
Anthony Sottile 2019-06-16 17:17:46 +00:00
commit 076dfeee37
2 changed files with 4 additions and 1 deletions

View file

@ -36,7 +36,7 @@ NOQA_INLINE_REGEXP = re.compile(
# We do not care about the casing of ``noqa``
# We want a comma-separated list of errors
# https://regex101.com/r/4XUuax/2 full explenation of the regex
r"# noqa(?::[\s]?(?P<codes>([A-Z][0-9]+(?:[,\s]+)?)+))?",
r"# noqa(?::[\s]?(?P<codes>([A-Z]+[0-9]+(?:[,\s]+)?)+))?",
re.IGNORECASE,
)

View file

@ -23,6 +23,9 @@ from flake8 import style_guide
('E111', 'a = 1 # noqa - We do not care', True),
('E111', 'a = 1 # noqa: We do not care', True),
('E111', 'a = 1 # noqa:We do not care', True),
('ABC123', 'a = 1 # noqa: ABC123', True),
('E111', 'a = 1 # noqa: ABC123', False),
('ABC123', 'a = 1 # noqa: ABC124', False),
])
def test_is_inline_ignored(error_code, physical_line, expected_result):
"""Verify that we detect inline usage of ``# noqa``."""