Skip to content

Commit

Permalink
Update ruff config and typing
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Nov 10, 2023
1 parent 875e4d7 commit 7de30b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions notebook/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 7de30b0

Please sign in to comment.