Skip to content

Commit 4dd9da9

Browse files
[trailing-comma-tuple] Handle case with space between 'enable' and '='
1 parent 865d57c commit 4dd9da9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pylint/checkers/refactoring/refactoring_checker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,11 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
660660
not trailing_comma_tuple_enabled_once
661661
and token_string.startswith("#")
662662
# We have at least 1 '#' (one char) at the start of the token
663-
and all(c in token_string[1:] for c in ("pylint:", "enable="))
664-
# We have at least '#' 'pylint' / 'enable' (15 chars) at the start of the token
663+
and "pylint:" in token_string[1:]
664+
# We have at least '#' 'pylint' (8 chars) at the start of the token
665+
and "enable" in token_string[8:]
666+
# We have at least '#', 'pylint', ( + ':'), 'enable' (+ '=') (15 chars)
667+
# at the start of the token
665668
and any(
666669
c in token_string[15:] for c in ("trailing-comma-tuple", "R1707")
667670
)

tests/functional/t/trailing_comma_tuple_9608.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def some_func(first, second):
1313
return (first, second,)
1414
return first, second,
1515

16-
# pylint: enable=trailing-comma-tuple
16+
#pylint:enable = trailing-comma-tuple
1717
AAA = 1, # [trailing-comma-tuple]
1818
BBB = "aaaa", # [trailing-comma-tuple]
1919
# pylint: disable=trailing-comma-tuple

0 commit comments

Comments
 (0)