Calling warnings.warn() without a stacklevel, or a stacklevel value of <2, is nearly always a mistake. Doing so flags the warning inside the called function, rather than the caller, making it hard to fix the warning.
flake8-bugbear could detect such invocations of warnings.warn().
This issue inspired by @asottile's video of the day: https://www.youtube.com/watch?v=CtFdXBEwYfk . This is also something I've seen recur as a review point in Django PR's.
Calling
warnings.warn()without astacklevel, or astacklevelvalue of <2, is nearly always a mistake. Doing so flags the warning inside the called function, rather than the caller, making it hard to fix the warning.flake8-bugbear could detect such invocations of
warnings.warn().This issue inspired by @asottile's video of the day: https://www.youtube.com/watch?v=CtFdXBEwYfk . This is also something I've seen recur as a review point in Django PR's.