Hello,
I write new services and work with legacy code also. So, one of the hardest challenges for me here is to not start big refactoring, but do only what we need now.
Several weeks ago I faced the issue: I have a method that used in a lot of places, and I was not going to change the interface of this method... but I want to get more data - here I add a new attribute - the "reason" attribute to a class that emulate boolean result of the method:
class FalseWithReason:
def __init__(self, reason):
self.reason = reason
def __bool__(self):
return False
