Ticket-35459 narrates a debugging session where the culprit turned out to be accidentally passing extraneous keyword args to Case
.
As I read it, the ticket was accepted to add coverage and clarify in docs how arbitrary **extra
args are allowed to support custom SQL templates in subclasses. However, there is an interesting asymmetry here we could do something about.
If the left-hand side (the SQL template) has extraneous args e.g. because it was subclassed, and there is no matching right-hand side argument, a KeyError
escapes from the failed string format operation.
But if the right-hand side (**extra
) has extraneous args e.g. because of a mistaken call, the string formatting proceeds without error.
Is there value in putting this behavior on a deprecation path and eventually raising an exception if a provided keyword argument doesn’t match a parameter in the SQL template?