From c0790d77571fcf6d6c95131c2bb444146a9d48ea Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Mon, 2 Oct 2023 08:18:14 +0000 Subject: [PATCH] Fix traitlets typing --- notebook/app.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/notebook/app.py b/notebook/app.py index 9cdccadd0f..da5253818f 100644 --- a/notebook/app.py +++ b/notebook/app.py @@ -32,11 +32,14 @@ from notebook_shim.shim import NotebookConfigShimMixin # type:ignore[import] from tornado import web from traitlets import Bool, Unicode, default +from traitlets.config.loader import Config from ._version import __version__ HERE = os.path.dirname(__file__) +Flags = t.Dict[t.Union[str, t.Tuple[str, ...]], t.Tuple[t.Union[t.Dict[str, t.Any], Config], str]] + app_dir = get_app_dir() version = __version__ @@ -253,7 +256,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[ """, ) - flags = flags + flags: Flags = flags # type:ignore[assignment] flags["expose-app-in-browser"] = ( {"JupyterNotebookApp": {"expose_app_in_browser": True}}, "Expose the global app instance to browser via window.jupyterapp.", @@ -264,31 +267,31 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[ "Load custom CSS in template html files. Default is True", ) - @default("static_dir") # type:ignore[misc] + @default("static_dir") def _default_static_dir(self) -> str: return os.path.join(HERE, "static") - @default("templates_dir") # type:ignore[misc] + @default("templates_dir") def _default_templates_dir(self) -> str: return os.path.join(HERE, "templates") - @default("app_settings_dir") # type:ignore[misc] + @default("app_settings_dir") def _default_app_settings_dir(self) -> str: return pjoin(app_dir, "settings") - @default("schemas_dir") # type:ignore[misc] + @default("schemas_dir") def _default_schemas_dir(self) -> str: return pjoin(app_dir, "schemas") - @default("themes_dir") # type:ignore[misc] + @default("themes_dir") def _default_themes_dir(self) -> str: return pjoin(app_dir, "themes") - @default("user_settings_dir") # type:ignore[misc] + @default("user_settings_dir") def _default_user_settings_dir(self) -> str: return t.cast(str, get_user_settings_dir()) - @default("workspaces_dir") # type:ignore[misc] + @default("workspaces_dir") def _default_workspaces_dir(self) -> str: return t.cast(str, get_workspaces_dir())