There is no warning function in warnings, so the advice would break the code. It seems to be misrecognizing the statement as a logger. If there's enough context in the linter's representation of the code (like, if you have a good AST with some inference?), warnings here is a fairly obvious import of the warnings module; could perhaps those get excepted as not loggers?
The AST doesn't have that level of detail as far as I can tell. I added a simple name check, which feels sufficient provided you don't name your logger warnings.
The following example,
generates the following lint,
There is no
warning
function inwarnings
, so the advice would break the code. It seems to be misrecognizing the statement as a logger. If there's enough context in the linter's representation of the code (like, if you have a good AST with some inference?),warnings
here is a fairly obvious import of thewarnings
module; could perhaps those get excepted as not loggers?