Simplify suppression of spurious 'unused-ignore's#15419
Simplify suppression of spurious 'unused-ignore's#15419ikonst wants to merge 1 commit intopython:masterfrom
Conversation
|
@ilevkivskyi since you authored #15164 |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
ilevkivskyi
left a comment
There was a problem hiding this comment.
FWIW I am not a fan of this idea: in general I try to avoid modifying parsed part of AST unless really necessary, and ignored_lines comes almost directly from parser.
Another thing, I suspect this may break daemon mode, and --warn-unused-ignores is already quite fragile/tricky in daemon mode.
|
Wouldn't (Also, WDYT about at the very least renaming |
Yes, and I think it is a bad idea, but maybe it was needed for some reason (like an alternative would be even worse).
Yes, this is a good idea. |
|
Closed in favor of #15483. |
In #15164 we've made it so that
# type: ignores in "unreachable" code are not flagged as unused.Here I'm removing the
unreachable_linesattribute (and related setters). It appears that the same effect can be achieved by pruning the lines from the existingignored_linesdict.This change also has the advantage (IMO) of directly spelling out what we're doing here. In contrast, when assigning to
unreachable_linesone 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".