From c4dedb0b6faeedf38b845383bb5e3676b45181d7 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 20 Dec 2025 20:59:02 +0000 Subject: [PATCH] Fix iter example in usafe fixes doc 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 ``` --- docs/linter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/linter.md b/docs/linter.md index 6d009e243d4f34..d1e762c6526465 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