diff options
Diffstat (limited to 'pylint/checkers/refactoring/refactoring_checker.py')
-rw-r--r-- | pylint/checkers/refactoring/refactoring_checker.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py index ec4d3d71e..890b0e64d 100644 --- a/pylint/checkers/refactoring/refactoring_checker.py +++ b/pylint/checkers/refactoring/refactoring_checker.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt from __future__ import annotations @@ -98,7 +98,7 @@ def _is_trailing_comma(tokens: list[tokenize.TokenInfo], index: int) -> bool: if token.exact_type != tokenize.COMMA: return False # Must have remaining tokens on the same line such as NEWLINE - left_tokens = list(itertools.islice(tokens, index + 1, None)) + left_tokens = itertools.islice(tokens, index + 1, None) more_tokens_on_line = False for remaining_token in left_tokens: @@ -644,9 +644,10 @@ class RefactoringChecker(checkers.BaseTokenChecker): # token[2] is the actual position and also is # reported by IronPython. self._elifs.extend([token[2], tokens[index + 1][2]]) - elif _is_trailing_comma(tokens, index): - if self.linter.is_message_enabled("trailing-comma-tuple"): - self.add_message("trailing-comma-tuple", line=token.start[0]) + elif self.linter.is_message_enabled( + "trailing-comma-tuple" + ) and _is_trailing_comma(tokens, index): + self.add_message("trailing-comma-tuple", line=token.start[0]) @utils.only_required_for_messages("consider-using-with") def leave_module(self, _: nodes.Module) -> None: @@ -1060,8 +1061,8 @@ class RefactoringChecker(checkers.BaseTokenChecker): def _check_consider_using_generator(self, node: nodes.Call) -> None: # 'any', 'all', definitely should use generator, while 'list', 'tuple', # 'sum', 'max', and 'min' need to be considered first - # See https://github.com/PyCQA/pylint/pull/3309#discussion_r576683109 - # https://github.com/PyCQA/pylint/pull/6595#issuecomment-1125704244 + # See https://github.com/pylint-dev/pylint/pull/3309#discussion_r576683109 + # https://github.com/pylint-dev/pylint/pull/6595#issuecomment-1125704244 # and https://peps.python.org/pep-0289/ checked_call = ["any", "all", "sum", "max", "min", "list", "tuple"] if ( @@ -1175,7 +1176,7 @@ class RefactoringChecker(checkers.BaseTokenChecker): if len(node.args) == 0: # handle case when builtin.next is called without args. - # see https://github.com/PyCQA/pylint/issues/7828 + # see https://github.com/pylint-dev/pylint/issues/7828 return inferred = utils.safe_infer(node.func) |