Skip to content

Commit

Permalink
Allow numbers in checker names. (#3667)
Browse files Browse the repository at this point in the history
This fixes #3666.
  • Loading branch information
jfly authored and PCManticore committed Jun 8, 2020
1 parent 9ba1d64 commit e0851ff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,7 @@ contributors:
* Andrew J. Simmons (anjsimmo): contributor

* Damien Baty: contributor

* Daniel R. Neal (danrneal): contributer

* Jeremy Fleischman (jfly): contributer
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"[0-9A-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 @@ -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)
Expand Down

0 comments on commit e0851ff

Please sign in to comment.