diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py index f87e9f60e1..674ebe19ab 100644 --- a/pylint/checkers/refactoring/refactoring_checker.py +++ b/pylint/checkers/refactoring/refactoring_checker.py @@ -21,7 +21,7 @@ from pylint import checkers from pylint.checkers import utils from pylint.checkers.utils import node_frame_class -from pylint.interfaces import Confidence, HIGH, INFERENCE +from pylint.interfaces import HIGH, INFERENCE, Confidence if TYPE_CHECKING: from pylint.lint import PyLinter @@ -2281,7 +2281,7 @@ def _enumerate_with_start( def _get_start_value(self, node: nodes.NodeNG) -> tuple[int | None, Confidence]: confidence = HIGH - if isinstance(node, nodes.Name): + if isinstance(node, (nodes.Name, nodes.Call)): inferred = utils.safe_infer(node) start_val = inferred.value if inferred else None confidence = INFERENCE diff --git a/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py b/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py index fbf0597255..e5cb135148 100644 --- a/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py +++ b/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py @@ -120,3 +120,13 @@ def process_list_again(data): for idx, val in enumerate(series, START): print(series[idx]) # [unnecessary-list-index-lookup] + +START = [1, 2, 3] +for i, k in enumerate(series, len(START)): + print(series[idx]) + +def return_start(start): + return start + +for i, k in enumerate(series, return_start(20)): + print(series[idx])