diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-05-14 19:03:24 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-05-14 19:04:32 +0200 |
commit | ffb354aea057c25d9e48fa22da2840a450d99f3e (patch) | |
tree | 2a75d6593a70474b5f647060a72be0d86deef0ee | |
parent | b73afc8e3d89df143ce686c7086939710ebf29c3 (diff) | |
download | pylint-git-ffb354aea057c25d9e48fa22da2840a450d99f3e.tar.gz |
Fix a regression where messages with dash are not fully parsed
Close #3604
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/utils/pragma_parser.py | 2 | ||||
-rw-r--r-- | tests/test_pragma_parser.py | 8 |
3 files changed, 13 insertions, 1 deletions
@@ -34,6 +34,10 @@ Release date: TBA Close #3612 +* Fix a regression where messages with dash are not fully parsed + + Close #3604 + What's New in Pylint 2.5.2? =========================== diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py index d2659fa44..28f04b668 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"[A-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 1aaed30d5..1e5b16b28 100644 --- a/tests/test_pragma_parser.py +++ b/tests/test_pragma_parser.py @@ -82,3 +82,11 @@ def test_missing_message(): match = OPTION_PO.search(comment) with pytest.raises(InvalidPragmaError): list(parse_pragma(match.group(2))) + + +def test_parse_message_with_dash(): + comment = "#pylint: disable = raw_input-builtin" + match = OPTION_PO.search(comment) + res = list(parse_pragma(match.group(2))) + assert res[0].action == "disable" + assert res[0].messages == ["raw_input-builtin"] |