diff options
author | Jeremy Fleischman <jeremyfleischman@gmail.com> | 2020-06-07 22:51:23 -0700 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-06-08 07:53:42 +0200 |
commit | e0851ffe4d48b795c0bdc99346fda849e3825102 (patch) | |
tree | 33032d23e450f26a721e5032920b24dd2713d748 | |
parent | 9ba1d64096f21dd07fb658d47d378f1bc9e763fa (diff) | |
download | pylint-git-e0851ffe4d48b795c0bdc99346fda849e3825102.tar.gz |
Allow numbers in checker names. (#3667)
This fixes https://github.com/PyCQA/pylint/issues/3666.
-rw-r--r-- | CONTRIBUTORS.txt | 4 | ||||
-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, 17 insertions, 1 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 350b7d1c0..9b3c69550 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -383,3 +383,7 @@ contributors: * Andrew J. Simmons (anjsimmo): contributor * Damien Baty: contributor + +* Daniel R. Neal (danrneal): contributer + +* Jeremy Fleischman (jfly): contributer @@ -7,6 +7,10 @@ What's New in Pylint 2.5.3? Release date: TBA +* Fix a regression where disable comments that have checker names with numbers in them are not parsed correctly + + Close #3666 + * `property-with-parameters` properly handles abstract properties Close #3600 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) |