Skip to content

Commit

Permalink
ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
tekumara committed Jan 8, 2024
1 parent d9037c5 commit 7cecce7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion starlette/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def requires(
scopes_list = [scopes] if isinstance(scopes, str) else list(scopes)

def decorator(
func: typing.Callable[_P, typing.Any]
func: typing.Callable[_P, typing.Any],
) -> typing.Callable[_P, typing.Any]:
sig = inspect.signature(func)
for idx, parameter in enumerate(sig.parameters.values()):
Expand Down
6 changes: 4 additions & 2 deletions starlette/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def iscoroutinefunction_or_partial(obj: typing.Any) -> bool: # pragma: no cover


def request_response(
func: typing.Callable[[Request], typing.Union[typing.Awaitable[Response], Response]]
func: typing.Callable[
[Request], typing.Union[typing.Awaitable[Response], Response]
],
) -> ASGIApp:
"""
Takes a function or coroutine `func(request) -> response`,
Expand All @@ -78,7 +80,7 @@ async def app(scope: Scope, receive: Receive, send: Send) -> None:


def websocket_session(
func: typing.Callable[[WebSocket], typing.Awaitable[None]]
func: typing.Callable[[WebSocket], typing.Awaitable[None]],
) -> ASGIApp:
"""
Takes a coroutine `func(session)`, and returns an ASGI application.
Expand Down
4 changes: 1 addition & 3 deletions starlette/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@
HTTPExceptionHandler = typing.Callable[
["Request", E], typing.Union["Response", typing.Awaitable["Response"]]
]
WebSocketExceptionHandler = typing.Callable[
["WebSocket", E], typing.Awaitable[None]
]
WebSocketExceptionHandler = typing.Callable[["WebSocket", E], typing.Awaitable[None]]
ExceptionHandler = typing.Union[HTTPExceptionHandler[E], WebSocketExceptionHandler[E]]
18 changes: 9 additions & 9 deletions tests/middleware/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ async def downstream_app(scope, receive, send):


def test_read_request_stream_in_app_after_middleware_calls_stream(
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
expected = [b""]
Expand Down Expand Up @@ -527,7 +527,7 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):


def test_read_request_stream_in_app_after_middleware_calls_body(
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
expected = [b"a", b""]
Expand All @@ -552,7 +552,7 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):


def test_read_request_body_in_app_after_middleware_calls_stream(
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
assert await request.body() == b""
Expand All @@ -577,7 +577,7 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):


def test_read_request_body_in_app_after_middleware_calls_body(
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
assert await request.body() == b"a"
Expand All @@ -599,7 +599,7 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):


def test_read_request_stream_in_dispatch_after_app_calls_stream(
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
expected = [b"a", b""]
Expand Down Expand Up @@ -627,7 +627,7 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):


def test_read_request_stream_in_dispatch_after_app_calls_body(
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
assert await request.body() == b"a"
Expand Down Expand Up @@ -705,7 +705,7 @@ async def send(msg: Message) -> None:


def test_read_request_stream_in_dispatch_after_app_calls_body_with_middleware_calling_body_before_call_next( # noqa: E501
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
assert await request.body() == b"a"
Expand Down Expand Up @@ -733,7 +733,7 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):


def test_read_request_body_in_dispatch_after_app_calls_body_with_middleware_calling_body_before_call_next( # noqa: E501
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
async def homepage(request: Request):
assert await request.body() == b"a"
Expand Down Expand Up @@ -837,7 +837,7 @@ async def send(msg: Message):


def test_downstream_middleware_modifies_receive(
test_client_factory: Callable[[ASGIApp], TestClient]
test_client_factory: Callable[[ASGIApp], TestClient],
) -> None:
"""If a downstream middleware modifies receive() the final ASGI app
should see the modified version.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def app(scope, receive, send):


def test_multi_tasks_failure_avoids_next_execution(
test_client_factory: Callable[..., TestClient]
test_client_factory: Callable[..., TestClient],
) -> None:
TASK_COUNTER = 0

Expand Down
2 changes: 1 addition & 1 deletion tests/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ async def modified_send(msg: Message) -> None:


def test_websocket_route_middleware(
test_client_factory: typing.Callable[..., TestClient]
test_client_factory: typing.Callable[..., TestClient],
):
async def websocket_endpoint(session: WebSocket):
await session.accept()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def app(scope: Scope, receive: Receive, send: Send) -> None:


def test_websocket_ensure_unicode_on_send_json(
test_client_factory: Callable[..., TestClient]
test_client_factory: Callable[..., TestClient],
):
async def app(scope: Scope, receive: Receive, send: Send) -> None:
websocket = WebSocket(scope, receive=receive, send=send)
Expand Down

0 comments on commit 7cecce7

Please sign in to comment.