-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
Description
Hi all,
I was greeted by some fresh B042 errors in our CI this morning, which rightfully complained about some exception subclasses. In one case however, I am not sure what the correct solution would be and after reading some exception-best-practices guides, I think that its a false positive in the B042 code.
Consider the following example:
class MyException(Exception):
def __init__(self, msg: str, additional_data: str = "", /, *args: object) -> None:
super().__init__(msg, *args)
self.additional_data = additional_data
This code works just fine and also seems to support copy.copy() and pickling, but flake8-bugbear reports:
myexception.py:2:5: B042 Exception class with `__init__` should pass all args to `super().__init__()` in order to work with `copy.copy()`. It should also not take any kwargs.