Skip to content

Commit

Permalink
Merge efbdd65 into aabb2da
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Yen committed Sep 15, 2017
2 parents aabb2da + efbdd65 commit 4556088
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion multipledispatch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ def dispatch(*types, **kwargs):
on_ambiguity = kwargs.get('on_ambiguity', ambiguity_warn)

types = tuple(types)

def _(func):
nonlocal types
if len(types) == 0:
sig = inspect.signature(func)
annotations = tuple(
param.annotation for param in sig.parameters.values())
if all(ann is not inspect.Parameter.empty for ann in annotations):
types = annotations

name = func.__name__

if ismethod(func):
dispatcher = inspect.currentframe().f_back.f_locals.get(name,
dispatcher = inspect.currentframe().f_back.f_locals.get(
name,
MethodDispatcher(name))
else:
if name not in namespace:
Expand Down

0 comments on commit 4556088

Please sign in to comment.