Simplify suppression of spurious 'unused-ignore's #15419
Closed
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.
In #15164 we've made it so that
# type: ignore
s in "unreachable" code are not flagged as unused.Here I'm removing the
unreachable_lines
attribute (and related setters). It appears that the same effect can be achieved by pruning the lines from the existingignored_lines
dict.This change also has the advantage (IMO) of directly spelling out what we're doing here. In contrast, when assigning to
unreachable_lines
one has to follow the code to determine what it's being used for. And yes, it's more open-ended to keep "unreachable_lines" but then (a) it's not so simple because not all "unreachabilities" are the same, (b) unused open-end is unwarranted complexity.Motivation
While looking at #12409, it became clear to me that the term "unreachable" became somewhat overloaded:
IMO it would be helpful to disambiguate and I suggest we stop referring to the latter as "reachability".