Repository navigation
Conversation
`Generator[()]` gives a Tuple slice with no elements. The guard in visit_subscript checks `all(... for el in node.slice.elts[1:])`, which is vacuously true for an empty list, so the suggestion built immediately after indexed `node.slice.elts[0]` and raised IndexError. Require a non-empty slice. Single-element subscripts like `Generator[int]` were already excluded, since those produce a Name slice rather than a Tuple, so the empty tuple was the only reachable case. Closes pylint-dev#11357
Member
|
Thank you for working on pylint, this is already fixed in #11375 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Changes
Description
Closes #11357
Generator[()]gives aTupleslice with no elements. The guard checksall(... for el in node.slice.elts[1:]), which is vacuously true for an emptylist, so the suggestion built immediately after indexes
node.slice.elts[0]andraises
IndexError.Single-element subscripts like
Generator[int]produce aNameslice rather than aTuple, so the empty tuple is the only reachable case — a non-empty check is thecomplete fix.
Testing
ca.Generator[()]/ca.AsyncGenerator[()]to the existingunnecessary_default_type_argsfunctional test; it fails withIndexErrorwhenthe fix is reverted
Generator[int, None, None]correctly