mirror of
https://github.com/jupyter/notebook.git
synced 2024-11-21 01:11:21 +08:00
Adopt sp-repo-review (#7039)
* adopt sp-repo-review * adopt sp-repo-review * fix typing * fix typing * undo redundant formatting * undo markdown changes * formatting
This commit is contained in:
parent
5a31c64a90
commit
14fce8c9e4
6
.github/actions/build-dist/action.yml
vendored
6
.github/actions/build-dist/action.yml
vendored
@ -1,7 +1,7 @@
|
||||
name: "Build Jupyter Notebook"
|
||||
description: "Build Jupyter Notebook from source"
|
||||
name: 'Build Jupyter Notebook'
|
||||
description: 'Build Jupyter Notebook from source'
|
||||
runs:
|
||||
using: "composite"
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Base Setup
|
||||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||
|
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
@ -1,10 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/"
|
||||
interval: 'weekly'
|
||||
- package-ecosystem: 'pip'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
interval: 'weekly'
|
||||
|
2
.github/jupyterlab-probot.yml
vendored
2
.github/jupyterlab-probot.yml
vendored
@ -1,2 +1,2 @@
|
||||
addBinderLink: false
|
||||
triageLabel: "status:Needs Triage"
|
||||
triageLabel: 'status:Needs Triage'
|
||||
|
55
.github/workflows/build.yml
vendored
55
.github/workflows/build.yml
vendored
@ -5,11 +5,10 @@ on:
|
||||
branches: ['main']
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
permissions:
|
||||
contents:
|
||||
write
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
||||
@ -26,11 +25,11 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
uses: ./.github/actions/build-dist
|
||||
- name: Build
|
||||
uses: ./.github/actions/build-dist
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@ -41,28 +40,28 @@ jobs:
|
||||
# used by the jupyterlab/maintainer-tools base-setup action
|
||||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Base Setup
|
||||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||
- name: Base Setup
|
||||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||
|
||||
- name: Test the package
|
||||
run: hatch run cov:test
|
||||
- name: Test the package
|
||||
run: hatch run cov:test
|
||||
|
||||
- name: JavaScript tests
|
||||
run: |
|
||||
hatch run js_test
|
||||
- name: JavaScript tests
|
||||
run: |
|
||||
hatch run js_test
|
||||
|
||||
- name: Integration Tests
|
||||
run: |
|
||||
pip install .
|
||||
cd
|
||||
jupyter labextension list 2>&1 | grep -ie "@jupyter-notebook/lab-extension.*enabled.*ok" -
|
||||
jupyter server extension list 2>&1 | grep -ie "notebook.*enabled" -
|
||||
python -m jupyterlab.browser_check
|
||||
- name: Integration Tests
|
||||
run: |
|
||||
pip install .
|
||||
cd
|
||||
jupyter labextension list 2>&1 | grep -ie "@jupyter-notebook/lab-extension.*enabled.*ok" -
|
||||
jupyter server extension list 2>&1 | grep -ie "notebook.*enabled" -
|
||||
python -m jupyterlab.browser_check
|
||||
|
||||
- uses: jupyterlab/maintainer-tools/.github/actions/upload-coverage@v1
|
||||
- uses: jupyterlab/maintainer-tools/.github/actions/upload-coverage@v1
|
||||
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
@ -176,8 +175,8 @@ jobs:
|
||||
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
|
||||
with:
|
||||
ignore_links: "https://playwright.dev/docs/test-cli/ https://blog.jupyter.org/the-big-split-9d7b88a031a7 https://blog.jupyter.org/jupyter-ascending-1bf5b362d97e https://mybinder.org/v2/gh/jupyter/notebook/main"
|
||||
ignore_glob: "ui-tests/test/notebooks/*"
|
||||
ignore_links: 'https://playwright.dev/docs/test-cli/ https://blog.jupyter.org/the-big-split-9d7b88a031a7 https://blog.jupyter.org/jupyter-ascending-1bf5b362d97e https://mybinder.org/v2/gh/jupyter/notebook/main'
|
||||
ignore_glob: 'ui-tests/test/notebooks/*'
|
||||
|
||||
test_lint:
|
||||
name: Test Lint
|
||||
@ -185,8 +184,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||
- name: Run Linters
|
||||
run: |
|
||||
- name: Run Linters
|
||||
run: |
|
||||
hatch run typing:test
|
||||
hatch run lint:style
|
||||
pipx run interrogate -v .
|
||||
|
94
.github/workflows/buildutils.yml
vendored
94
.github/workflows/buildutils.yml
vendored
@ -18,64 +18,64 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Base Setup
|
||||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||
- name: Base Setup
|
||||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U "jupyterlab>=4.0.2,<5" hatch
|
||||
jlpm
|
||||
jlpm run build
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U "jupyterlab>=4.0.2,<5" hatch
|
||||
jlpm
|
||||
jlpm run build
|
||||
|
||||
- name: Configure git identity to commit
|
||||
run: |
|
||||
git config --global user.email "you@example.com"
|
||||
git config --global user.name "Your Name"
|
||||
- name: Configure git identity to commit
|
||||
run: |
|
||||
git config --global user.email "you@example.com"
|
||||
git config --global user.name "Your Name"
|
||||
|
||||
- name: Reset version
|
||||
run: |
|
||||
hatch version 9.8.7
|
||||
jlpm run lerna version 9.8.7 --no-push --force-publish --no-git-tag-version --yes
|
||||
git commit -am "Release 9.8.7"
|
||||
- name: Reset version
|
||||
run: |
|
||||
hatch version 9.8.7
|
||||
jlpm run lerna version 9.8.7 --no-push --force-publish --no-git-tag-version --yes
|
||||
git commit -am "Release 9.8.7"
|
||||
|
||||
- name: Patch Release
|
||||
run: |
|
||||
jlpm release:patch --force
|
||||
- name: Patch Release
|
||||
run: |
|
||||
jlpm release:patch --force
|
||||
|
||||
- name: Minor Release
|
||||
run: |
|
||||
jlpm release:bump minor --force
|
||||
- name: Minor Release
|
||||
run: |
|
||||
jlpm release:bump minor --force
|
||||
|
||||
- name: Release Cycle
|
||||
run: |
|
||||
# beta
|
||||
jlpm release:bump release --force
|
||||
# rc
|
||||
jlpm release:bump release --force
|
||||
# final
|
||||
jlpm release:bump release --force
|
||||
- name: Release Cycle
|
||||
run: |
|
||||
# beta
|
||||
jlpm release:bump release --force
|
||||
# rc
|
||||
jlpm release:bump release --force
|
||||
# final
|
||||
jlpm release:bump release --force
|
||||
|
||||
- name: Major Release
|
||||
run: |
|
||||
jlpm release:bump major --force
|
||||
- name: Major Release
|
||||
run: |
|
||||
jlpm release:bump major --force
|
||||
|
||||
npm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
architecture: 'x64'
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
architecture: 'x64'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U "jupyterlab>=4.0.2,<5" pip
|
||||
jlpm
|
||||
jlpm run build
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U "jupyterlab>=4.0.2,<5" pip
|
||||
jlpm
|
||||
jlpm run build
|
||||
|
5
.github/workflows/check-release.yml
vendored
5
.github/workflows/check-release.yml
vendored
@ -1,12 +1,11 @@
|
||||
name: Check Release
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
branches: ['main']
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents:
|
||||
write
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
||||
|
6
.github/workflows/lock.yml
vendored
6
.github/workflows/lock.yml
vendored
@ -5,10 +5,8 @@ on:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
permissions:
|
||||
issues:
|
||||
write
|
||||
pull-requests:
|
||||
write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
|
16
.github/workflows/prep-release.yml
vendored
16
.github/workflows/prep-release.yml
vendored
@ -1,22 +1,22 @@
|
||||
name: "Step 1: Prep Release"
|
||||
name: 'Step 1: Prep Release'
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version_spec:
|
||||
description: "New Version Specifier"
|
||||
default: "next"
|
||||
description: 'New Version Specifier'
|
||||
default: 'next'
|
||||
required: false
|
||||
branch:
|
||||
description: "The branch to target"
|
||||
description: 'The branch to target'
|
||||
required: false
|
||||
post_version_spec:
|
||||
description: "Post Version Specifier"
|
||||
description: 'Post Version Specifier'
|
||||
required: false
|
||||
since:
|
||||
description: "Use PRs with activity since this date or git reference"
|
||||
description: 'Use PRs with activity since this date or git reference'
|
||||
required: false
|
||||
since_last_stable:
|
||||
description: "Use PRs with activity since the last stable git tag"
|
||||
description: 'Use PRs with activity since the last stable git tag'
|
||||
required: false
|
||||
type: boolean
|
||||
jobs:
|
||||
@ -37,6 +37,6 @@ jobs:
|
||||
since: ${{ github.event.inputs.since }}
|
||||
since_last_stable: ${{ github.event.inputs.since_last_stable }}
|
||||
|
||||
- name: "** Next Step **"
|
||||
- name: '** Next Step **'
|
||||
run: |
|
||||
echo "Optional): Review Draft Release: ${{ steps.prep-release.outputs.release_url }}"
|
||||
|
12
.github/workflows/publish-release.yml
vendored
12
.github/workflows/publish-release.yml
vendored
@ -1,15 +1,15 @@
|
||||
name: "Step 2: Publish Release"
|
||||
name: 'Step 2: Publish Release'
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch:
|
||||
description: "The target branch"
|
||||
description: 'The target branch'
|
||||
required: false
|
||||
release_url:
|
||||
description: "The URL of the draft GitHub release"
|
||||
description: 'The URL of the draft GitHub release'
|
||||
required: false
|
||||
steps_to_skip:
|
||||
description: "Comma separated list of steps to skip"
|
||||
description: 'Comma separated list of steps to skip'
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
@ -41,13 +41,13 @@ jobs:
|
||||
target: ${{ github.event.inputs.target }}
|
||||
release_url: ${{ steps.populate-release.outputs.release_url }}
|
||||
|
||||
- name: "** Next Step **"
|
||||
- name: '** Next Step **'
|
||||
if: ${{ success() }}
|
||||
run: |
|
||||
echo "Verify the final release"
|
||||
echo ${{ steps.finalize-release.outputs.release_url }}
|
||||
|
||||
- name: "** Failure Message **"
|
||||
- name: '** Failure Message **'
|
||||
if: ${{ failure() }}
|
||||
run: |
|
||||
echo "Failed to Publish the Draft Release Url:"
|
||||
|
2
.github/workflows/ui-tests.yml
vendored
2
.github/workflows/ui-tests.yml
vendored
@ -2,7 +2,7 @@ name: UI Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
branches: ['main']
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
|
@ -1,5 +1,6 @@
|
||||
ci:
|
||||
autoupdate_schedule: monthly
|
||||
autoupdate_commit_msg: 'chore: update pre-commit hooks'
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
@ -15,6 +16,7 @@ repos:
|
||||
- id: check-json
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
|
||||
@ -23,16 +25,46 @@ repos:
|
||||
hooks:
|
||||
- id: check-github-workflows
|
||||
|
||||
- repo: https://github.com/psf/black
|
||||
- repo: https://github.com/adamchainz/blacken-docs
|
||||
rev: '1.16.0'
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
additional_dependencies: [black==23.7.0]
|
||||
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 23.7.0
|
||||
hooks:
|
||||
- id: black
|
||||
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: 'v2.2.5'
|
||||
hooks:
|
||||
- id: codespell
|
||||
args: ['-L', 'sur,nd']
|
||||
exclude: |
|
||||
(?x)^(
|
||||
binder/example.ipynb|
|
||||
docs/source/examples/images/FrontendKernel.graffle/data.plist|
|
||||
)$
|
||||
|
||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||
rev: 'v1.10.0'
|
||||
hooks:
|
||||
- id: rst-backticks
|
||||
- id: rst-directive-colons
|
||||
- id: rst-inline-touching-normal
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.0.287
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: ["--fix"]
|
||||
args: ['--fix', '--show-fixes']
|
||||
|
||||
- repo: https://github.com/scientific-python/cookie
|
||||
rev: '2023.08.23'
|
||||
hooks:
|
||||
- id: sp-repo-review
|
||||
additional_dependencies: ['repo-review[cli]']
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
@ -40,7 +72,7 @@ repos:
|
||||
name: prettier
|
||||
entry: 'npm run prettier:files'
|
||||
language: node
|
||||
types_or: [json, ts, tsx, javascript, jsx, css]
|
||||
types_or: [json, ts, tsx, javascript, jsx, css, markdown]
|
||||
stages: [manual]
|
||||
- id: integrity
|
||||
name: integrity
|
||||
|
@ -4,10 +4,10 @@ sphinx:
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3.9"
|
||||
nodejs: "16"
|
||||
python: '3.9'
|
||||
nodejs: '16'
|
||||
python:
|
||||
install:
|
||||
# install notebook itself
|
||||
- method: pip
|
||||
path: ".[docs]"
|
||||
path: '.[docs]'
|
||||
|
@ -1902,7 +1902,7 @@ notebook dashboard are moved to the OS trash vs. deleted permanently).
|
||||
- Change cull_idle_timeout_minimum to 1 from 300 ([2910](https://github.com/jupyter/notebook/pull/2910)).
|
||||
- Config option to shut down server after n seconds with no kernels ([2963](https://github.com/jupyter/notebook/pull/2963)).
|
||||
- Display a "close" button on load notebook error ([3176](https://github.com/jupyter/notebook/pull/3176)).
|
||||
- Add action to command pallette to run CodeMirror's "indentAuto"
|
||||
- Add action to command palette to run CodeMirror's "indentAuto"
|
||||
on selection ([3175](https://github.com/jupyter/notebook/pull/3175)).
|
||||
- Add option to specify extra services ([3158](https://github.com/jupyter/notebook/pull/3158)).
|
||||
- Warn_bad_name should not use global name ([3160](https://github.com/jupyter/notebook/pull/3160)).
|
||||
|
@ -33,7 +33,7 @@ To learn more about Notebook v7: https://jupyter.org/enhancement-proposals/79-no
|
||||
|
||||
### Classic Notebook v6
|
||||
|
||||
Maintainance and security-related issues are now being addressed in the [`6.4.x`](https://github.com/jupyter/notebook/tree/6.4.x) branch.
|
||||
Maintenance and security-related issues are now being addressed in the [`6.4.x`](https://github.com/jupyter/notebook/tree/6.4.x) branch.
|
||||
|
||||
A `6.5.x` branch will be soon created and will depend on [`nbclassic`](https://github.com/jupyter/nbclassic) for the HTML/JavaScript/CSS assets.
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
name: notebook
|
||||
channels:
|
||||
- conda-forge
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- ipywidgets=7.6
|
||||
- jupyterlab=3
|
||||
- jupyterlab-language-pack-fr-FR
|
||||
- jupyterlab-link-share>=0.2
|
||||
- matplotlib
|
||||
- numpy
|
||||
- nodejs
|
||||
- python >=3.10,<3.11
|
||||
- xeus-python
|
||||
- ipywidgets=7.6
|
||||
- jupyterlab=3
|
||||
- jupyterlab-language-pack-fr-FR
|
||||
- jupyterlab-link-share>=0.2
|
||||
- matplotlib
|
||||
- numpy
|
||||
- nodejs
|
||||
- python >=3.10,<3.11
|
||||
- xeus-python
|
||||
|
@ -72,7 +72,7 @@ the same server, and are reachable via `/tree` for NbClassic and
|
||||
## NbClassic and JupyterLab 4.x
|
||||
|
||||
When only JupyterLab 4.x is installed, then NbClassic has to be installed
|
||||
explictly. They will run on the same server, and are reachable via
|
||||
explicitly. They will run on the same server, and are reachable via
|
||||
`/tree` for NbClassic, and `/lab` for JupyterLab.
|
||||
|
||||
## NbClassic Independently
|
||||
|
@ -1,15 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ._version import __version__ # noqa
|
||||
|
||||
|
||||
def _jupyter_server_extension_paths():
|
||||
def _jupyter_server_extension_paths() -> list[dict[str, str]]:
|
||||
return [{"module": "notebook"}]
|
||||
|
||||
|
||||
def _jupyter_server_extension_points():
|
||||
def _jupyter_server_extension_points() -> list[dict[str, Any]]:
|
||||
from .app import JupyterNotebookApp
|
||||
|
||||
return [{"module": "notebook", "app": JupyterNotebookApp}]
|
||||
|
||||
|
||||
def _jupyter_labextension_paths():
|
||||
def _jupyter_labextension_paths() -> list[dict[str, str]]:
|
||||
return [{"src": "labextension", "dest": "@jupyter-notebook/lab-extension"}]
|
||||
|
@ -3,4 +3,4 @@ import sys
|
||||
|
||||
from notebook.app import main
|
||||
|
||||
sys.exit(main())
|
||||
sys.exit(main()) # type:ignore[no-untyped-call]
|
||||
|
@ -21,7 +21,7 @@ _version_regex = re.compile(
|
||||
re.VERBOSE,
|
||||
)
|
||||
|
||||
_version_fields = _version_regex.match(__version__).groupdict() # type:ignore
|
||||
_version_fields = _version_regex.match(__version__).groupdict() # type:ignore[union-attr]
|
||||
|
||||
VersionInfo = namedtuple("VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"])
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
"""Jupyter notebook application."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
import typing as t
|
||||
from os.path import join as pjoin
|
||||
|
||||
from jupyter_client.utils import ensure_async
|
||||
from jupyter_client.utils import ensure_async # type:ignore[attr-defined]
|
||||
from jupyter_core.application import base_aliases
|
||||
from jupyter_core.paths import jupyter_config_dir
|
||||
from jupyter_server.base.handlers import JupyterHandler
|
||||
@ -14,15 +17,19 @@ from jupyter_server.extension.handler import (
|
||||
from jupyter_server.serverapp import flags
|
||||
from jupyter_server.utils import url_escape, url_is_absolute
|
||||
from jupyter_server.utils import url_path_join as ujoin
|
||||
from jupyterlab.commands import ( # type:ignore
|
||||
from jupyterlab.commands import ( # type:ignore[import]
|
||||
get_app_dir,
|
||||
get_user_settings_dir,
|
||||
get_workspaces_dir,
|
||||
)
|
||||
from jupyterlab_server import LabServerApp
|
||||
from jupyterlab_server.config import LabConfig, get_page_config, recursive_update
|
||||
from jupyterlab_server.config import ( # type:ignore[attr-defined]
|
||||
LabConfig,
|
||||
get_page_config,
|
||||
recursive_update,
|
||||
)
|
||||
from jupyterlab_server.handlers import _camelCase, is_url
|
||||
from notebook_shim.shim import NotebookConfigShimMixin # type:ignore
|
||||
from notebook_shim.shim import NotebookConfigShimMixin # type:ignore[import]
|
||||
from tornado import web
|
||||
from traitlets import Bool, Unicode, default
|
||||
|
||||
@ -33,15 +40,17 @@ HERE = os.path.dirname(__file__)
|
||||
app_dir = get_app_dir()
|
||||
version = __version__
|
||||
|
||||
# mypy: disable-error-code="no-untyped-call"
|
||||
|
||||
|
||||
class NotebookBaseHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler):
|
||||
"""The base notebook API handler."""
|
||||
|
||||
@property
|
||||
def custom_css(self):
|
||||
def custom_css(self) -> bool:
|
||||
return self.settings.get("custom_css", True)
|
||||
|
||||
def get_page_config(self):
|
||||
def get_page_config(self) -> dict[str, t.Any]:
|
||||
"""Get the page config."""
|
||||
config = LabConfig()
|
||||
app = self.extensionapp
|
||||
@ -115,7 +124,7 @@ class TreeHandler(NotebookBaseHandler):
|
||||
"""A tree page handler."""
|
||||
|
||||
@web.authenticated
|
||||
async def get(self, path=None):
|
||||
async def get(self, path: str = "") -> None:
|
||||
"""
|
||||
Display appropriate page for given path.
|
||||
|
||||
@ -155,7 +164,7 @@ class ConsoleHandler(NotebookBaseHandler):
|
||||
"""A console page handler."""
|
||||
|
||||
@web.authenticated
|
||||
def get(self, path=None):
|
||||
def get(self, path: str | None = None) -> t.Any:
|
||||
"""Get the console page."""
|
||||
tpl = self.render_template("consoles.html", page_config=self.get_page_config())
|
||||
return self.write(tpl)
|
||||
@ -165,7 +174,7 @@ class TerminalHandler(NotebookBaseHandler):
|
||||
"""A terminal page handler."""
|
||||
|
||||
@web.authenticated
|
||||
def get(self, path=None):
|
||||
def get(self, path: str | None = None) -> t.Any:
|
||||
"""Get the terminal page."""
|
||||
tpl = self.render_template("terminals.html", page_config=self.get_page_config())
|
||||
return self.write(tpl)
|
||||
@ -175,7 +184,7 @@ class FileHandler(NotebookBaseHandler):
|
||||
"""A file page handler."""
|
||||
|
||||
@web.authenticated
|
||||
def get(self, path=None):
|
||||
def get(self, path: str | None = None) -> t.Any:
|
||||
"""Get the file page."""
|
||||
tpl = self.render_template("edit.html", page_config=self.get_page_config())
|
||||
return self.write(tpl)
|
||||
@ -185,7 +194,7 @@ class NotebookHandler(NotebookBaseHandler):
|
||||
"""A notebook page handler."""
|
||||
|
||||
@web.authenticated
|
||||
def get(self, path=None):
|
||||
def get(self, path: str | None = None) -> t.Any:
|
||||
"""Get the notebook page."""
|
||||
tpl = self.render_template("notebooks.html", page_config=self.get_page_config())
|
||||
return self.write(tpl)
|
||||
@ -195,7 +204,7 @@ class CustomCssHandler(NotebookBaseHandler):
|
||||
"""A custom CSS handler."""
|
||||
|
||||
@web.authenticated
|
||||
def get(self):
|
||||
def get(self) -> t.Any:
|
||||
"""Get the custom css file."""
|
||||
|
||||
self.set_header("Content-Type", 'text/css')
|
||||
@ -215,7 +224,7 @@ class CustomCssHandler(NotebookBaseHandler):
|
||||
aliases = dict(base_aliases)
|
||||
|
||||
|
||||
class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
|
||||
class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[misc]
|
||||
"""The notebook server extension app."""
|
||||
|
||||
name = "notebook"
|
||||
@ -228,7 +237,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
|
||||
file_url_prefix = "/tree"
|
||||
load_other_extensions = True
|
||||
app_dir = app_dir
|
||||
subcommands: dict = {}
|
||||
subcommands: dict[str, t.Any] = {}
|
||||
|
||||
expose_app_in_browser = Bool(
|
||||
False,
|
||||
@ -255,39 +264,39 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
|
||||
"Load custom CSS in template html files. Default is True",
|
||||
)
|
||||
|
||||
@default("static_dir")
|
||||
def _default_static_dir(self):
|
||||
@default("static_dir") # type:ignore[misc]
|
||||
def _default_static_dir(self) -> str:
|
||||
return os.path.join(HERE, "static")
|
||||
|
||||
@default("templates_dir")
|
||||
def _default_templates_dir(self):
|
||||
@default("templates_dir") # type:ignore[misc]
|
||||
def _default_templates_dir(self) -> str:
|
||||
return os.path.join(HERE, "templates")
|
||||
|
||||
@default("app_settings_dir")
|
||||
def _default_app_settings_dir(self):
|
||||
@default("app_settings_dir") # type:ignore[misc]
|
||||
def _default_app_settings_dir(self) -> str:
|
||||
return pjoin(app_dir, "settings")
|
||||
|
||||
@default("schemas_dir")
|
||||
def _default_schemas_dir(self):
|
||||
@default("schemas_dir") # type:ignore[misc]
|
||||
def _default_schemas_dir(self) -> str:
|
||||
return pjoin(app_dir, "schemas")
|
||||
|
||||
@default("themes_dir")
|
||||
def _default_themes_dir(self):
|
||||
@default("themes_dir") # type:ignore[misc]
|
||||
def _default_themes_dir(self) -> str:
|
||||
return pjoin(app_dir, "themes")
|
||||
|
||||
@default("user_settings_dir")
|
||||
def _default_user_settings_dir(self):
|
||||
return get_user_settings_dir()
|
||||
@default("user_settings_dir") # type:ignore[misc]
|
||||
def _default_user_settings_dir(self) -> str:
|
||||
return t.cast(str, get_user_settings_dir())
|
||||
|
||||
@default("workspaces_dir")
|
||||
def _default_workspaces_dir(self):
|
||||
return get_workspaces_dir()
|
||||
@default("workspaces_dir") # type:ignore[misc]
|
||||
def _default_workspaces_dir(self) -> str:
|
||||
return t.cast(str, get_workspaces_dir())
|
||||
|
||||
def _prepare_templates(self):
|
||||
def _prepare_templates(self) -> None:
|
||||
super(LabServerApp, self)._prepare_templates()
|
||||
self.jinja2_env.globals.update(custom_css=self.custom_css) # type:ignore
|
||||
self.jinja2_env.globals.update(custom_css=self.custom_css) # type:ignore[has-type]
|
||||
|
||||
def server_extension_is_enabled(self, extension):
|
||||
def server_extension_is_enabled(self, extension: str) -> bool:
|
||||
"""Check if server extension is enabled."""
|
||||
try:
|
||||
extension_enabled = (
|
||||
@ -297,7 +306,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
|
||||
extension_enabled = False
|
||||
return extension_enabled
|
||||
|
||||
def initialize_handlers(self):
|
||||
def initialize_handlers(self) -> None:
|
||||
"""Initialize handlers."""
|
||||
page_config = self.serverapp.web_app.settings.setdefault("page_config_data", {})
|
||||
nbclassic_enabled = self.server_extension_is_enabled("nbclassic")
|
||||
@ -328,7 +337,7 @@ class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
|
||||
self.handlers.append(("/custom/custom.css", CustomCssHandler))
|
||||
super().initialize_handlers()
|
||||
|
||||
def initialize(self, argv=None):
|
||||
def initialize(self, argv: list[str] | None = None) -> None:
|
||||
"""Subclass because the ExtensionApp.initialize() method does not take arguments"""
|
||||
super().initialize()
|
||||
|
||||
|
@ -209,7 +209,7 @@ const opener: JupyterFrontEndPlugin<void> = {
|
||||
const urlParams = new URLSearchParams(parsed.search);
|
||||
let defaultFactory = docRegistry.defaultWidgetFactory(path).name;
|
||||
|
||||
// Explicitely get the default viewers from the settings because
|
||||
// Explicitly get the default viewers from the settings because
|
||||
// JupyterLab might not have had the time to load the settings yet (race condition)
|
||||
// Relevant code: https://github.com/jupyterlab/jupyterlab/blob/d56ff811f39b3c10c6d8b6eb27a94624b753eb53/packages/docmanager-extension/src/index.tsx#L265-L293
|
||||
if (settingRegistry) {
|
||||
|
@ -155,7 +155,7 @@ export class NotebookApp extends JupyterFrontEnd<INotebookShell> {
|
||||
}
|
||||
|
||||
/**
|
||||
* A namespace for App statics.
|
||||
* A namespace for App static items.
|
||||
*/
|
||||
export namespace NotebookApp {
|
||||
/**
|
||||
|
@ -354,7 +354,7 @@ export class SidePanelPalette {
|
||||
},
|
||||
});
|
||||
|
||||
// Keep the disposableDelegate objet to be able to dispose of the item if the widget
|
||||
// Keep the disposableDelegate object to be able to dispose of the item if the widget
|
||||
// is remove from the side panel.
|
||||
this._items.push({
|
||||
widgetId: widget.id,
|
||||
|
@ -85,7 +85,7 @@ const TrustedButton = ({
|
||||
};
|
||||
|
||||
/**
|
||||
* A namespace for TrustedComponent statics.
|
||||
* A namespace for TrustedComponent static methods.
|
||||
*/
|
||||
export namespace TrustedComponent {
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ body[data-notebook='notebooks']
|
||||
width: 11px;
|
||||
}
|
||||
|
||||
/* Cell toolbar adjustements */
|
||||
/* Cell toolbar adjustments */
|
||||
|
||||
body[data-notebook='notebooks'] .jp-cell-toolbar {
|
||||
background: unset;
|
||||
|
@ -96,7 +96,7 @@ const FileActions = ({
|
||||
};
|
||||
|
||||
/**
|
||||
* A namespace for FileActionsComponent statics.
|
||||
* A namespace for FileActionsComponent static functions.
|
||||
*/
|
||||
export namespace FileActionsComponent {
|
||||
/**
|
||||
|
@ -135,9 +135,9 @@ nowarn = "test -W default {args}"
|
||||
|
||||
[tool.hatch.envs.typing]
|
||||
features = ["test"]
|
||||
dependencies = ["mypy>=0.990"]
|
||||
dependencies = ["mypy>=1.5.1"]
|
||||
[tool.hatch.envs.typing.scripts]
|
||||
test = "mypy --install-types --non-interactive {args:notebook tests}"
|
||||
test = "mypy --install-types --non-interactive {args}"
|
||||
|
||||
[tool.hatch.envs.lint]
|
||||
dependencies = [
|
||||
@ -194,7 +194,13 @@ before-build-python = [
|
||||
]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-raXs --durations 10 --color=yes --doctest-modules"
|
||||
minversion = "6.0"
|
||||
xfail_strict = true
|
||||
log_cli_level = "info"
|
||||
addopts = [
|
||||
"-raXs", "--durations=10", "--color=yes", "--doctest-modules",
|
||||
"--showlocals", "--strict-markers", "--strict-config"
|
||||
]
|
||||
testpaths = [
|
||||
"tests/",
|
||||
]
|
||||
@ -227,26 +233,12 @@ relative_files = true
|
||||
source = ["notebook"]
|
||||
|
||||
[tool.mypy]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
no_implicit_optional = true
|
||||
pretty = true
|
||||
show_error_context = true
|
||||
files = "notebook"
|
||||
python_version = "3.8"
|
||||
strict = true
|
||||
show_error_codes = true
|
||||
strict_equality = true
|
||||
strict_optional = true
|
||||
warn_no_return = true
|
||||
warn_return_any = true
|
||||
warn_unused_configs = true
|
||||
warn_unused_ignores = true
|
||||
warn_redundant_casts = true
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = [
|
||||
"ruamel",
|
||||
]
|
||||
ignore_missing_imports = true
|
||||
|
||||
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
|
||||
warn_unreachable = true
|
||||
|
||||
[tool.black]
|
||||
line-length = 100
|
||||
@ -289,3 +281,9 @@ ignore-nested-functions=true
|
||||
ignore-nested-classes=true
|
||||
fail-under=100
|
||||
exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"]
|
||||
|
||||
[tool.repo-review]
|
||||
ignore = ["PY007", "PP308", "GH102", "PC140", "PC180"]
|
||||
|
||||
[tool.codespell]
|
||||
ignore-words-list = "hart,noteable"
|
||||
|
Loading…
Reference in New Issue
Block a user