Skip to content

Using named arguments would lost the signature of the method #134

Description

@Farrukhw

See the last call where arguments are given value by their names while changing their positions

from multipledispatch import dispatch

@dispatch(int, int)
def add(x, y):
    return x + y

@dispatch(object, object)
def add(x, y):
    return "%s + %s" % (x, y)

@dispatch(object, object, object)
def add(y, x , z):
    return f"{x} and {y} now {z}"

print(add(3,4))
print(add('Me','You'))

#using named arguments
print(add(y='You', x='me'))

This would end up with the following errors:

 {
	"name": "NotImplementedError",
	"message": "Could not find signature for add: <>",
	"stack": "---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~\\AppData\\Roaming\\Python\\Python311\\site-packages\\multipledispatch\\dispatcher.py:269, in Dispatcher.__call__(self, *args, **kwargs)
    268 try:
--> 269     func = self._cache[types]
    270 except KeyError:

KeyError: ()

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
Cell In[45], line 18
     16 print(add('Me','You'))
     17 #using named arguments
---> 18 print(add(y='You', x='me'))

File ~\\AppData\\Roaming\\Python\\Python311\\site-packages\\multipledispatch\\dispatcher.py:273, in Dispatcher.__call__(self, *args, **kwargs)
    271     func = self.dispatch(*types)
    272     if not func:
--> 273         raise NotImplementedError(
    274             \"Could not find signature for %s: <%s>\"
    275             % (self.name, str_signature(types))
    276         )
    277     self._cache[types] = func
    278 try:

NotImplementedError: Could not find signature for add: <>"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions