You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checked on main: since #578, class FailOnException(ContextManager[T]) with an __init__ that doesn't call super().__init__() is no longer flagged by B042 (it was on the commit before). #578 only excludes parameterized generic bases rather than resolving real inheritance from BaseException, so I'll leave it to you whether that's enough to close this.
It sounds like it addresses my usecase (I haven't tested it yet), so thanks for that, but it sounds like it is still technically "naive", so I'll leave it open. 🙂
Activity
cooperlees commentedon Feb 13, 2026
I get the "buggy" nature, but calling something an exception that isn't an exception is misleading right? Probably don't want to do that in Python ...
But open to maybe using inheritance from BaseException etc. to be smarter here if others agree.
GPHemsley-RELX commentedon Feb 13, 2026
FailOnExceptionis a context manager that catches exceptions and then fails gracefully; it's not calling itself an exception.I think checking for inheritance from BaseException is the only right way to do this, and indeed is a more Pythonic way.
B042: don't count a parameterized generic base as an exception super …
Merge main: resolve UNRELEASED changelog conflict
DG-Elom commentedon Oct 14, 2026
Checked on
main: since #578,class FailOnException(ContextManager[T])with an__init__that doesn't callsuper().__init__()is no longer flagged by B042 (it was on the commit before). #578 only excludes parameterized generic bases rather than resolving real inheritance fromBaseException, so I'll leave it to you whether that's enough to close this.GPHemsley-RELX commentedon Oct 14, 2026
It sounds like it addresses my usecase (I haven't tested it yet), so thanks for that, but it sounds like it is still technically "naive", so I'll leave it open. 🙂