diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e78760d4df..14304ce6b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,7 @@ repos: files: "^notebook" stages: [manual] args: ["--install-types", "--non-interactive"] - additional_dependencies: ["traitlets>=5.13", "tornado", "jupyter_server>=2.9", "jupyterlab_server>=2.25", "jupyterlab>=4.0"] + additional_dependencies: ["traitlets>=5.13", "tornado", "jupyter_server>=2.10", "jupyterlab_server>=2.25", "jupyterlab>=4.0"] - repo: https://github.com/pre-commit/pygrep-hooks rev: 'v1.10.0' @@ -60,11 +60,13 @@ repos: - id: rst-inline-touching-normal - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.4 + rev: v0.1.5 hooks: - id: ruff + types_or: [ python, jupyter ] args: ['--fix', '--show-fixes'] - id: ruff-format + types_or: [ python, jupyter ] - repo: https://github.com/scientific-python/cookie rev: '2023.10.27' diff --git a/notebook/app.py b/notebook/app.py index 53cc86e65b..dffa397946 100644 --- a/notebook/app.py +++ b/notebook/app.py @@ -301,6 +301,8 @@ def _prepare_templates(self) -> None: def server_extension_is_enabled(self, extension: str) -> bool: """Check if server extension is enabled.""" + if self.serverapp is None: + return False try: extension_enabled = ( self.serverapp.extension_manager.extensions[extension].enabled is True @@ -311,6 +313,7 @@ def server_extension_is_enabled(self, extension: str) -> bool: def initialize_handlers(self) -> None: """Initialize handlers.""" + assert self.serverapp is not None # noqa: S101 page_config = self.serverapp.web_app.settings.setdefault("page_config_data", {}) nbclassic_enabled = self.server_extension_is_enabled("nbclassic") page_config["nbclassic_enabled"] = nbclassic_enabled diff --git a/pyproject.toml b/pyproject.toml index 3df1cba221..1c67251b93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,7 +138,10 @@ nowarn = "test -W default {args}" detached = true dependencies = ["pre-commit"] [tool.hatch.envs.lint.scripts] -build = "pre-commit run --all-files ruff" +build = [ + "pre-commit run --all-files ruff", + "pre-commit run --all-files ruff-format" +] [tool.hatch.envs.typing] dependencies = [ "pre-commit"] @@ -233,7 +236,6 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] warn_unreachable = true [tool.ruff] -target-version = "py38" line-length = 100 [tool.ruff.lint]