Skip to content

Commit

Permalink
speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
kislyuk committed Feb 16, 2014
1 parent 25c1fa7 commit b1e7efc
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions ensure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,18 +633,14 @@ def wrapper(*args, **kwargs):
value = args[arg_pos[arg]]
else:
continue
try:
unittest_case.assertIsInstance(value, templ)
except AssertionError:
if not isinstance(value, templ):
msg = "Argument {arg} to {f} does not match annotation type {t}"
raise EnsureError(msg.format(arg=arg, f=f, t=templ))

return_val = f(*args, **kwargs)
if 'return' in f.__annotations__:
templ = f.__annotations__['return']
try:
unittest_case.assertIsInstance(return_val, templ)
except AssertionError:
if not isinstance(return_val, templ):
msg = "Return value of {f} does not match annotation type {t}"
raise EnsureError(msg.format(f=f, t=templ))
return return_val
Expand Down

0 comments on commit b1e7efc

Please sign in to comment.