Skip to content

Commit

Permalink
Fix a regression where messages with dash are not fully parsed
Browse files Browse the repository at this point in the history
Close #3604
  • Loading branch information
PCManticore committed May 14, 2020
1 parent b73afc8 commit ffb354a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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?
===========================
Expand Down
2 changes: 1 addition & 1 deletion pylint/utils/pragma_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

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*"),
]
Expand Down
8 changes: 8 additions & 0 deletions tests/test_pragma_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit ffb354a

Please sign in to comment.