Skip to content

Commit

Permalink
Have mungers stop outputing module
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjw committed Jan 15, 2019
1 parent b58a3e2 commit 8f264c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
24 changes: 12 additions & 12 deletions tests/core/method-class/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def formatter(params):
},
[],
{},
('eth_method', [])
('eth_method', ())
),
(
{
Expand All @@ -161,14 +161,14 @@ def formatter(params):
},
[],
{},
('eth_method', [])
('eth_method', ())
),
(
{
'mungers': [
lambda m, x, y, z: (m, [x, y]),
lambda m, x, y: (m, [x]),
lambda m, x: (m, [str(x)])],
lambda m, x, y, z: [x, y],
lambda m, x, y: [x],
lambda m, x: [str(x)]],
'json_rpc_method': 'eth_method',
'formatter_lookup_fn': ''
},
Expand All @@ -179,9 +179,9 @@ def formatter(params):
(
{
'mungers': [
lambda m, x, y, z: (m, [x, y]),
lambda m, x, y: (m, [x]),
lambda m, x: (m, [str(x)])],
lambda m, x, y, z: [x, y],
lambda m, x, y: [x],
lambda m, x: [str(x)]],
'json_rpc_method': 'eth_method',
'formatter_lookup_fn': ''
},
Expand All @@ -207,14 +207,14 @@ def formatter(params):
},
[],
{},
('eth_mismatch', [])
('eth_mismatch', ())
),
(
{
'mungers': [
lambda m, x, y, z: (m, [x, y]),
lambda m, x, y: (m, [x]),
lambda m, x: (m, [str(x)])],
lambda m, x, y, z: [x, y],
lambda m, x, y: [x],
lambda m, x: [str(x)]],
'json_rpc_method': 'eth_method',
'formatter_lookup_fn': get_test_formatters
},
Expand Down
11 changes: 5 additions & 6 deletions web3/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

def _munger_star_apply(fn):
@functools.wraps(fn)
def inner(module_args):
module, args = module_args
return fn(module, *args)
def inner(args):
return fn(*args)
return inner


Expand All @@ -23,7 +22,7 @@ def get_default_formatters(*args, **kwargs):

def default_munger(module, *args, **kwargs):
if not args and not kwargs:
return module, list()
return tuple()
else:
raise TypeError("Parameters passed to method without parameter mungers defined.")

Expand Down Expand Up @@ -118,9 +117,9 @@ def input_munger(self, val):
# TODO: Create friendly error output.
mungers_iter = iter(self.mungers)
root_munger = next(mungers_iter)
_, munged_inputs = pipe(
munged_inputs = pipe(
root_munger(module, *args, **kwargs),
*map(_munger_star_apply, mungers_iter))
*map(lambda m: _munger_star_apply(functools.partial(m, module)), mungers_iter))

return munged_inputs

Expand Down

0 comments on commit 8f264c1

Please sign in to comment.