From 20a463e065f7cb38ee607cce95c30b6915c80f1a Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 16 Nov 2023 05:49:26 -0600 Subject: [PATCH] Update typings for Server 2.10.1 and mypy 1.7 (#425) --- .pre-commit-config.yaml | 6 +++--- jupyterlab_server/settings_utils.py | 4 ++-- jupyterlab_server/workspaces_handler.py | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index afffb10e..c59667fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: [mdformat-gfm, mdformat-frontmatter, mdformat-footnote] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + rev: "v3.1.0" hooks: - id: prettier types_or: [yaml, json] @@ -58,7 +58,7 @@ repos: - id: rst-inline-touching-normal - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.6.1" + rev: "v1.7.0" hooks: - id: mypy files: "^jupyterlab_server" @@ -67,7 +67,7 @@ repos: additional_dependencies: [ "traitlets>=5.3", - "jupyter_server>=2.10", + "jupyter_server>=2.10.1", "openapi_core", "json5", "pytest", diff --git a/jupyterlab_server/settings_utils.py b/jupyterlab_server/settings_utils.py index fd36cff8..8869be22 100644 --- a/jupyterlab_server/settings_utils.py +++ b/jupyterlab_server/settings_utils.py @@ -92,8 +92,8 @@ def _get_user_settings(settings_dir: str, schema_name: str, schema: Any) -> dict if os.path.exists(path): stat = os.stat(path) - last_modified = tz.utcfromtimestamp(stat.st_mtime).isoformat() # type:ignore[no-untyped-call] - created = tz.utcfromtimestamp(stat.st_ctime).isoformat() # type:ignore[no-untyped-call] + last_modified = tz.utcfromtimestamp(stat.st_mtime).isoformat() + created = tz.utcfromtimestamp(stat.st_ctime).isoformat() with open(path, encoding="utf-8") as fid: try: # to load and parse the settings file. raw = fid.read() or raw diff --git a/jupyterlab_server/workspaces_handler.py b/jupyterlab_server/workspaces_handler.py index a42ce909..27121a90 100644 --- a/jupyterlab_server/workspaces_handler.py +++ b/jupyterlab_server/workspaces_handler.py @@ -57,8 +57,8 @@ def _load_with_file_times(workspace_path: Path) -> dict: with workspace_path.open(encoding="utf-8") as fid: workspace = json.load(fid) workspace["metadata"].update( - last_modified=tz.utcfromtimestamp(stat.st_mtime).isoformat(), # type:ignore[no-untyped-call] - created=tz.utcfromtimestamp(stat.st_ctime).isoformat(), # type:ignore[no-untyped-call] + last_modified=tz.utcfromtimestamp(stat.st_mtime).isoformat(), + created=tz.utcfromtimestamp(stat.st_ctime).isoformat(), ) return workspace @@ -170,9 +170,7 @@ def save(self, space_name: str, raw: str) -> Path: class WorkspacesHandler(ExtensionHandlerMixin, ExtensionHandlerJinjaMixin, APIHandler): """A workspaces API handler.""" - def initialize( # type:ignore[override] - self, name: str, manager: WorkspacesManager, **kwargs: Any - ) -> None: + def initialize(self, name: str, manager: WorkspacesManager, **kwargs: Any) -> None: """Initialize the handler.""" super().initialize(name) self.manager = manager