Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix traitlets typing #7082

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions notebook/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @blink1073

Wondering if there would be a better / simpler way to handle this in downstream apps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on making them just dict[str, Any] in Application and JupyterApp, rather than trying to be more specific. https://github.com/ipython/traitlets/pull/873/files#diff-5453d413070d06bcf7ba7f017b9cf364e774627fad69964a6471449e5c16dc37R371

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks!


app_dir = get_app_dir()
version = __version__

Expand Down Expand Up @@ -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.",
Expand All @@ -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())

Expand Down
Loading