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

Commit 7fed19a

Browse files
laggron42fscherf
authored andcommitted
Remove the lenght of arguments conditions
Edited-by: Florian Scherf <f.scherf@pengutronix.de> - pep8 fix - added test
1 parent ad05d59 commit 7fed19a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

aiohttp_json_rpc/rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, method):
5151
# required args
5252
self.required_args = copy(self.args)
5353

54-
if not (len(self.args) == 1 and self.defaults is None):
54+
if self.defaults:
5555
self.required_args = [
5656
i for i in self.args[:-len(self.defaults or ())]
5757
if i not in self.CREDENTIAL_KEYS

tests/test_method_args.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ async def test_args(rpc_context):
77
async def method1(request, a):
88
return a
99

10+
async def method1_1(request, a, b):
11+
return [a, b]
12+
1013
async def method2(request, a, b, c=1):
1114
return [a, b, c]
1215

@@ -44,6 +47,7 @@ async def method4(self):
4447
# setup rpc and client
4548
rpc_context.rpc.add_methods(
4649
('', method1),
50+
('', method1_1),
4751
('', method2),
4852
('', method3),
4953
('', method4),
@@ -54,6 +58,7 @@ async def method4(self):
5458

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

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

0 commit comments

Comments
 (0)