pylint
pylint copied to clipboard
Pylint should warn when global private variable (starting with ``_``) are unused
Is your feature request related to a problem? Please describe
For a module defined like:
FOO = 'abc'
_BAR = 'xyz'
it would be great if pylint had an option to ignore the fact that FOO is unused, since it is "public", but still alert that _BAR is unused, since it is private to the module
Describe the solution you'd like
Would an additional configuration option for allow-global-unused-variables make sense? I'd like to have pylint let me know about unused global variables that it would consider protected, since in that case there's a higher chance the variable is truly unused.
@nmarrow Yes, this sounds like a good idea. A separate option would be preferred.
it would be great if pylint had an option to ignore the fact that FOO is unused
Isn't this already the case? If I understood this correctly, the new checker here must flag _BAR as unused.
Right now pylint does not warn for any of those.
So unused-protected-global seems like a new good checker here. But what about private globals? Should we check for both _BOO and __BOO?
I think both are nice. _BOO can be a protected variable at the package level, I think the check would be costly (we have to check the whole repo for each global ?), Doesn't sound like something you want to launch all the time. The unused-private-global-variable is probably the most value / computation here and could be launched all the time.