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 585fed67d7..b2f9b4a9d8 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@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 . diff --git a/.github/workflows/buildutils.yml b/.github/workflows/buildutils.yml index 3d83df76db..24929cc0e5 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@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 diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index b27d33f453..f6ceb3ccaa 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 c6b1531060..8d407248c2 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 e231ea7490..436e10e72d 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,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 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..146c8f58fc 100644 --- a/README.md +++ b/README.md @@ -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/migrating/multiple-interfaces.md b/docs/source/migrating/multiple-interfaces.md index c6e976500e..2d8fcdd298 100644 --- a/docs/source/migrating/multiple-interfaces.md +++ b/docs/source/migrating/multiple-interfaces.md @@ -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 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..dc4b6d038e 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,19 @@ 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 @@ 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 @@ 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 +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 @@ 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 +337,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() 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 851051c849..d1d30a50ce 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,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"