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 Jun 8, 2020
1 parent 627d07d commit fe0a7f7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,5 @@ contributors:
* 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 @@ -6,6 +6,10 @@ What's New in Pylint 2.6.0?
===========================
Release date: TBA

* Fix a regression where disable comments that have checker names with numbers in them are not parsed correctly

Close #3666

* bad-continuation and bad-whitespace have been removed, black or another formatter can help you with this better than Pylint

Close #246, #289, #638, #747, #1148, #1179, #1943, #2041, #2301, #2304, #2944, #3565
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 fe0a7f7

Please sign in to comment.