From 381f83ff800c86a5daa093ca0874c367eb77110f Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sun, 23 Jul 2023 08:45:06 +0200 Subject: [PATCH] Fix some inconsistencies --- starlette/_compat.py | 4 +++- starlette/applications.py | 5 +---- starlette/middleware/exceptions.py | 2 +- starlette/types.py | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/starlette/_compat.py b/starlette/_compat.py index 2e49f9e42a..9087a76450 100644 --- a/starlette/_compat.py +++ b/starlette/_compat.py @@ -18,7 +18,9 @@ def md5_hexdigest( data: bytes, *, usedforsecurity: bool = True ) -> str: # pragma: no cover - return hashlib.md5(data, usedforsecurity=usedforsecurity).hexdigest() # type: ignore[call-arg] # noqa: E501 + return hashlib.md5( # type: ignore[call-arg] + data, usedforsecurity=usedforsecurity + ).hexdigest() except TypeError: # pragma: no cover diff --git a/starlette/applications.py b/starlette/applications.py index 1c315b42a0..41db4ac80c 100644 --- a/starlette/applications.py +++ b/starlette/applications.py @@ -50,10 +50,7 @@ def __init__( routes: typing.Optional[typing.Sequence[BaseRoute]] = None, middleware: typing.Optional[typing.Sequence[Middleware]] = None, exception_handlers: typing.Optional[ - typing.Mapping[ - typing.Any, - ExceptionHandler, - ] + typing.Mapping[typing.Any, ExceptionHandler] ] = None, on_startup: typing.Optional[ typing.Sequence[typing.Callable[[], typing.Any]] diff --git a/starlette/middleware/exceptions.py b/starlette/middleware/exceptions.py index 59010c7e68..0124f5c8f3 100644 --- a/starlette/middleware/exceptions.py +++ b/starlette/middleware/exceptions.py @@ -26,7 +26,7 @@ def __init__( self._status_handlers: StatusHandlers = {} self._exception_handlers: ExceptionHandlers = { HTTPException: self.http_exception, - WebSocketException: self.websocket_exception, # type: ignore[dict-item] + WebSocketException: self.websocket_exception, } if handlers is not None: for key, value in handlers.items(): diff --git a/starlette/types.py b/starlette/types.py index a8b3e798a7..4479698a98 100644 --- a/starlette/types.py +++ b/starlette/types.py @@ -25,5 +25,5 @@ typing.Callable[ ["Request", Exception], typing.Union["Response", typing.Awaitable["Response"]] ], - typing.Callable[["WebSocket", Exception], None], + typing.Callable[["WebSocket", Exception], typing.Awaitable[None]], ]