Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ypankovych committed May 14, 2021
1 parent 37e2a3b commit d08c4b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pankoff/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _invalidate_call_cache(instance, target):
instance_type = type(instance)
for base in instance_type.mro():
if hasattr(base, target):
attribute = getattr(base, target)
attribute = getattr(base, target, None)
if hasattr(attribute, "__called__"):
del attribute.__called__

Expand All @@ -38,8 +38,8 @@ def __init_subclass__(cls, **kwargs):
def __cached_wrapper(func):
@functools.wraps(func)
def __inner(*args, **kw):
__inner.__called__ = True
ret = func(*args, **kw)
func.__called__ = True
return ret
__inner.__wrapped__ = func
return __inner
Expand All @@ -58,7 +58,7 @@ def __init__(self, __mro__=None, **kwargs):
if parameter.name in kwargs:
kw[parameter.name] = kwargs.pop(parameter.name)
if base.__setup__ is not BaseValidator.__setup__:
if not getattr(base.__setup__.__wrapped__, "__called__", False):
if not getattr(base.__setup__, "__called__", False):
base.__setup__(self, **kw)
super(base, self).__init__(__mro__=__mro__, **kwargs)

Expand All @@ -68,7 +68,7 @@ def __set__(self, instance, value, __mro__=None, errors=None):
__mro__ = type(self).mro()
base, __mro__ = __mro__[0], __mro__[1:]
if base.validate is not BaseValidator.validate:
if not getattr(base.validate.__wrapped__, "__called__", False):
if not getattr(base.validate, "__called__", False):
try:
base.validate(self, instance, value)
except ValidationError as exc:
Expand Down

0 comments on commit d08c4b7

Please sign in to comment.