diff options
author | Jeremy Fleischman <jeremyfleischman@gmail.com> | 2020-06-07 22:51:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 07:51:23 +0200 |
commit | fe0a7f7953430f10308d2ba94c14f056e166fe1c (patch) | |
tree | 53537bbf5aa91f50d033a8619eb261c0e224ef2e | |
parent | 627d07d249d17c12ed9e1a52044843607a5353d0 (diff) | |
download | pylint-git-fe0a7f7953430f10308d2ba94c14f056e166fe1c.tar.gz |
Allow numbers in checker names. (#3667)
This fixes https://github.com/PyCQA/pylint/issues/3666.
-rw-r--r-- | CONTRIBUTORS.txt | 2 | ||||
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/utils/pragma_parser.py | 2 | ||||
-rw-r--r-- | tests/test_pragma_parser.py | 8 |
4 files changed, 15 insertions, 1 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 4dc47f901..9b3c69550 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -385,3 +385,5 @@ contributors: * Damien Baty: contributor * Daniel R. Neal (danrneal): contributer + +* Jeremy Fleischman (jfly): contributer @@ -6,6 +6,10 @@ What's New in Pylint 2.6.0? =========================== Release date: TBA +* Fix a regression where disable comments that have checker names with numbers in them are not parsed correctly + + Close #3666 + * bad-continuation and bad-whitespace have been removed, black or another formatter can help you with this better than Pylint Close #246, #289, #638, #747, #1148, #1179, #1943, #2041, #2301, #2304, #2944, #3565 diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py index 28f04b668..2afbae5a3 100644 --- a/pylint/utils/pragma_parser.py +++ b/pylint/utils/pragma_parser.py @@ -39,7 +39,7 @@ ALL_KEYWORDS = "|".join( TOKEN_SPECIFICATION = [ ("KEYWORD", r"\b({:s})\b".format(ALL_KEYWORDS)), - ("MESSAGE_STRING", r"[A-Za-z\-\_]{2,}"), # Identifiers + ("MESSAGE_STRING", r"[0-9A-Za-z\-\_]{2,}"), # Identifiers ("ASSIGN", r"="), # Assignment operator ("MESSAGE_NUMBER", r"[CREIWF]{1}\d*"), ] diff --git a/tests/test_pragma_parser.py b/tests/test_pragma_parser.py index 1e5b16b28..0dec8ac88 100644 --- a/tests/test_pragma_parser.py +++ b/tests/test_pragma_parser.py @@ -16,6 +16,14 @@ def test_simple_pragma(): assert pragma_repr.messages == ["missing-docstring"] +def test_disable_checker_with_number_in_name(): + comment = "#pylint: disable = j3-custom-checker" + match = OPTION_PO.search(comment) + for pragma_repr in parse_pragma(match.group(2)): + assert pragma_repr.action == "disable" + assert pragma_repr.messages == ["j3-custom-checker"] + + def test_simple_pragma_no_messages(): comment = "#pylint: skip-file" match = OPTION_PO.search(comment) |