One way to ensure that a method is called with a particular kwarg would be like:
def mymethod(self, *args, **kwargs):
assert "required_field" in kwargs
Raising an AssertionError doesn’t seem like the most appropriate thing to do. Is there an agreed upon builtin exception to handle this with a nice error message?
More info: there are 3rd-party subclassing issues where *args and **kwargs kinda’ need to be passed so making “required_field” a positional argument is not really a good option.
I’d just go with TypeError..