Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Remove the lenght of arguments conditions
Browse files Browse the repository at this point in the history
Edited-by: Florian Scherf <f.scherf@pengutronix.de>
 - pep8 fix
 - added test
  • Loading branch information
laggron42 authored and fscherf committed Feb 26, 2019
1 parent ad05d59 commit 7fed19a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aiohttp_json_rpc/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, method):
# required args
self.required_args = copy(self.args)

if not (len(self.args) == 1 and self.defaults is None):
if self.defaults:
self.required_args = [
i for i in self.args[:-len(self.defaults or ())]
if i not in self.CREDENTIAL_KEYS
Expand Down
5 changes: 5 additions & 0 deletions tests/test_method_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ async def test_args(rpc_context):
async def method1(request, a):
return a

async def method1_1(request, a, b):
return [a, b]

async def method2(request, a, b, c=1):
return [a, b, c]

Expand Down Expand Up @@ -44,6 +47,7 @@ async def method4(self):
# setup rpc and client
rpc_context.rpc.add_methods(
('', method1),
('', method1_1),
('', method2),
('', method3),
('', method4),
Expand All @@ -54,6 +58,7 @@ async def method4(self):

# simple coroutine based methods
assert await client.call('method1', 1) == 1
assert await client.call('method1_1', [1, 2]) == [1, 2]

assert await client.call('method2', [1, 2]) == [1, 2, 1]
assert await client.call('method2', [1, 2, 3]) == [1, 2, 3]
Expand Down

0 comments on commit 7fed19a

Please sign in to comment.