diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 71cc80e45..000000000 --- a/.flake8 +++ /dev/null @@ -1,18 +0,0 @@ -[flake8] -ignore = E501, W503, E402 -builtins = c, get_config -exclude = - .cache, - .github, - docs, - setup.py -enable-extensions = G -extend-ignore = - G001, G002, G004, G200, G201, G202, - # black adds spaces around ':' - E203, -per-file-ignores = - # B011: Do not call assert False since python -O removes these calls - # F841 local variable 'foo' is assigned to but never used - # B007 Loop control variable - tests/*: B011, F841, B007 diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml deleted file mode 100644 index 1cc04883b..000000000 --- a/.github/workflows/check-release.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Check Release -on: - push: - branches: ["main"] - pull_request: - -concurrency: - group: check-release-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: write - -jobs: - check_release: - runs-on: ubuntu-latest - strategy: - matrix: - group: [check_release, link_check] - fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - name: Install Dependencies - run: | - pip install -e . - - name: Check Release - if: ${{ matrix.group == 'check_release' }} - uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Check Links - if: ${{ matrix.group == 'link_check' }} - uses: jupyter-server/jupyter_releaser/.github/actions/check-links@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a45d9accd..7ea63e53d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,35 +10,32 @@ concurrency: cancel-in-progress: true jobs: - # Run "pre-commit run --all-files --hook-stage=manual" pre-commit: - name: Run pre-commit hook runs-on: ubuntu-latest - timeout-minutes: 5 steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v3 - - name: Run pre-commit - uses: pre-commit/action@v2.0.0 + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/pre-commit@v1 + + check_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2 with: - extra_args: --all-files --hook-stage=manual - - name: Help message if pre-commit fail - if: ${{ failure() }} - run: | - echo "You can install pre-commit hooks to automatically run formatting" - echo "on each commit with:" - echo " pre-commit install" - echo "or you can run by hand on staged files with" - echo " pre-commit run" - echo "or after-the-fact on already committed files with" - echo " pre-commit run --all-files --hook-stage=manual" + token: ${{ secrets.GITHUB_TOKEN }} - build-n-test-n-coverage: - name: Build, test and code coverage + check-links: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1 + + test: runs-on: ${{ matrix.os }} - timeout-minutes: 15 + timeout-minutes: 20 strategy: fail-fast: false @@ -50,53 +47,35 @@ jobs: python-version: "3.9" - os: ubuntu-latest python-version: "pypy-3.8" + - os: ubuntu-latest + python-version: "3.11-dev" - os: macos-latest python-version: "3.8" - - env: - OS: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - - name: Install dependencies - run: | - pip install -e .[test] - pip freeze - + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - name: Run the tests if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(matrix.os, 'windows') }} run: | - args="-vv --cov jupyter_client --cov-branch --cov-report term-missing:skip-covered" - python -m pytest $args --cov-fail-under 70 || python -m pytest $args --lf + hatch run cov:test || hatch run test:test --lf - name: Run the tests on pypy and windows if: ${{ startsWith(matrix.python-version, 'pypy') || startsWith(matrix.os, 'windows') }} run: | # Ignore warnings on Windows and PyPI + pip install -e ".[test]" python -m pytest -vv -W ignore || python -m pytest -vv -W ignore --lf - name: Code coverage - run: codecov + run: | + pip install codecov + codecov docs: runs-on: ubuntu-latest - timeout-minutes: 10 steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - - name: Build the docs - run: | - pip install ".[doc]" - cd docs - make html SPHINXOPTS="-W" + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - run: hatch run docs:build test_miniumum_verisons: name: Test Minimum Versions @@ -152,3 +131,20 @@ jobs: - uses: jupyterlab/maintainer-tools/.github/actions/test-sdist@v1 with: test_command: pytest -vv || pytest -vv --lf + + tests_check: # This job does nothing and is only used for the branch protection + if: always() + needs: + - test + - docs + - check-links + - test_miniumum_verisons + - pre-commit + - test_prereleases + - test_sdist + runs-on: ubuntu-latest + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85c4068d5..2835fdbbc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,10 +26,16 @@ repos: - id: black args: ["--line-length", "100"] - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.1 + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.10.1 hooks: - - id: prettier + - id: validate-pyproject + stages: [manual] + + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.16 + hooks: + - id: mdformat - repo: https://github.com/PyCQA/doc8 rev: v1.0.0 @@ -38,10 +44,11 @@ repos: args: [--max-line-length=200] stages: [manual] - - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + - repo: https://github.com/john-hen/Flake8-pyproject + rev: 1.0.1 hooks: - - id: flake8 + - id: Flake8-pyproject + alias: flake8 additional_dependencies: ["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0"] stages: [manual] diff --git a/readthedocs.yml b/.readthedocs.yaml similarity index 86% rename from readthedocs.yml rename to .readthedocs.yaml index 4b22b960b..856ac9b4d 100644 --- a/readthedocs.yml +++ b/.readthedocs.yaml @@ -6,4 +6,4 @@ python: install: # install jupyter-client itself - method: pip - path: ".[doc]" + path: ".[docs]" diff --git a/CHANGELOG.md b/CHANGELOG.md index 555f57edc..1316fc48b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,16 +49,16 @@ ### Maintenance and upkeep improvements -- [pre-commit.ci] pre-commit autoupdate [#824](https://github.com/jupyter/jupyter_client/pull/824) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#821](https://github.com/jupyter/jupyter_client/pull/821) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#820](https://github.com/jupyter/jupyter_client/pull/820) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#818](https://github.com/jupyter/jupyter_client/pull/818) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#816](https://github.com/jupyter/jupyter_client/pull/816) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#815](https://github.com/jupyter/jupyter_client/pull/815) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#812](https://github.com/jupyter/jupyter_client/pull/812) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#810](https://github.com/jupyter/jupyter_client/pull/810) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#809](https://github.com/jupyter/jupyter_client/pull/809) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#807](https://github.com/jupyter/jupyter_client/pull/807) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#824](https://github.com/jupyter/jupyter_client/pull/824) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#821](https://github.com/jupyter/jupyter_client/pull/821) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#820](https://github.com/jupyter/jupyter_client/pull/820) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#818](https://github.com/jupyter/jupyter_client/pull/818) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#816](https://github.com/jupyter/jupyter_client/pull/816) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#815](https://github.com/jupyter/jupyter_client/pull/815) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#812](https://github.com/jupyter/jupyter_client/pull/812) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#810](https://github.com/jupyter/jupyter_client/pull/810) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#809](https://github.com/jupyter/jupyter_client/pull/809) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#807](https://github.com/jupyter/jupyter_client/pull/807) ([@pre-commit-ci](https://github.com/pre-commit-ci)) ### Contributors to this release @@ -77,7 +77,7 @@ ### Maintenance and upkeep improvements - Fix sphinx 5.0 support [#804](https://github.com/jupyter/jupyter_client/pull/804) ([@blink1073](https://github.com/blink1073)) -- [pre-commit.ci] pre-commit autoupdate [#799](https://github.com/jupyter/jupyter_client/pull/799) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#799](https://github.com/jupyter/jupyter_client/pull/799) ([@pre-commit-ci](https://github.com/pre-commit-ci)) ### Contributors to this release @@ -109,9 +109,9 @@ ### Maintenance and upkeep improvements -- [pre-commit.ci] pre-commit autoupdate [#792](https://github.com/jupyter/jupyter_client/pull/792) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#792](https://github.com/jupyter/jupyter_client/pull/792) ([@pre-commit-ci](https://github.com/pre-commit-ci)) - Use hatch backend [#789](https://github.com/jupyter/jupyter_client/pull/789) ([@blink1073](https://github.com/blink1073)) -- [pre-commit.ci] pre-commit autoupdate [#788](https://github.com/jupyter/jupyter_client/pull/788) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#788](https://github.com/jupyter/jupyter_client/pull/788) ([@pre-commit-ci](https://github.com/pre-commit-ci)) - Use flit build backend [#781](https://github.com/jupyter/jupyter_client/pull/781) ([@blink1073](https://github.com/blink1073)) ### Contributors to this release @@ -132,7 +132,7 @@ ### Maintenance and upkeep improvements - Allow bot PRs to be automatically labeled [#784](https://github.com/jupyter/jupyter_client/pull/784) ([@blink1073](https://github.com/blink1073)) -- [pre-commit.ci] pre-commit autoupdate [#783](https://github.com/jupyter/jupyter_client/pull/783) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#783](https://github.com/jupyter/jupyter_client/pull/783) ([@pre-commit-ci](https://github.com/pre-commit-ci)) ### Contributors to this release @@ -150,8 +150,8 @@ ### Maintenance and upkeep improvements -- [pre-commit.ci] pre-commit autoupdate [#773](https://github.com/jupyter/jupyter_client/pull/773) ([@pre-commit-ci](https://github.com/pre-commit-ci)) -- [pre-commit.ci] pre-commit autoupdate [#770](https://github.com/jupyter/jupyter_client/pull/770) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#773](https://github.com/jupyter/jupyter_client/pull/773) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#770](https://github.com/jupyter/jupyter_client/pull/770) ([@pre-commit-ci](https://github.com/pre-commit-ci)) - Improve mypy config [#769](https://github.com/jupyter/jupyter_client/pull/769) ([@blink1073](https://github.com/blink1073)) - Clean up pre-commit [#768](https://github.com/jupyter/jupyter_client/pull/768) ([@blink1073](https://github.com/blink1073)) @@ -168,7 +168,7 @@ ### Maintenance and upkeep improvements - Include py.typed file [#766](https://github.com/jupyter/jupyter_client/pull/766) ([@blink1073](https://github.com/blink1073)) -- [pre-commit.ci] pre-commit autoupdate [#765](https://github.com/jupyter/jupyter_client/pull/765) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- \[pre-commit.ci\] pre-commit autoupdate [#765](https://github.com/jupyter/jupyter_client/pull/765) ([@pre-commit-ci](https://github.com/pre-commit-ci)) - More Cleanup [#764](https://github.com/jupyter/jupyter_client/pull/764) ([@blink1073](https://github.com/blink1073)) ### Contributors to this release @@ -246,7 +246,7 @@ ### Documentation improvements -- [DOC] improve kernel provisioner doc [#730](https://github.com/jupyter/jupyter_client/pull/730) ([@abzymeinsjtu](https://github.com/abzymeinsjtu)) +- \[DOC\] improve kernel provisioner doc [#730](https://github.com/jupyter/jupyter_client/pull/730) ([@abzymeinsjtu](https://github.com/abzymeinsjtu)) - add changelog for message spec [#525](https://github.com/jupyter/jupyter_client/pull/525) ([@minrk](https://github.com/minrk)) ### Contributors to this release @@ -490,7 +490,7 @@ pull-requests](https://github.com/jupyter/jupyter_client/milestone/27?closed=1) - Drop Travis CI, add GitHub Actions [#586](https://github.com/jupyter/jupyter_client/pull/586) - Adapt KernelManager.\_kernel_spec_manager_changed to observe [#588](https://github.com/jupyter/jupyter_client/pull/588) -- Allow use \~/ in the kernel\'s command or its arguments +- Allow use ~/ in the kernel's command or its arguments [#589](https://github.com/jupyter/jupyter_client/pull/589) - Change wait_for_ready logic [#592](https://github.com/jupyter/jupyter_client/pull/592) - Fix test_session with msgpack v1 [#594](https://github.com/jupyter/jupyter_client/pull/594) @@ -550,12 +550,12 @@ should soon have releases to additionally support async patterns. ## 6.0.0 The git history had to be reworked heavily in merging 5.x and master, so -a link to all the changes at once in github had been left out as it\'s +a link to all the changes at once in github had been left out as it's just confusing. An exciting change in this release is some async support (huge thanks to -\@davidbrochart for doing most of the work)! See linked PR below for -more details, we\'re working on integrating this into nbclient as well +@davidbrochart for doing most of the work)! See linked PR below for +more details, we're working on integrating this into nbclient as well in the near future. New Features: @@ -765,7 +765,9 @@ New features: - Introduce `jupyter run` command for running scripts with a kernel, for instance: - jupyter run --kernel python3 myscript.py + ``` + jupyter run --kernel python3 myscript.py + ``` - New method `.BlockingKernelClient.execute_interactive` for running code and capturing or redisplaying its diff --git a/COPYING.md b/COPYING.md index 7cfb970db..f7874eb9b 100644 --- a/COPYING.md +++ b/COPYING.md @@ -56,5 +56,7 @@ change to one of the Jupyter repositories. With this in mind, the following banner should be used in any source code file to indicate the copyright and license terms: - # Copyright (c) Jupyter Development Team. - # Distributed under the terms of the Modified BSD License. +``` +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. +``` diff --git a/README.md b/README.md index 60d1a2a64..b08c3eb75 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,12 @@ [![Build Status](https://github.com/jupyter/jupyter_client/workflows/CI/badge.svg)](https://github.com/jupyter/jupyter_client/actions) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -`jupyter_client` contains the reference implementation of the [Jupyter protocol][]. +`jupyter_client` contains the reference implementation of the [Jupyter protocol]. It also provides client and kernel management APIs for working with kernels. It also provides the `jupyter kernelspec` entrypoint for installing kernelspecs for use with Jupyter frontends. -[jupyter protocol]: https://jupyter-client.readthedocs.io/en/latest/messaging.html - ## Development Setup The [Jupyter Contributor Guides](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html) provide extensive information on contributing code or documentation to Jupyter projects. The limited instructions below for setting up a development environment are for your convenience. @@ -79,3 +77,5 @@ yourself after that. Some of the hooks only run on CI by default, but you can invoke them by running with the `--hook-stage manual` argument. + +[jupyter protocol]: https://jupyter-client.readthedocs.io/en/latest/messaging.html diff --git a/docs/migration.md b/docs/migration.md index 8cf19c1f7..6808e9dcc 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -11,9 +11,13 @@ All of the API changes for `KernelManager` and `AsyncKernelManager` in the 7.0 r The following internal methods had signature changes: - `def pre_start_kernel(self, **kwargs) -> Tuple[List[str], Dict[str, Any]]:` + - `pre_start_kernel` now returns a tuple consisting of the formatted kernel startup list and an updated set of keyword arguments. + - `def _launch_kernel(self, kernel_cmd: List[str], **kw) -> None:` + - `_launch_kernel` now returns `None` instead of the `Popen` instance + - These methods now take the keyword argument `restart` indicating the shutdown was on behalf of a kernel restart (when `True`). - `def finish_shutdown(self, restart: bool = False):` diff --git a/pyproject.toml b/pyproject.toml index 4ffa86315..240179ff0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,8 +50,7 @@ Homepage = "https://jupyter.org" test = [ "codecov", "coverage", - "ipykernel>=6.12", - "ipython", + "ipykernel>=6.11", "mypy", "pre-commit", "pytest", @@ -59,7 +58,7 @@ test = [ "pytest-cov", "pytest-timeout", ] -doc = [ +docs = [ "ipykernel", "myst-parser", "sphinx>=1.3.6", @@ -77,6 +76,26 @@ local-provisioner = "jupyter_client.provisioning:LocalProvisioner" [tool.hatch.version] path = "jupyter_client/_version.py" +validate-bump = false + +[tool.hatch.envs.docs] +features = ["docs"] +[tool.hatch.envs.docs.scripts] +build = "make -C docs html SPHINXOPTS='-W'" + +[tool.hatch.envs.test] +features = ["test"] +[tool.hatch.envs.test.scripts] +test = "python -m pytest -vv {args}" +nowarn = "python -m pytest -vv -W default {args}" + +[tool.hatch.envs.cov] +features = ["test"] +dependencies = ["coverage", "pytest-cov"] +[tool.hatch.envs.cov.env-vars] +ARGS = "-vv --cov jupyter_core --cov-branch --cov-report term-missing:skip-covered" +[tool.hatch.envs.cov.scripts] +test = "python -m pytest $ARGS --cov-fail-under 70 {args}" [tool.black] line-length = 100 @@ -88,9 +107,6 @@ target_version = [ "py310", ] -[tool.jupyter-releaser] -skip = ["check-links"] - [tool.pytest.ini_options] addopts = "-raXs --durations 10 --color=yes --doctest-modules" testpaths = [ @@ -131,3 +147,25 @@ module = [ "entrypoints" ] ignore_missing_imports = true + +[tool.flake8] +ignore = "E501, W503, E402" +builtins = "c, get_config" +exclude = [ + ".cache", + ".github", + "docs", + "setup.py", +] +enable-extensions = "G" +extend-ignore = [ + "G001", "G002", "G004", "G200", "G201", "G202", + # black adds spaces around ':' + "E203", +] +per-file-ignores = [ + # B011: Do not call assert False since python -O removes these calls + # F841 local variable 'foo' is assigned to but never used + # B007 Loop control variable + "tests/*: B011", "F841", "B007", +]