pylint
pylint copied to clipboard
Respect warnings disablement or provide .pylintrc file controls
Current problem
Code being linted has a number of Python (not pylint) warnings disablements. For example:
warnings.filterwarnings("ignore", category=UserWarning, module="_distutils_hack")
pylint ignores these. Understandably so, because it uses astroid to produce an AST of the source rather than actually importing the modules under analysis, and thus doesn't explicitly pay any attention to these module-global calls.
It is possible to silence these warnings by setting the PYTHONWARNINGS envirosym ahead of launching pylint. However, this either requires setting that symbol globally in someplace like .bashrc, entering it (a very long string) manually ahead of each pylint shell command, or always wrapping the pylint launch within a shell script. Not ideal options, any of these.
Suggestion: to respect warnings configurations in the code-under-analysis, either do pay attention to warnings module method calls at global scope and replicate these (difficult/problematic), or add some means of configuring Python warnings in the .pylintrc file (easy). pytest took the latter approach, and allows:
[pytest] filterwarnings= ...
in their pytest.ini config file.
Granted, root cause is in setuptools (and in other packages), loudly shrieking at every opportunity about deprecations that have been in effect for a decade or more and will likely be for another decade, and for which there're no decent alternatives. But being able to control this in .pylintrc would be a nice solution.
Desired solution
Without being able to squelch warnings, "clean" pylint runs (10.00 out of 10.00 score) are littered with uggo diagnostic messages. It would be desired to be able to configure these away.
Additional context
No response