Closed avylove closed 3 months ago
Although this is an interesting idea I don't think it is feasible and would make our already overly complicated disable
logic even more complicated.
If we were to redesign it from scratch I would definitely take it into consideration and if you're using ruff
I'd recommend explaining this use case in https://github.com/astral-sh/ruff/issues/3711 as it seems their issue of generating feedback about disables.
We have a somewhat related issue to add reasoning in disables https://github.com/pylint-dev/pylint/issues/5253
Current problem
With the introduction of
possibly-used-before-assignment
we've seen some errors come up in existing code. They are all cases where the code imports different libraries depending on if it is running on Windows or *nix. The guards in these cases are not direct. In one case, the Windows code is subclassed and in another the code isI don't expect Pylint to figure out every case, but the current implementation only provides two options: disable the check universally or disable the check in-line. Of course there are some cases the code could be refactored, but that's not always possible or practical. In either case, one could easily mask legitimate issues.
Desired solution
Disable the check in-line for specific variables This may look something like this:
In this case, for this line
possibly-used-before-assignment
is ignored fortermios
, but not forfd
I believe this also introduces a new general capability, i.e. the ability to fine tune in-line disables. This seems very useful as a general purpose capability, thought, without being familiar with the code, I can't be sure how difficult this would be to implement.
Additional context
No response