diff --git a/jupyter_server/base/handlers.py b/jupyter_server/base/handlers.py index d8097b4f3b..8687e9de93 100644 --- a/jupyter_server/base/handlers.py +++ b/jupyter_server/base/handlers.py @@ -14,7 +14,7 @@ import warnings from http.client import responses from logging import Logger -from typing import TYPE_CHECKING, Any, Awaitable, Sequence, cast +from typing import TYPE_CHECKING, Any, Awaitable, Coroutine, Sequence, cast from urllib.parse import urlparse import prometheus_client @@ -1016,14 +1016,14 @@ def compute_etag(self) -> str | None: # access is allowed as this class is used to serve static assets on login page # TODO: create an allow-list of files used on login page and remove this decorator @allow_unauthenticated - def get(self, *args, **kwargs) -> None: - return super().get(*args, **kwargs) + def get(self, path: str, include_body: bool = ...) -> Coroutine[Any, Any, None]: + return super().get(path, include_body) # access is allowed as this class is used to serve static assets on login page # TODO: create an allow-list of files used on login page and remove this decorator @allow_unauthenticated - def head(self, *args, **kwargs) -> None: - return super().head(*args, **kwargs) + def head(self, path: str) -> Awaitable[None]: + return super().head(path) @classmethod def get_absolute_path(cls, roots: Sequence[str], path: str) -> str: @@ -1170,12 +1170,12 @@ class PublicStaticFileHandler(web.StaticFileHandler): """Same as web.StaticFileHandler, but decorated to acknowledge that auth is not required.""" @allow_unauthenticated - def head(self, *args, **kwargs) -> None: - return super().head(*args, **kwargs) + def head(self, path: str) -> Awaitable[None]: + return super().head(path) @allow_unauthenticated - def get(self, *args, **kwargs) -> None: - return super().get(*args, **kwargs) + def get(self, path: str, include_body: bool = ...) -> Coroutine[Any, Any, None]: + return super().get(path, include_body) # ----------------------------------------------------------------------------- diff --git a/jupyter_server/base/websocket.py b/jupyter_server/base/websocket.py index c7bd311dd5..a424d06376 100644 --- a/jupyter_server/base/websocket.py +++ b/jupyter_server/base/websocket.py @@ -97,6 +97,7 @@ def _maybe_auth(self): self.log.warning("Couldn't authenticate WebSocket connection") raise web.HTTPError(403) + @no_type_check def prepare(self, *args, **kwargs): """Handle a get request.""" self._maybe_auth()