pytest icon indicating copy to clipboard operation
pytest copied to clipboard

enable gracefull handling and mitigation of -W error for pytest plugins and packages

Open RonnyPfannschmidt opened this issue 2 years ago • 4 comments

based on https://twitter.com/davidism/status/1484580868840558593

we should have a tool to help to turn a warning into a filterwarning expression we should also shift toward having pytest/pytest plugin warnings be warnings, even when projects use -W error

RonnyPfannschmidt avatar Jul 02 '22 21:07 RonnyPfannschmidt

we should also shift toward having pytest/pytest plugin warnings be warnings, even when projects use -W error

Why? This is one of the main reasons I use -Werror, and I've found various deprecated pytest API usage in other projects by doing so. It sounds very surprising to special case pytest warnings in any way here.

(I also fail to see how this is related to the mentioned tool and/or the tweet, so if anything, it should probably be a separate issue.)

The-Compiler avatar Jul 02 '22 22:07 The-Compiler

The special case for pytest warnings is intended to reduce the cost of pytest updates fow -werror projects , but I can go with the sentiment that it may be too overreaching as proposed

RonnyPfannschmidt avatar Jul 03 '22 05:07 RonnyPfannschmidt

I'm with @The-Compiler - if I say -Werror, I actually want thing to fail! If it's making upgrades more expensive, people can configure a more precise warnings filter which warns in some packages and errors in others, e.g. -Wdefault:::pytest,error.

Zac-HD avatar Jul 16 '22 22:07 Zac-HD

https://github.com/pytest-dev/pytest/runs/7593793768?check_suite_focus=true has a great examle of why eager -W error is evil for debugging

the call to warn_explicit which includes the real location is hidden away, its not clear if there are more similar issues in the output as the exit is early

im reopenin as -W error is hostile due to bad debugging cappabilities

this wouldnt be necessary if the warnings module of python was better, but it isnt

RonnyPfannschmidt avatar Jul 31 '22 05:07 RonnyPfannschmidt