Skip to content

Commit

Permalink
typing updates
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Oct 4, 2023
1 parent bb1bf4a commit 3ad47a8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions jupyterlab_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class LabServerApp(ExtensionAppJinjaMixin, LabConfig, ExtensionApp):

name = "jupyterlab_server"
extension_url = "/lab"
app_name = "JupyterLab Server Application"
file_url_prefix = "/lab/tree" # type:ignore
app_name = "JupyterLab Server Application" # type:ignore[assignment]
file_url_prefix = "/lab/tree" # type:ignore[assignment]

@property
def app_namespace(self):
Expand Down
12 changes: 12 additions & 0 deletions jupyterlab_server/licenses_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from typing import TYPE_CHECKING

from jupyter_server.base.handlers import APIHandler
from tornado import gen, web
Expand Down Expand Up @@ -50,6 +51,10 @@ def federated_extensions(self):
This is expensive, but probably the only way to be sure to get
up-to-date license information for extensions installed interactively.
"""
if TYPE_CHECKING:
from .app import LabServerApp
assert isinstance(self.parent, LabServerApp)

labextensions_path: list = sum(
[
self.parent.labextensions_path,
Expand Down Expand Up @@ -200,6 +205,9 @@ def app_static_info(self):
This will usually be in `static_dir`, but may also appear in the
parent of `static_dir`.
"""
if TYPE_CHECKING:
from .app import LabServerApp
assert isinstance(self.parent, LabServerApp)
path = Path(self.parent.static_dir)
package_json = path / "package.json"
if not package_json.exists():
Expand Down Expand Up @@ -253,6 +261,10 @@ async def get(self, _args):
full_text=full_text,
)

if TYPE_CHECKING:
from .app import LabServerApp
assert isinstance(self.manager.parent, LabServerApp)

if download:
filename = "{}-licenses{}".format(
self.manager.parent.app_name.lower(), mimetypes.guess_extension(mime)
Expand Down
2 changes: 1 addition & 1 deletion jupyterlab_server/process_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ProcessApp(ExtensionAppJinjaMixin, LabConfig, ExtensionApp):
load_other_extensions = True

# Do not open a browser for process apps
open_browser = False
open_browser = False # type:ignore[assignment]

def get_command(self):
"""Get the command and kwargs to run with `Process`.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ nowarn = "test -W default {args}"

[tool.hatch.envs.typing]
features = ["test"]
dependencies = ["mypy>=1.5.1"]
dependencies = ["mypy>=1.5.1", "traitlets>=5.11.2"]
[tool.hatch.envs.typing.scripts]
test = "mypy --install-types --non-interactive {args:jupyterlab_server tests}"

Expand Down

0 comments on commit 3ad47a8

Please sign in to comment.