You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 is
I 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:
if not IS_WINDOWS:
import termios
...
if not IS_WINDOWS:
attrs = termios.tcgetattr(fd) # pylint: disable=possibly-used-before-assignment(termios)
In this case, for this line possibly-used-before-assignment is ignored for termios, but not for fd
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
The text was updated successfully, but these errors were encountered:
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 astral-sh/ruff#3711 as it seems their issue of generating feedback about disables.
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
The text was updated successfully, but these errors were encountered: