Passed
Push — master ( 863a60...41e8a0 )
by Michael
15:33
created

aiohttp_rpc.decorators.rpc_method()   A

Complexity

Conditions 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 15
rs 9.75
c 0
b 0
f 0
cc 1
nop 5
1
import typing
2
3
from .protocol import JsonRpcMethod
4
from .server import JsonRpcServer, rpc_server as default_rpc_server
5
6
7
__all__ = (
8
    'rpc_method',
9
)
10
11
12
def rpc_method(prefix: str = '', *,
13
               rpc_server: JsonRpcServer = default_rpc_server,
14
               custom_name: typing.Optional[str] = None,
15
               add_extra_args: bool = True) -> typing.Callable:
16
    def _decorator(func: typing.Callable) -> typing.Callable:
17
        method = JsonRpcMethod(
18
            prefix=prefix,
19
            func=func,
20
            custom_name=custom_name,
21
            add_extra_args=add_extra_args,
22
        )
23
        rpc_server.add_method(method)
24
        return func
25
26
    return _decorator
27