Skip to content

Commit 4f510b1

Browse files
committed
Pylint fixes
1 parent ab30150 commit 4f510b1

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

examples/fastapi_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""FastAPI server"""
22
from fastapi import FastAPI, Request, Response
3-
from jsonrpcserver import dispatch, method, Ok, Result
43
import uvicorn # type: ignore
4+
from jsonrpcserver import dispatch, method, Ok, Result
55

66
app = FastAPI()
77

jsonrpcserver/async_methods.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Async methods"""
12
from typing import Any, Awaitable, Callable, Dict, Optional, cast
23

34
from returns.result import Result
@@ -6,11 +7,11 @@
67

78
Method = Callable[..., Awaitable[Result[SuccessResult, ErrorResult]]]
89
Methods = Dict[str, Method]
9-
global_methods: Methods = dict()
10+
global_methods: Methods = {}
1011

1112

1213
def method(
13-
f: Optional[Method] = None, name: Optional[str] = None
14+
func: Optional[Method] = None, name: Optional[str] = None
1415
) -> Callable[..., Awaitable[Any]]:
1516
"""A decorator to add a function into jsonrpcserver's internal global_methods dict.
1617
The global_methods dict will be used by default unless a methods argument is passed
@@ -23,9 +24,9 @@ def foo():
2324
...
2425
"""
2526

26-
def decorator(func: Method) -> Method:
27+
def decorator(func_: Method) -> Method:
2728
nonlocal name
28-
global_methods[name or func.__name__] = func
29-
return func
29+
global_methods[name or func_.__name__] = func_
30+
return func_
3031

31-
return decorator(f) if callable(f) else cast(Method, decorator)
32+
return decorator(func) if callable(func) else cast(Method, decorator)

tests/test_async_dispatcher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ async def test_dispatch_to_response_pure_success() -> None:
8787
@patch("jsonrpcserver.async_dispatcher.dispatch_request", side_effect=ValueError("foo"))
8888
@pytest.mark.asyncio
8989
async def test_dispatch_to_response_pure_server_error(_: Mock) -> None:
90-
async def foo() -> Result:
90+
async def ping() -> Result:
9191
return Ok()
9292

9393
assert await dispatch_to_response_pure(
9494
deserializer=default_deserializer,
9595
validator=default_validator,
9696
post_process=identity,
9797
context=NOCONTEXT,
98-
methods={"foo": foo},
99-
request='{"jsonrpc": "2.0", "method": "foo", "id": 1}',
100-
) == Failure(ErrorResponse(ERROR_SERVER_ERROR, "Server error", "foo", None))
98+
methods={"ping": ping},
99+
request='{"jsonrpc": "2.0", "method": "ping", "id": 1}',
100+
) == Failure(ErrorResponse(ERROR_SERVER_ERROR, "Server error", "ping", None))

tests/test_dispatcher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
TODO: Add tests for dispatch_requests (non-pure version)
44
"""
5-
from typing import Any, Callable, Dict
5+
from typing import Any
66
from unittest.mock import Mock, patch, sentinel
77
import json
88
import pytest
@@ -167,14 +167,14 @@ def f() -> Result:
167167

168168

169169
def test_validate_result_positionals() -> None:
170-
def f(x: int) -> Result:
170+
def f(_: int) -> Result:
171171
return Ok()
172172

173173
assert validate_args(Request("f", [1], NOID), NOCONTEXT, f) == Success(f)
174174

175175

176176
def test_validate_result_positionals_not_passed() -> None:
177-
def f(x: str) -> Result:
177+
def f(_: str) -> Result:
178178
return Ok()
179179

180180
assert validate_args(Request("f", {"foo": "bar"}, NOID), NOCONTEXT, f) == Failure(
@@ -185,7 +185,7 @@ def f(x: str) -> Result:
185185

186186

187187
def test_validate_result_keywords() -> None:
188-
def f(**kwargs: str) -> Result:
188+
def f(**_: str) -> Result:
189189
return Ok()
190190

191191
assert validate_args(Request("f", {"foo": "bar"}, NOID), NOCONTEXT, f) == Success(f)

0 commit comments

Comments
 (0)