Dispatch not recognizing correct parameter types

Viewed 12

I have the following test example:

from multipledispatch import dispatch


@dispatch(a=int,
          b=int,
          c=Optional[int])
def function(a, b, c=3):
    print(a+b+c)


@dispatch(a=str,
          b=str)
def function(a, b):
    print(a+b)


function(a=10, b=10, c=10)

Which produced the following error: TypeError: function() got an unexpected keyword argument 'c'

If I comment out the second instance of function(), then I get the expected result. But why does dispatch try to use the function that has 2 strings as input when I am passing 3 integers? That seems to go against every example of dispatch that I can find.

0 Answers
Related