From 6a1173080a6bd4cf80c06be0027444169e008163 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 10 Sep 2023 19:55:30 -0500 Subject: [PATCH 1/7] adopt sp-repo-review --- .pre-commit-config.yaml | 42 +++++++++++++++++++++++++++++++++++++++-- pyproject.toml | 39 +++++++++++++++++--------------------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e231ea7490..e72d1ca937 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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,52 @@ repos: hooks: - id: check-github-workflows - - repo: https://github.com/psf/black + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.17 + hooks: + - id: mdformat + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: 'v3.0.2' + hooks: + - id: prettier + types_or: [yaml, html] + + - 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'] + + - 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: diff --git a/pyproject.toml b/pyproject.toml index 851051c849..80bf4c584c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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,6 @@ 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"] From 407d0aac3c740fc8e98d621bc202bd1f93e9e468 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 10 Sep 2023 20:04:37 -0500 Subject: [PATCH 2/7] adopt sp-repo-review --- .github/ISSUE_TEMPLATE/bug_report.md | 16 ++-- .github/ISSUE_TEMPLATE/feature_request.md | 8 +- .github/actions/build-dist/action.yml | 6 +- .github/dependabot.yml | 12 +-- .github/jupyterlab-probot.yml | 2 +- .github/workflows/build.yml | 55 ++++++------ .github/workflows/buildutils.yml | 94 ++++++++++---------- .github/workflows/check-release.yml | 5 +- .github/workflows/lock.yml | 6 +- .github/workflows/prep-release.yml | 16 ++-- .github/workflows/publish-release.yml | 12 +-- .github/workflows/ui-tests.yml | 2 +- .pre-commit-config.yaml | 6 ++ .readthedocs.yaml | 6 +- CHANGELOG.md | 2 +- README.md | 4 +- binder/environment.yml | 20 ++--- docs/source/migrate_to_notebook7.md | 4 +- docs/source/migrating/frontend-extensions.md | 9 +- docs/source/migrating/multiple-interfaces.md | 6 +- docs/source/notebook.md | 12 +-- docs/source/notebook_7_features.md | 8 +- notebook/templates/consoles.html | 84 +++++++++-------- notebook/templates/edit.html | 74 +++++++-------- notebook/templates/notebooks.html | 84 +++++++++-------- notebook/templates/terminals.html | 84 +++++++++-------- notebook/templates/tree.html | 84 +++++++++-------- packages/application-extension/src/index.ts | 2 +- packages/application/src/app.ts | 2 +- packages/application/src/panelhandler.ts | 2 +- packages/notebook-extension/src/trusted.tsx | 2 +- packages/notebook-extension/style/base.css | 2 +- packages/tree-extension/src/fileactions.tsx | 2 +- pyproject.toml | 3 + 34 files changed, 383 insertions(+), 353 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index d9e70611ba..79f86a1c61 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,8 +1,6 @@ ---- -name: "\U0001F41B Bug report" -about: Create a report to help us repair something that is currently broken -labels: bug, status:Needs Triage ---- +______________________________________________________________________ + +## name: "\\U0001F41B Bug report" about: Create a report to help us repair something that is currently broken labels: bug, status:Needs Triage @@ -35,9 +33,9 @@ Here, we're looking for specific bugs in the Jupyter Notebook codebase. If you t 1. Go to '...' -2. Click on '...' -3. Scroll down to '...' -4. See error '...' +1. Click on '...' +1. Scroll down to '...' +1. See error '...' @@ -52,7 +50,9 @@ https://jupyter-notebook.readthedocs.io/en/latest/troubleshooting.html --> - Operating System and version: - Browser and version: + + - Jupyter Notebook version: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 4904f7223d..74642eae3e 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,8 +1,6 @@ ---- -name: "\U0001F680 Feature Request" -about: Suggest a new feature or a change -labels: enhancement, status:Needs Triage ---- +______________________________________________________________________ + +## name: "\\U0001F680 Feature Request" about: Suggest a new feature or a change labels: enhancement, status:Needs Triage diff --git a/.github/actions/build-dist/action.yml b/.github/actions/build-dist/action.yml index 18a6f2e25b..b5197af1c0 100644 --- a/.github/actions/build-dist/action.yml +++ b/.github/actions/build-dist/action.yml @@ -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 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cbd920f6b3..489940db19 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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' diff --git a/.github/jupyterlab-probot.yml b/.github/jupyterlab-probot.yml index d67026659a..bc128e6679 100644 --- a/.github/jupyterlab-probot.yml +++ b/.github/jupyterlab-probot.yml @@ -1,2 +1,2 @@ addBinderLink: false -triageLabel: "status:Needs Triage" +triageLabel: 'status:Needs Triage' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4504b7f4a..1006fcc62e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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@v3 + - name: Checkout + uses: actions/checkout@v3 - - 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@v3 + - name: Checkout + uses: actions/checkout@v3 - - 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@v3 - 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 . diff --git a/.github/workflows/buildutils.yml b/.github/workflows/buildutils.yml index 41d2fb32cc..15aae26af5 100644 --- a/.github/workflows/buildutils.yml +++ b/.github/workflows/buildutils.yml @@ -18,64 +18,64 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - 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@v3 + - name: Checkout + uses: actions/checkout@v3 - - 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 diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index a537636a8a..b8eb65422f 100644 --- a/.github/workflows/check-release.yml +++ b/.github/workflows/check-release.yml @@ -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 }} diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index e84180046f..7b04bca9b0 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -5,10 +5,8 @@ on: - cron: '0 0 * * *' permissions: - issues: - write - pull-requests: - write + issues: write + pull-requests: write jobs: lock: diff --git a/.github/workflows/prep-release.yml b/.github/workflows/prep-release.yml index 7a2a18de75..2ab42761d9 100644 --- a/.github/workflows/prep-release.yml +++ b/.github/workflows/prep-release.yml @@ -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 }}" diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index dbaaeaad24..dd5b779134 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -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:" diff --git a/.github/workflows/ui-tests.yml b/.github/workflows/ui-tests.yml index 31aa44aba1..f2b2ba8aa4 100644 --- a/.github/workflows/ui-tests.yml +++ b/.github/workflows/ui-tests.yml @@ -2,7 +2,7 @@ name: UI Tests on: push: - branches: ["main"] + branches: ['main'] pull_request: concurrency: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e72d1ca937..c3a140e864 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,6 +35,7 @@ repos: hooks: - id: prettier types_or: [yaml, html] + exclude: 'notebook/templates/.*' - repo: https://github.com/adamchainz/blacken-docs rev: '1.16.0' @@ -52,6 +53,11 @@ repos: 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' diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e5727f9623..52d94a4a32 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -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]' diff --git a/CHANGELOG.md b/CHANGELOG.md index fa84d37860..32ca2a9391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)). diff --git a/README.md b/README.md index f8801be701..2fa389b0b3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The Jupyter notebook is a web-based notebook environment for interactive computing. -![Jupyter notebook example](docs/resources/running_code_med.png 'Jupyter notebook example') +![Jupyter notebook example](docs/resources/running_code_med.png "Jupyter notebook example") ## Maintained versions @@ -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. diff --git a/binder/environment.yml b/binder/environment.yml index a98d310f21..1260c0a5ef 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -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 diff --git a/docs/source/migrate_to_notebook7.md b/docs/source/migrate_to_notebook7.md index 91c6c1ef81..33a762ac98 100644 --- a/docs/source/migrate_to_notebook7.md +++ b/docs/source/migrate_to_notebook7.md @@ -77,7 +77,7 @@ migrating/custom-themes.md migrating/multiple-interfaces.md ``` -[jep 79]: https://jupyter.org/enhancement-proposals/79-notebook-v7/notebook-v7.html -[team-compass note]: https://github.com/jupyter/notebook-team-compass/issues/5#issuecomment-1085254000 [find replacements for those that are not available]: https://jupyter-notebook.readthedocs.io/en/latest/migrating/frontend-extensions.html#jupyterlab-equivalent-extensions-to-the-classic-notebook +[jep 79]: https://jupyter.org/enhancement-proposals/79-notebook-v7/notebook-v7.html [nbclassic]: https://github.com/jupyter/nbclassic +[team-compass note]: https://github.com/jupyter/notebook-team-compass/issues/5#issuecomment-1085254000 diff --git a/docs/source/migrating/frontend-extensions.md b/docs/source/migrating/frontend-extensions.md index ecd0ee4cea..c9eaeaee8e 100644 --- a/docs/source/migrating/frontend-extensions.md +++ b/docs/source/migrating/frontend-extensions.md @@ -14,14 +14,11 @@ You can check the following resources to see if your extension is available for To get an idea of the extensions available for Notebook 7, you can check the following resources: -- [List of JupyterLab extensions][list of jupyterlab extensions] -- [Awesome Jupyter][awesome jupyter] +- [List of JupyterLab extensions] +- [Awesome Jupyter] These resources are for JupyterLab, but many of them are compatible with Notebook 7 since Notebook 7 is based on JupyterLab. -[list of jupyterlab extensions]: https://jupyterlab-contrib.github.io/extensions.html -[awesome jupyter]: https://github.com/markusschanta/awesome-jupyter#jupyterlab-extensions - ## JupyterLab equivalent extensions to the Classic Notebook The `jupyterlab-contrib` organization maintains a list of extensions to ease the transition from the Classic Notebook to Notebook 7 and / or JupyterLab. @@ -30,4 +27,6 @@ The list is available at the following URL: [Migrating from the Classic Notebook ![a screenshot showing extensions in classic and lab](https://user-images.githubusercontent.com/591645/229616855-94d34762-6666-4edd-a969-e85b285d7094.png) +[awesome jupyter]: https://github.com/markusschanta/awesome-jupyter#jupyterlab-extensions +[list of jupyterlab extensions]: https://jupyterlab-contrib.github.io/extensions.html [migrate from classic]: https://jupyterlab-contrib.github.io/migrate_from_classical.html diff --git a/docs/source/migrating/multiple-interfaces.md b/docs/source/migrating/multiple-interfaces.md index c6e976500e..649ac465a2 100644 --- a/docs/source/migrating/multiple-interfaces.md +++ b/docs/source/migrating/multiple-interfaces.md @@ -13,8 +13,6 @@ You can try JupyterLab, Notebook 7 and NBClassic installed together using [this [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gist/jtpio/35a72862c8be13dee31b61ebac2d9786/master?urlpath=/tree) -[lab-nb-nbclassic]: https://gist.github.com/jtpio/35a72862c8be13dee31b61ebac2d9786 - ## Using the `Interface` dropdown Notebook 7 provides a dropdown menu to switch between the different user interfaces available on the same server. @@ -72,7 +70,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 @@ -86,3 +84,5 @@ way to view the NbClassic frontend. You would be able to manually enable the extension when running an instance of Jupyter Server, `> jupyter server --ServerApp.jpserver_extensions="nbclassic=True"`, which will provide the NbClassic frontend at `/tree` path when visited. + +[lab-nb-nbclassic]: https://gist.github.com/jtpio/35a72862c8be13dee31b61ebac2d9786 diff --git a/docs/source/notebook.md b/docs/source/notebook.md index 1eab1b8fa1..fb046e2e30 100644 --- a/docs/source/notebook.md +++ b/docs/source/notebook.md @@ -37,8 +37,8 @@ notebook and its dependencies. computations attached to the code which generated them. - Displaying the result of computation using rich media representations, such as HTML, LaTeX, PNG, SVG, etc. For example, publication-quality figures - rendered by the [matplotlib] library, can be included inline. -- In-browser editing for rich text using the [Markdown] markup language, which + rendered by the \[matplotlib\] library, can be included inline. +- In-browser editing for rich text using the \[Markdown\] markup language, which can provide commentary for the code, is not limited to plain text. - The ability to easily include mathematical notation within markdown cells using LaTeX, and rendered natively by [MathJax]. @@ -56,14 +56,14 @@ colleagues. Notebooks may be exported to a range of static formats, including HTML (for example, for blog posts), reStructuredText, LaTeX, PDF, and slide shows, via -the [nbconvert] command. +the \[nbconvert\] command. Furthermore, any `.ipynb` notebook document available from a public URL can be shared via the Jupyter Notebook Viewer \. This service loads the notebook document from the URL and renders it as a static web page. The results may thus be shared with a colleague, or as a public blog post, without other users needing to install the Jupyter notebook -themselves. In effect, nbviewer is simply [nbconvert] as +themselves. In effect, nbviewer is simply \[nbconvert\] as a web service, so you can do your own static conversions with nbconvert, without relying on nbviewer. @@ -278,7 +278,7 @@ the IPython session. _Raw_ cells provide a place in which you can write _output_ directly. Raw cells are not evaluated by the notebook. -When passed through [nbconvert], raw cells arrive in the +When passed through \[nbconvert\], raw cells arrive in the destination format unmodified. For example, you can type full LaTeX into a raw cell, which will only be rendered by LaTeX after conversion by nbconvert. @@ -349,7 +349,7 @@ document content to the browser at the expense of performance. One major feature of the Jupyter notebook is the ability to display plots that are the output of running code cells. The IPython kernel is designed to work -seamlessly with the [matplotlib] plotting library to provide this functionality. +seamlessly with the \[matplotlib\] plotting library to provide this functionality. Specific plotting library integration is a feature of the kernel. ## Installing kernels diff --git a/docs/source/notebook_7_features.md b/docs/source/notebook_7_features.md index c51697b20c..ad2aad6344 100644 --- a/docs/source/notebook_7_features.md +++ b/docs/source/notebook_7_features.md @@ -1,6 +1,6 @@ # New features in Notebook 7 -This document describes the new features in Notebook 7 as originally mentioned in the related Jupyter Enhancement Proposal [JEP 79][jep 79]. +This document describes the new features in Notebook 7 as originally mentioned in the related Jupyter Enhancement Proposal [JEP 79]. ```{contents} Table of Contents :depth: 3 @@ -124,12 +124,10 @@ pip install jupyterlab-rise ## A document-centric user experience -Despite all the new features and as stated in [JEP 79][jep 79], Notebook 7 keeps the document-centric user experience of the Classic Notebook: +Despite all the new features and as stated in [JEP 79], Notebook 7 keeps the document-centric user experience of the Classic Notebook: > The Jupyter Notebook application offers a document-centric user experience. That is, in the Notebook application, the landing page that contains a file manager, running tools tab, and a few optional extras, is a launching point into opening standalone, individual documents. This document-centric experience is important for many users, and that is the first key point this proposal aims to preserve. Notebook v7 will be based on a different JavaScript implementation than v6, but it will preserve the document-centric experience, where each individual notebook opens in a separate browser tab and the visible tools and menus are focused on the open document. -[jep 79]: https://jupyter.org/enhancement-proposals/79-notebook-v7/notebook-v7.html - ## Compact View on Mobile Devices Notebook 7 automatically switches to a more compact layout on mobile devices, making it convenient to run code on the go. @@ -142,3 +140,5 @@ This was just a quick overview of the new features in Notebook 7. For more detai - The [JupyterLab Documentation](https://jupyterlab.readthedocs.io/en/latest/) is a great resource to learn more about JupyterLab and the extensions available. Since Notebook 7 is based on JupyterLab, many of the features and extensions available for JupyterLab are also available for Notebook 7. - [Migration Guide](./migrate_to_notebook7.md) for Notebook 7, which explains how to migrate from the Classic Notebook to Notebook 7. + +[jep 79]: https://jupyter.org/enhancement-proposals/79-notebook-v7/notebook-v7.html diff --git a/notebook/templates/consoles.html b/notebook/templates/consoles.html index 00fa72d3e5..8af8dca9b5 100644 --- a/notebook/templates/consoles.html +++ b/notebook/templates/consoles.html @@ -1,43 +1,49 @@ - + - - - - {{page_config['appName'] | e}} - Console - {% block favicon %} - - {% endblock %} + + + + {{page_config['appName'] | e}} - Console + {% block favicon %} + + {% endblock %} {% if custom_css %} + + {% endif %} + + + {# Copy so we do not modify the page_config with updates. #} {% set + page_config_full = page_config.copy() %} {# Set a dummy variable - we just + want the side effect of the update. #} {% set _ = + page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} {# Sentinel value + to say that we are on the tree page #} {% set _ = + page_config_full.update(notebookPage='consoles') %} - {% if custom_css %} - - {% endif %} - - + + - {# Copy so we do not modify the page_config with updates. #} - {% set page_config_full = page_config.copy() %} - - {# Set a dummy variable - we just want the side effect of the update. #} - {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} - - {# Sentinel value to say that we are on the tree page #} - {% set _ = page_config_full.update(notebookPage='consoles') %} - - - - - - - + + diff --git a/notebook/templates/edit.html b/notebook/templates/edit.html index 9a4548b5ad..4acef12523 100644 --- a/notebook/templates/edit.html +++ b/notebook/templates/edit.html @@ -1,39 +1,43 @@ - + - - - - {{page_config['appName'] | e}} - Edit - {% block favicon %} - - {% endblock %} - - + + + + {{page_config['appName'] | e}} - Edit + {% block favicon %} + + {% endblock %} + + + {# Copy so we do not modify the page_config with updates. #} {% set + page_config_full = page_config.copy() %} {# Set a dummy variable - we just + want the side effect of the update. #} {% set _ = + page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} {# Sentinel value + to say that we are on the tree page #} {% set _ = + page_config_full.update(notebookPage='edit') %} - {# Copy so we do not modify the page_config with updates. #} - {% set page_config_full = page_config.copy() %} + + - {# Set a dummy variable - we just want the side effect of the update. #} - {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} - - {# Sentinel value to say that we are on the tree page #} - {% set _ = page_config_full.update(notebookPage='edit') %} - - - - - - - + + diff --git a/notebook/templates/notebooks.html b/notebook/templates/notebooks.html index 22107558f1..19267ba36b 100644 --- a/notebook/templates/notebooks.html +++ b/notebook/templates/notebooks.html @@ -1,43 +1,49 @@ - + - - - - {{page_config['appName'] | e}} - Notebook - {% block favicon %} - - {% endblock %} + + + + {{page_config['appName'] | e}} - Notebook + {% block favicon %} + + {% endblock %} {% if custom_css %} + + {% endif %} + + + {# Copy so we do not modify the page_config with updates. #} {% set + page_config_full = page_config.copy() %} {# Set a dummy variable - we just + want the side effect of the update. #} {% set _ = + page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} {# Sentinel value + to say that we are on the tree page #} {% set _ = + page_config_full.update(notebookPage='notebooks') %} - {% if custom_css %} - - {% endif %} - - + + - {# Copy so we do not modify the page_config with updates. #} - {% set page_config_full = page_config.copy() %} - - {# Set a dummy variable - we just want the side effect of the update. #} - {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} - - {# Sentinel value to say that we are on the tree page #} - {% set _ = page_config_full.update(notebookPage='notebooks') %} - - - - - - - + + diff --git a/notebook/templates/terminals.html b/notebook/templates/terminals.html index fe603df6e8..3b1db435c7 100644 --- a/notebook/templates/terminals.html +++ b/notebook/templates/terminals.html @@ -1,43 +1,49 @@ - + - - - - {{page_config['appName'] | e}} - Terminal - {% block favicon %} - - {% endblock %} + + + + {{page_config['appName'] | e}} - Terminal + {% block favicon %} + + {% endblock %} {% if custom_css %} + + {% endif %} + + + {# Copy so we do not modify the page_config with updates. #} {% set + page_config_full = page_config.copy() %} {# Set a dummy variable - we just + want the side effect of the update. #} {% set _ = + page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} {# Sentinel value + to say that we are on the tree page #} {% set _ = + page_config_full.update(notebookPage='terminals') %} - {% if custom_css %} - - {% endif %} - - + + - {# Copy so we do not modify the page_config with updates. #} - {% set page_config_full = page_config.copy() %} - - {# Set a dummy variable - we just want the side effect of the update. #} - {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} - - {# Sentinel value to say that we are on the tree page #} - {% set _ = page_config_full.update(notebookPage='terminals') %} - - - - - - - + + diff --git a/notebook/templates/tree.html b/notebook/templates/tree.html index a5d2b524de..d78dff08f1 100644 --- a/notebook/templates/tree.html +++ b/notebook/templates/tree.html @@ -1,43 +1,49 @@ - + - - - - Home - {% block favicon %} - - {% endblock %} + + + + Home + {% block favicon %} + + {% endblock %} {% if custom_css %} + + {% endif %} + + + {# Copy so we do not modify the page_config with updates. #} {% set + page_config_full = page_config.copy() %} {# Set a dummy variable - we just + want the side effect of the update. #} {% set _ = + page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} {# Sentinel value + to say that we are on the tree page #} {% set _ = + page_config_full.update(notebookPage='tree') %} - {% if custom_css %} - - {% endif %} - - + + - {# Copy so we do not modify the page_config with updates. #} - {% set page_config_full = page_config.copy() %} - - {# Set a dummy variable - we just want the side effect of the update. #} - {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %} - - {# Sentinel value to say that we are on the tree page #} - {% set _ = page_config_full.update(notebookPage='tree') %} - - - - - - - + + diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts index 2497dc59f1..13c02193b5 100644 --- a/packages/application-extension/src/index.ts +++ b/packages/application-extension/src/index.ts @@ -209,7 +209,7 @@ const opener: JupyterFrontEndPlugin = { 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) { diff --git a/packages/application/src/app.ts b/packages/application/src/app.ts index 3a0c5306d0..45ec75774f 100644 --- a/packages/application/src/app.ts +++ b/packages/application/src/app.ts @@ -155,7 +155,7 @@ export class NotebookApp extends JupyterFrontEnd { } /** - * A namespace for App statics. + * A namespace for App static items. */ export namespace NotebookApp { /** diff --git a/packages/application/src/panelhandler.ts b/packages/application/src/panelhandler.ts index 43bd2a2137..6973d99e0b 100644 --- a/packages/application/src/panelhandler.ts +++ b/packages/application/src/panelhandler.ts @@ -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, diff --git a/packages/notebook-extension/src/trusted.tsx b/packages/notebook-extension/src/trusted.tsx index 37a9bd3b19..1a12bb6675 100644 --- a/packages/notebook-extension/src/trusted.tsx +++ b/packages/notebook-extension/src/trusted.tsx @@ -85,7 +85,7 @@ const TrustedButton = ({ }; /** - * A namespace for TrustedComponent statics. + * A namespace for TrustedComponent static methods. */ export namespace TrustedComponent { /** diff --git a/packages/notebook-extension/style/base.css b/packages/notebook-extension/style/base.css index 9b391a399c..7e6d5f92e8 100644 --- a/packages/notebook-extension/style/base.css +++ b/packages/notebook-extension/style/base.css @@ -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; diff --git a/packages/tree-extension/src/fileactions.tsx b/packages/tree-extension/src/fileactions.tsx index 8fc7414291..87b03119bd 100644 --- a/packages/tree-extension/src/fileactions.tsx +++ b/packages/tree-extension/src/fileactions.tsx @@ -96,7 +96,7 @@ const FileActions = ({ }; /** - * A namespace for FileActionsComponent statics. + * A namespace for FileActionsComponent static functions. */ export namespace FileActionsComponent { /** diff --git a/pyproject.toml b/pyproject.toml index 80bf4c584c..5d5643576b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -284,3 +284,6 @@ exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"] [tool.repo-review] ignore = ["PY007", "PP308", "GH102", "PC140"] + +[tool.codespell] +ignore-words-list = "hart,noteable" From af6068225c1f3784d546e03389237a24b366821d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 10 Sep 2023 20:22:36 -0500 Subject: [PATCH 3/7] fix typing --- notebook/__init__.py | 10 ++++-- notebook/__main__.py | 2 +- notebook/_version.py | 2 +- notebook/app.py | 81 +++++++++++++++++++++++++------------------- 4 files changed, 55 insertions(+), 40 deletions(-) diff --git a/notebook/__init__.py b/notebook/__init__.py index 3aebf59f23..8cb25b7c2b 100644 --- a/notebook/__init__.py +++ b/notebook/__init__.py @@ -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"}] diff --git a/notebook/__main__.py b/notebook/__main__.py index 952b18ddff..c05250a257 100644 --- a/notebook/__main__.py +++ b/notebook/__main__.py @@ -3,4 +3,4 @@ from notebook.app import main -sys.exit(main()) +sys.exit(main()) # type:ignore[no-untyped-call] diff --git a/notebook/_version.py b/notebook/_version.py index 488b177a23..504f8bd92a 100644 --- a/notebook/_version.py +++ b/notebook/_version.py @@ -21,7 +21,7 @@ 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"]) diff --git a/notebook/app.py b/notebook/app.py index 446088f9be..d5a3b75b35 100644 --- a/notebook/app.py +++ b/notebook/app.py @@ -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,21 @@ 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 ( + LabConfig, + get_page_config, + recursive_update, +) + +# type:ignore[attr-defined] 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 +42,17 @@ 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 +126,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 +166,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 +176,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 +186,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 +196,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 +206,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 +226,7 @@ def get(self): aliases = dict(base_aliases) -class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): +class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp): # type:ignore[misc] """The notebook server extension app.""" name = "notebook" @@ -228,7 +239,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 +266,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 +308,7 @@ def server_extension_is_enabled(self, extension): 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 +339,7 @@ def initialize_handlers(self): 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() From 307f12704bfe28c03dbe6962a64fdc8b902258e5 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 10 Sep 2023 20:22:58 -0500 Subject: [PATCH 4/7] fix typing --- notebook/app.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/notebook/app.py b/notebook/app.py index d5a3b75b35..dc4b6d038e 100644 --- a/notebook/app.py +++ b/notebook/app.py @@ -23,13 +23,11 @@ get_workspaces_dir, ) from jupyterlab_server import LabServerApp -from jupyterlab_server.config import ( +from jupyterlab_server.config import ( # type:ignore[attr-defined] LabConfig, get_page_config, recursive_update, ) - -# type:ignore[attr-defined] from jupyterlab_server.handlers import _camelCase, is_url from notebook_shim.shim import NotebookConfigShimMixin # type:ignore[import] from tornado import web From 485be7aa868271eed3378398c23cdf2bcff66767 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 10 Sep 2023 20:36:01 -0500 Subject: [PATCH 5/7] undo redundant formatting --- .pre-commit-config.yaml | 14 +------------- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c3a140e864..436e10e72d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,18 +25,6 @@ repos: hooks: - id: check-github-workflows - - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 - hooks: - - id: mdformat - - - repo: https://github.com/pre-commit/mirrors-prettier - rev: 'v3.0.2' - hooks: - - id: prettier - types_or: [yaml, html] - exclude: 'notebook/templates/.*' - - repo: https://github.com/adamchainz/blacken-docs rev: '1.16.0' hooks: @@ -84,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 diff --git a/pyproject.toml b/pyproject.toml index 5d5643576b..d1d30a50ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -283,7 +283,7 @@ fail-under=100 exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"] [tool.repo-review] -ignore = ["PY007", "PP308", "GH102", "PC140"] +ignore = ["PY007", "PP308", "GH102", "PC140", "PC180"] [tool.codespell] ignore-words-list = "hart,noteable" From 6ea21e1f5bb02689b18e61bbd5fd73fa8df71b99 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 10 Sep 2023 20:39:35 -0500 Subject: [PATCH 6/7] undo markdown changes --- .github/ISSUE_TEMPLATE/bug_report.md | 16 ++++++++-------- .github/ISSUE_TEMPLATE/feature_request.md | 8 +++++--- docs/source/migrate_to_notebook7.md | 4 ++-- docs/source/migrating/frontend-extensions.md | 9 +++++---- docs/source/migrating/multiple-interfaces.md | 4 ++-- docs/source/notebook.md | 12 ++++++------ docs/source/notebook_7_features.md | 8 ++++---- 7 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 79f86a1c61..d9e70611ba 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,8 @@ -______________________________________________________________________ - -## name: "\\U0001F41B Bug report" about: Create a report to help us repair something that is currently broken labels: bug, status:Needs Triage +--- +name: "\U0001F41B Bug report" +about: Create a report to help us repair something that is currently broken +labels: bug, status:Needs Triage +--- @@ -33,9 +35,9 @@ Here, we're looking for specific bugs in the Jupyter Notebook codebase. If you t 1. Go to '...' -1. Click on '...' -1. Scroll down to '...' -1. See error '...' +2. Click on '...' +3. Scroll down to '...' +4. See error '...' @@ -50,9 +52,7 @@ https://jupyter-notebook.readthedocs.io/en/latest/troubleshooting.html --> - Operating System and version: - Browser and version: - - - Jupyter Notebook version: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 74642eae3e..4904f7223d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,6 +1,8 @@ -______________________________________________________________________ - -## name: "\\U0001F680 Feature Request" about: Suggest a new feature or a change labels: enhancement, status:Needs Triage +--- +name: "\U0001F680 Feature Request" +about: Suggest a new feature or a change +labels: enhancement, status:Needs Triage +--- diff --git a/docs/source/migrate_to_notebook7.md b/docs/source/migrate_to_notebook7.md index 33a762ac98..91c6c1ef81 100644 --- a/docs/source/migrate_to_notebook7.md +++ b/docs/source/migrate_to_notebook7.md @@ -77,7 +77,7 @@ migrating/custom-themes.md migrating/multiple-interfaces.md ``` -[find replacements for those that are not available]: https://jupyter-notebook.readthedocs.io/en/latest/migrating/frontend-extensions.html#jupyterlab-equivalent-extensions-to-the-classic-notebook [jep 79]: https://jupyter.org/enhancement-proposals/79-notebook-v7/notebook-v7.html -[nbclassic]: https://github.com/jupyter/nbclassic [team-compass note]: https://github.com/jupyter/notebook-team-compass/issues/5#issuecomment-1085254000 +[find replacements for those that are not available]: https://jupyter-notebook.readthedocs.io/en/latest/migrating/frontend-extensions.html#jupyterlab-equivalent-extensions-to-the-classic-notebook +[nbclassic]: https://github.com/jupyter/nbclassic diff --git a/docs/source/migrating/frontend-extensions.md b/docs/source/migrating/frontend-extensions.md index c9eaeaee8e..ecd0ee4cea 100644 --- a/docs/source/migrating/frontend-extensions.md +++ b/docs/source/migrating/frontend-extensions.md @@ -14,11 +14,14 @@ You can check the following resources to see if your extension is available for To get an idea of the extensions available for Notebook 7, you can check the following resources: -- [List of JupyterLab extensions] -- [Awesome Jupyter] +- [List of JupyterLab extensions][list of jupyterlab extensions] +- [Awesome Jupyter][awesome jupyter] These resources are for JupyterLab, but many of them are compatible with Notebook 7 since Notebook 7 is based on JupyterLab. +[list of jupyterlab extensions]: https://jupyterlab-contrib.github.io/extensions.html +[awesome jupyter]: https://github.com/markusschanta/awesome-jupyter#jupyterlab-extensions + ## JupyterLab equivalent extensions to the Classic Notebook The `jupyterlab-contrib` organization maintains a list of extensions to ease the transition from the Classic Notebook to Notebook 7 and / or JupyterLab. @@ -27,6 +30,4 @@ The list is available at the following URL: [Migrating from the Classic Notebook ![a screenshot showing extensions in classic and lab](https://user-images.githubusercontent.com/591645/229616855-94d34762-6666-4edd-a969-e85b285d7094.png) -[awesome jupyter]: https://github.com/markusschanta/awesome-jupyter#jupyterlab-extensions -[list of jupyterlab extensions]: https://jupyterlab-contrib.github.io/extensions.html [migrate from classic]: https://jupyterlab-contrib.github.io/migrate_from_classical.html diff --git a/docs/source/migrating/multiple-interfaces.md b/docs/source/migrating/multiple-interfaces.md index 649ac465a2..2d8fcdd298 100644 --- a/docs/source/migrating/multiple-interfaces.md +++ b/docs/source/migrating/multiple-interfaces.md @@ -13,6 +13,8 @@ You can try JupyterLab, Notebook 7 and NBClassic installed together using [this [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gist/jtpio/35a72862c8be13dee31b61ebac2d9786/master?urlpath=/tree) +[lab-nb-nbclassic]: https://gist.github.com/jtpio/35a72862c8be13dee31b61ebac2d9786 + ## Using the `Interface` dropdown Notebook 7 provides a dropdown menu to switch between the different user interfaces available on the same server. @@ -84,5 +86,3 @@ way to view the NbClassic frontend. You would be able to manually enable the extension when running an instance of Jupyter Server, `> jupyter server --ServerApp.jpserver_extensions="nbclassic=True"`, which will provide the NbClassic frontend at `/tree` path when visited. - -[lab-nb-nbclassic]: https://gist.github.com/jtpio/35a72862c8be13dee31b61ebac2d9786 diff --git a/docs/source/notebook.md b/docs/source/notebook.md index fb046e2e30..1eab1b8fa1 100644 --- a/docs/source/notebook.md +++ b/docs/source/notebook.md @@ -37,8 +37,8 @@ notebook and its dependencies. computations attached to the code which generated them. - Displaying the result of computation using rich media representations, such as HTML, LaTeX, PNG, SVG, etc. For example, publication-quality figures - rendered by the \[matplotlib\] library, can be included inline. -- In-browser editing for rich text using the \[Markdown\] markup language, which + rendered by the [matplotlib] library, can be included inline. +- In-browser editing for rich text using the [Markdown] markup language, which can provide commentary for the code, is not limited to plain text. - The ability to easily include mathematical notation within markdown cells using LaTeX, and rendered natively by [MathJax]. @@ -56,14 +56,14 @@ colleagues. Notebooks may be exported to a range of static formats, including HTML (for example, for blog posts), reStructuredText, LaTeX, PDF, and slide shows, via -the \[nbconvert\] command. +the [nbconvert] command. Furthermore, any `.ipynb` notebook document available from a public URL can be shared via the Jupyter Notebook Viewer \. This service loads the notebook document from the URL and renders it as a static web page. The results may thus be shared with a colleague, or as a public blog post, without other users needing to install the Jupyter notebook -themselves. In effect, nbviewer is simply \[nbconvert\] as +themselves. In effect, nbviewer is simply [nbconvert] as a web service, so you can do your own static conversions with nbconvert, without relying on nbviewer. @@ -278,7 +278,7 @@ the IPython session. _Raw_ cells provide a place in which you can write _output_ directly. Raw cells are not evaluated by the notebook. -When passed through \[nbconvert\], raw cells arrive in the +When passed through [nbconvert], raw cells arrive in the destination format unmodified. For example, you can type full LaTeX into a raw cell, which will only be rendered by LaTeX after conversion by nbconvert. @@ -349,7 +349,7 @@ document content to the browser at the expense of performance. One major feature of the Jupyter notebook is the ability to display plots that are the output of running code cells. The IPython kernel is designed to work -seamlessly with the \[matplotlib\] plotting library to provide this functionality. +seamlessly with the [matplotlib] plotting library to provide this functionality. Specific plotting library integration is a feature of the kernel. ## Installing kernels diff --git a/docs/source/notebook_7_features.md b/docs/source/notebook_7_features.md index ad2aad6344..c51697b20c 100644 --- a/docs/source/notebook_7_features.md +++ b/docs/source/notebook_7_features.md @@ -1,6 +1,6 @@ # New features in Notebook 7 -This document describes the new features in Notebook 7 as originally mentioned in the related Jupyter Enhancement Proposal [JEP 79]. +This document describes the new features in Notebook 7 as originally mentioned in the related Jupyter Enhancement Proposal [JEP 79][jep 79]. ```{contents} Table of Contents :depth: 3 @@ -124,10 +124,12 @@ pip install jupyterlab-rise ## A document-centric user experience -Despite all the new features and as stated in [JEP 79], Notebook 7 keeps the document-centric user experience of the Classic Notebook: +Despite all the new features and as stated in [JEP 79][jep 79], Notebook 7 keeps the document-centric user experience of the Classic Notebook: > The Jupyter Notebook application offers a document-centric user experience. That is, in the Notebook application, the landing page that contains a file manager, running tools tab, and a few optional extras, is a launching point into opening standalone, individual documents. This document-centric experience is important for many users, and that is the first key point this proposal aims to preserve. Notebook v7 will be based on a different JavaScript implementation than v6, but it will preserve the document-centric experience, where each individual notebook opens in a separate browser tab and the visible tools and menus are focused on the open document. +[jep 79]: https://jupyter.org/enhancement-proposals/79-notebook-v7/notebook-v7.html + ## Compact View on Mobile Devices Notebook 7 automatically switches to a more compact layout on mobile devices, making it convenient to run code on the go. @@ -140,5 +142,3 @@ This was just a quick overview of the new features in Notebook 7. For more detai - The [JupyterLab Documentation](https://jupyterlab.readthedocs.io/en/latest/) is a great resource to learn more about JupyterLab and the extensions available. Since Notebook 7 is based on JupyterLab, many of the features and extensions available for JupyterLab are also available for Notebook 7. - [Migration Guide](./migrate_to_notebook7.md) for Notebook 7, which explains how to migrate from the Classic Notebook to Notebook 7. - -[jep 79]: https://jupyter.org/enhancement-proposals/79-notebook-v7/notebook-v7.html From 6916156cb9085218c345dc8cbb54441cfb48338d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 10 Sep 2023 20:52:32 -0500 Subject: [PATCH 7/7] formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fa389b0b3..146c8f58fc 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The Jupyter notebook is a web-based notebook environment for interactive computing. -![Jupyter notebook example](docs/resources/running_code_med.png "Jupyter notebook example") +![Jupyter notebook example](docs/resources/running_code_med.png 'Jupyter notebook example') ## Maintained versions