Name the unexpected keyword argument in the bind-failure TypeError (#144)
* Raise a proper unexpected-keyword-argument TypeError on bind failure
When a method call fails to bind and one of the supplied keyword arguments
matches no parameter of any candidate overload, the generic 'No method
matches given arguments' message did not mention the keyword argument at
all (only positional argument types are echoed), leaving the actual
mistake invisible, e.g.:
market_order(symbol, -10, as_tag="EmergencyFlatten")
-> No method matches given arguments for market_order:
(<class 'Symbol'>, <class 'int'>). The following overloads ...
Now such calls raise the Python-style error instead, naming the offending
kwarg and suggesting the closest parameter name when one exists:
market_order() got an unexpected keyword argument 'as_tag'.
Did you mean 'tag'?
When every kwarg name is valid for some overload but binding still fails,
the existing no-method-matches message is preserved.
* Tighten comments in unexpected-keyword-argument error path
* Share the Levenshtein distance helper between ClassBase and MethodBinder
Moves ClassBase's private LevenshteinDistance implementation verbatim to
Util.LevenshteinDistance and uses it from both call sites, removing the
duplicate introduced for keyword-argument suggestions.
* Extend the no-match error with the unexpected keyword argument instead of replacing it
* Never let bind-failure message construction throw J
Jhonathan Abreu committed
3464917e5f0ee78019ff85571b99ea8e7970fda4
Parent: cc51794
Committed by GitHub <noreply@github.com>
on 8/12/2026, 8:33:01 PM