From 900a1970a9665c3618b2aaa662be444e71d88ace Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:09:48 +0000 Subject: [PATCH] Fix pass through overrides typing --- jupyter_server/base/handlers.py | 18 +++++++++--------- jupyter_server/base/websocket.py | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) 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()