From 87406b43ead3cab3eea4806307c7c381d8200fea Mon Sep 17 00:00:00 2001 From: Peter Law Date: Mon, 22 Dec 2025 14:25:28 +0000 Subject: [PATCH] Fix iter example in usafe fixes doc (#22118) ## Summary This appears to have been a copy/paste error from the list example, as the subscript is not present in the original next/iter example only in the case where the error case is shown. While in the specific example code the subscript actually has no effect, it does make the example slightly confusing. Consider the following variations, first the example from the docs unchanged and second the same code but not hitting the intended error case (due to using a non-empty collection): ```console $ python3 -c 'next(iter(range(0)))[0]' Traceback (most recent call last): File "", line 1, in StopIteration $ python3 -c 'next(iter(range(1)))[0]' Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not subscriptable ``` ## Test Plan Not directly tested, however see inline snippets above. --- docs/linter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/linter.md b/docs/linter.md index 6d009e243d..d1e762c652 100644 --- a/docs/linter.md +++ b/docs/linter.md @@ -188,7 +188,7 @@ IndexError: list index out of range ``` ```console -$ python -c 'next(iter(range(0)))[0]' +$ python -c 'next(iter(range(0)))' Traceback (most recent call last): File "", line 1, in StopIteration