I have a dispatcher that calls callbacks with two arguments:
class Foo:
def register(self, callback):
self.callback = callback
def _handle(self):
self.callback(x, y)
I wish to deprecate the second argument, and send only one argument instead:
def _handle(self):
self.callback(x)
How am I able to deprecate the old callback without breaking code during the migration period?
Most ways to deprecate include ignoring an argument and sending DeprecationWarning. In this case it won't work as I have to send all parameters in case an older callback is registered.
Other ways are signature inspection (which won't be reliable) or creating a different register()
function or new_callback
parameter which looks like a code smell.