Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style cleanup and some optimization #1194

Merged
merged 1 commit into from
Jan 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions web3/_utils/datatypes.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import web3._utils.formatters
from web3._utils.toolz import (
concat,
curry,
)


@curry
def verify_attr(class_name, key, namespace):
if key not in namespace:
raise AttributeError(
Expand All @@ -23,14 +21,16 @@ def __init__(cls, name, bases, namespace, **kargs):

def __new__(mcs, name, bases, namespace, normalizers=None):
all_bases = set(concat(base.__mro__ for base in bases))
all_keys = set(concat(base.__dict__.keys() for base in all_bases))

for key in namespace:
verify_key_attr = verify_attr(name, key)
verify_key_attr(concat(base.__dict__.keys() for base in all_bases))
verify_attr(name, key, all_keys)

if normalizers:
processed_namespace = web3._utils.formatters.apply_formatters_to_dict(
normalizers,
namespace)
namespace,
)
else:
processed_namespace = namespace

Expand Down