Skip to content

Commit e0851ff

Browse files
jflyPCManticore
authored andcommitted
Allow numbers in checker names. (#3667)
This fixes #3666.
1 parent 9ba1d64 commit e0851ff

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

CONTRIBUTORS.txt

+4
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,7 @@ contributors:
383383
* Andrew J. Simmons (anjsimmo): contributor
384384

385385
* Damien Baty: contributor
386+
387+
* Daniel R. Neal (danrneal): contributer
388+
389+
* Jeremy Fleischman (jfly): contributer

ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ What's New in Pylint 2.5.3?
77

88
Release date: TBA
99

10+
* Fix a regression where disable comments that have checker names with numbers in them are not parsed correctly
11+
12+
Close #3666
13+
1014
* `property-with-parameters` properly handles abstract properties
1115

1216
Close #3600

pylint/utils/pragma_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
TOKEN_SPECIFICATION = [
4141
("KEYWORD", r"\b({:s})\b".format(ALL_KEYWORDS)),
42-
("MESSAGE_STRING", r"[A-Za-z\-\_]{2,}"), #  Identifiers
42+
("MESSAGE_STRING", r"[0-9A-Za-z\-\_]{2,}"), #  Identifiers
4343
("ASSIGN", r"="), #  Assignment operator
4444
("MESSAGE_NUMBER", r"[CREIWF]{1}\d*"),
4545
]

tests/test_pragma_parser.py

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ def test_simple_pragma():
1616
assert pragma_repr.messages == ["missing-docstring"]
1717

1818

19+
def test_disable_checker_with_number_in_name():
20+
comment = "#pylint: disable = j3-custom-checker"
21+
match = OPTION_PO.search(comment)
22+
for pragma_repr in parse_pragma(match.group(2)):
23+
assert pragma_repr.action == "disable"
24+
assert pragma_repr.messages == ["j3-custom-checker"]
25+
26+
1927
def test_simple_pragma_no_messages():
2028
comment = "#pylint: skip-file"
2129
match = OPTION_PO.search(comment)

0 commit comments

Comments
 (0)