Possible false positive for B015
We discovered some potential false positives in pybind11 (see here) - specifically, a test like this reports:
with pytest.raises(TypeError):
y < object()
Might not be fixable, and this check has helped in other cases, but thought I'd point it out here.
Yeah, that is “technically pointless”, I guess. Thanks for stating the check has also helped. It seems lots of people have loved this check (myself included).
I think this will just have to be commented to be ignored. I like the comment as it shows the author’s intent and acknowledgement.
Let’s leave the issue open tho cause someone smarter than I might see a way to use the AST to notice we’re in a context manager & using raises, but I worry adding this complicates and could cause us to maybe miss a pointless comparison.
Quite a few of my pointless comparisons have been in pytest.raises, actually, see https://github.com/scikit-hep/hist/commit/b9c447680ee7441049ae15e38e8d09b1494917d2 . The problem here is that the comparison itself raises, and that's what's being checked.
FYI, this check actually caught a real bug in https://github.com/scikit-hep/awkward-1.0/pull/682 :)
Yeah, that is “technically pointless”, I guess.
How so? I'm confused. AFAIC, the false-positive is not in question. B015 should not flag within a with pytest.raises(TypeError): context.