mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-09 14:24:17 +00:00
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:
commit
076dfeee37
2 changed files with 4 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ NOQA_INLINE_REGEXP = re.compile(
|
||||||
# We do not care about the casing of ``noqa``
|
# We do not care about the casing of ``noqa``
|
||||||
# We want a comma-separated list of errors
|
# We want a comma-separated list of errors
|
||||||
# https://regex101.com/r/4XUuax/2 full explenation of the regex
|
# 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,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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),
|
('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):
|
def test_is_inline_ignored(error_code, physical_line, expected_result):
|
||||||
"""Verify that we detect inline usage of ``# noqa``."""
|
"""Verify that we detect inline usage of ``# noqa``."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue