Add docstring, fix spelling mistake

This commit is contained in:
Arjan Molenaar 2020-05-19 12:06:11 +02:00
parent 6e76661492
commit 2a975f55fc
2 changed files with 6 additions and 1 deletions

View File

@ -81,6 +81,10 @@ class FunctionDispatcher(Generic[T]):
self.registry = Registry(*axis)
def check_rule(self, rule: T, *argtypes: KeyType) -> None:
""" Check if the argument types match wrt number of arguments.
Raise TypeError in case of failure.
"""
# Check if we have the right number of parametrized types
if len(argtypes) != self.params_arity:
raise TypeError(
@ -111,6 +115,7 @@ class FunctionDispatcher(Generic[T]):
"""
def register_rule(func: T) -> T:
""" Register rule wrapper function."""
self.register_rule(func, *argtypes)
return func

View File

@ -105,7 +105,7 @@ class MethodDispatcher(FunctionDispatcher[T]):
@property
def otherwise(self) -> Callable[[T], T]:
""" Decorator which registeres "catch-all" case for multimethod"""
""" Decorator which registers "catch-all" case for multimethod"""
def make_declaration(meth):
self.register_unbound_rule(meth, *([object] * (self.params_arity - 1)))