Make the nooper impl even smaller!
This commit is contained in:
parent
b1abc98c15
commit
e97ef09bd3
1 changed files with 3 additions and 4 deletions
|
@ -7,12 +7,11 @@ def nooper(cls):
|
||||||
""" Decorates a class that derives from an ABCMeta, filling in any unimplemented methods with
|
""" Decorates a class that derives from an ABCMeta, filling in any unimplemented methods with
|
||||||
no-ops.
|
no-ops.
|
||||||
"""
|
"""
|
||||||
def empty_func(self_or_cls, *args, **kwargs):
|
def empty_func(*args, **kwargs):
|
||||||
|
# pylint: disable=unused-argument
|
||||||
pass
|
pass
|
||||||
|
|
||||||
empty_methods = {}
|
empty_methods = {m_name: empty_func for m_name in cls.__abstractmethods__}
|
||||||
for method in cls.__abstractmethods__:
|
|
||||||
empty_methods[method] = empty_func
|
|
||||||
|
|
||||||
if not empty_methods:
|
if not empty_methods:
|
||||||
raise NoopIsANoopException('nooper implemented no abstract methods on %s' % cls)
|
raise NoopIsANoopException('nooper implemented no abstract methods on %s' % cls)
|
||||||
|
|
Reference in a new issue