summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-05-14 19:03:24 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2020-05-14 19:04:32 +0200
commitffb354aea057c25d9e48fa22da2840a450d99f3e (patch)
tree2a75d6593a70474b5f647060a72be0d86deef0ee
parentb73afc8e3d89df143ce686c7086939710ebf29c3 (diff)
downloadpylint-git-ffb354aea057c25d9e48fa22da2840a450d99f3e.tar.gz
Fix a regression where messages with dash are not fully parsed
Close #3604
-rw-r--r--ChangeLog4
-rw-r--r--pylint/utils/pragma_parser.py2
-rw-r--r--tests/test_pragma_parser.py8
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cb53f6d0..465e372df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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"]