Add B017 support for pytest.raises#317
Conversation
cooperlees
left a comment
There was a problem hiding this comment.
Thanks for this. This totally makes sense.
I'd just like to know how the pytest import is working? Does GitHub actions install it by default or something?
Also cc: @cricalix - Thoughts on this?
| import pytest | ||
|
|
There was a problem hiding this comment.
This confuses me how this works as we don't have pytest named as a dependency anywhere ...
Should we add it to dependencies or the dev optional dependencies now too?
There was a problem hiding this comment.
Good question. Not sure how this is being found. Agreed on adding to dev optional dependencies, though it would be good to know where it's currently being taken from.
No objections your honour. Not sure there's a cleaner way to check the AST without spending a bunch of time fiddling with pytest and bugbear (and we know how that's gone before..). Couldn't see anything in GH actions that default installs pytest either, nor any reference to pytest in the bugbear repo (oh for |
|
I'll happily not know here to avoid using buck. |
Hi! This PR should solve #169, where calls like
with pytest.raises(Exception):are not being flagged by B017, even though they are basically the same use case aswith self.assertRaises(Exception).I'm uncertain about the best structure for
tests/b017.py, and I'm open to suggestions here. For now, I've just added the analogouspytest.raisescalls for each of the test cases withassertRaises.