Skip to content

Commit

Permalink
Merge branch 'patch-1' into 'master'
Browse files Browse the repository at this point in the history
Identify error codes with more than one letter in noqa-flags correctly

Closes #549

See merge request pycqa/flake8!326
  • Loading branch information
asottile committed Jun 16, 2019
2 parents 2f8bc64 + 37964db commit 076dfee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/flake8/defaults.py
Expand Up @@ -36,7 +36,7 @@
# 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,
)

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_violation.py
Expand Up @@ -23,6 +23,9 @@
('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``."""
Expand Down

0 comments on commit 076dfee

Please sign in to comment.