diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c6a54738..728482ffa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,30 @@ defaults: shell: bash jobs: + # Run "pre-commit run --all-files" + pre-commit: + runs-on: ubuntu-20.04 + timeout-minutes: 2 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + + # ref: https://github.com/pre-commit/action + - uses: pre-commit/action@v2.0.0 + - 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" + build: runs-on: ${{ matrix.os }} strategy: @@ -29,53 +53,53 @@ jobs: - os: macos-latest python-version: "3.8" steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - - name: Install the Python dependencies - run: | - pip install .[test] codecov - - - name: Install matplotlib - if: ${{ !startsWith(matrix.os, 'macos') && !startsWith(matrix.python-version, 'pypy') }} - run: | - pip install matplotlib || echo 'failed to install matplotlib' - - - name: Install alternate event loops - if: ${{ !startsWith(matrix.os, 'windows') }} - run: | - pip install curio || echo 'ignoring curio install failure' - pip install trio || echo 'ignoring trio install failure' - - - name: List installed packages - run: | - pip uninstall pipx -y - pip install pipdeptree - pipdeptree - pipdeptree --reverse - pip freeze - pip check - - - name: Run the tests - timeout-minutes: 15 - if: ${{ !startsWith( matrix.python-version, 'pypy' ) && !startsWith(matrix.os, 'windows') }} - run: | - cmd="python -m pytest -vv -raXs --cov ipykernel --cov-branch --cov-report term-missing:skip-covered --durations 10 --color=yes" - $cmd || $cmd --lf - - - name: Run the tests on pypy and windows - timeout-minutes: 15 - if: ${{ startsWith( matrix.python-version, 'pypy' ) || startsWith(matrix.os, 'windows') }} - run: | - cmd="python -m pytest -vv -raXs --durations 10 --color=yes" - $cmd || $cmd --lf - - - name: Coverage - run: | - codecov + - name: Checkout + uses: actions/checkout@v2 + + - name: Base Setup + uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + + - name: Install the Python dependencies + run: | + pip install .[test] codecov + + - name: Install matplotlib + if: ${{ !startsWith(matrix.os, 'macos') && !startsWith(matrix.python-version, 'pypy') }} + run: | + pip install matplotlib || echo 'failed to install matplotlib' + + - name: Install alternate event loops + if: ${{ !startsWith(matrix.os, 'windows') }} + run: | + pip install curio || echo 'ignoring curio install failure' + pip install trio || echo 'ignoring trio install failure' + + - name: List installed packages + run: | + pip uninstall pipx -y + pip install pipdeptree + pipdeptree + pipdeptree --reverse + pip freeze + pip check + + - name: Run the tests + timeout-minutes: 15 + if: ${{ !startsWith( matrix.python-version, 'pypy' ) && !startsWith(matrix.os, 'windows') }} + run: | + cmd="python -m pytest -vv --cov ipykernel --cov-branch --cov-report term-missing:skip-covered" + $cmd || $cmd --lf + + - name: Run the tests on pypy and windows + timeout-minutes: 15 + if: ${{ startsWith( matrix.python-version, 'pypy' ) || startsWith(matrix.os, 'windows') }} + run: | + cmd="python -m pytest -vv" + $cmd || $cmd --lf + + - name: Coverage + run: | + codecov test_docs: runs-on: ${{ matrix.os }} @@ -83,60 +107,60 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [ '3.9' ] + python-version: ["3.9"] exclude: - - os: windows-latest - python-version: pypy-3.7 + - os: windows-latest + python-version: pypy-3.7 steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 - - 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: Build the docs - run: | - cd docs - pip install -r requirements.txt - make html SPHINXOPTS="-W" + - name: Build the docs + run: | + cd docs + pip install -r requirements.txt + make html SPHINXOPTS="-W" - - name: Install the Python dependencies - run: | - pip install . - pip install velin + - name: Install the Python dependencies + run: | + pip install . + pip install velin - - name: Check Docstrings - run: | - velin . --check --compact + - name: Check Docstrings + run: | + velin . --check --compact test_without_debugpy: - runs-on: ${{ matrix.os }}-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu] - python-version: [ '3.9' ] + os: [ubuntu-latest] + python-version: ["3.9"] steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 - - 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 the Python dependencies without debugpy - run: | - pip install .[test] - pip uninstall --yes debugpy + - name: Install the Python dependencies without debugpy + run: | + pip install .[test] + pip uninstall --yes debugpy - - name: List installed packages - run: | - pip freeze + - name: List installed packages + run: | + pip freeze - - name: Run the tests - timeout-minutes: 10 - run: | - cmd="python -m pytest -vv -raXxs --durations 10 --color=yes" - $cmd || $cmd --lf + - name: Run the tests + timeout-minutes: 10 + run: | + cmd="python -m pytest -vv -raXxs" + $cmd || $cmd --lf test_miniumum_versions: name: Test Minimum Versions @@ -152,7 +176,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1 - name: Run the unit tests run: | - cmd="python -m pytest -vv -raXxs --durations 10 --color=yes" + cmd="python -m pytest -vv -raXxs" $cmd || $cmd --lf test_prereleases: @@ -173,7 +197,7 @@ jobs: pip check - name: Run the tests run: | - cmd="python -m pytest -vv -raXs --durations 10 --color=yes" + cmd="python -m pytest -vv" $cmd || $cmd --lf make_sdist: @@ -214,5 +238,5 @@ jobs: - name: Run Test run: | cd sdist/test - cmd="python -m pytest -vv -raXs --durations 10 --color=yes" + cmd="python -m pytest -vv" $cmd || $cmd --lf diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 26e003a0b..061299943 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -52,7 +52,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 with: package_name: ipyparallel - package_spec: "-e \".[test]\"" + package_spec: '-e ".[test]"' jupyter_kernel_test: runs-on: ubuntu-latest diff --git a/.mailmap b/.mailmap index bd6544e25..e39230250 100644 --- a/.mailmap +++ b/.mailmap @@ -26,7 +26,7 @@ David Hirschfeld dhirschfeld David P. Sanders David Warde-Farley David Warde-Farley <> Doug Blank Doug Blank -Eugene Van den Bulke Eugene Van den Bulke +Eugene Van den Bulke Eugene Van den Bulke Evan Patterson Evan Patterson Evan Patterson diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..25b0bcb3c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,60 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: end-of-file-fixer + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: requirements-txt-fixer + - id: check-added-large-files + - id: check-case-conflict + - id: check-toml + - id: check-yaml + - id: debug-statements + exclude: ipykernel/kernelapp.py + - id: forbid-new-submodules + - id: check-builtin-literals + - id: trailing-whitespace + + # - repo: https://github.com/psf/black + # rev: 22.1.0 + # hooks: + # - id: black + # args: ["--line-length", "100"] + + # - repo: https://github.com/PyCQA/isort + # rev: 5.10.1 + # hooks: + # - id: isort + # files: \.py$ + # args: [--profile=black] + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.5.1 + hooks: + - id: prettier + + # - repo: https://github.com/pycqa/flake8 + # rev: 4.0.1 + # hooks: + # - id: flake8 + # additional_dependencies: + # [ + # "flake8-bugbear==20.1.4", + # "flake8-logging-format==0.6.0", + # "flake8-implicit-str-concat==0.2.0", + # ] + + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.8.0 + hooks: + - id: eslint + + - repo: https://github.com/sirosen/check-jsonschema + rev: 0.10.2 + hooks: + - id: check-jsonschema + name: "Check GitHub Workflows" + files: ^\.github/workflows/ + types: [yaml] + args: ["--schemafile", "https://json.schemastore.org/github-workflow"] diff --git a/CHANGELOG.md b/CHANGELOG.md index 90c46b372..e20fec75f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,7 +119,7 @@ ### Documentation improvements -- Fix title position in changelog [#828](https://github.com/ipython/ipykernel/pull/828) ([@fcollonval](https://github.com/fcollonval)) +- Fix title position in changelog [#828](https://github.com/ipython/ipykernel/pull/828) ([@fcollonval](https://github.com/fcollonval)) ### Contributors to this release @@ -366,30 +366,30 @@ release and welcome any feedback (~50 Pull-requests). IPykernel 6 should contain all changes of the 5.x series, in addition to the following non-exhaustive changes. - - Support for the debugger protocol, when using `JupyterLab`, `RetroLab` or any - frontend supporting the debugger protocol you should have access to the - debugger functionalities. +- Support for the debugger protocol, when using `JupyterLab`, `RetroLab` or any + frontend supporting the debugger protocol you should have access to the + debugger functionalities. - - The control channel on IPykernel 6.0 is run in a separate thread, this may - change the order in which messages are processed, though this change was necessary - to accommodate the debugger. +- The control channel on IPykernel 6.0 is run in a separate thread, this may + change the order in which messages are processed, though this change was necessary + to accommodate the debugger. - - We now have a new dependency: `matplotlib-inline`, this helps to separate the - circular dependency between IPython/IPykernel and matplotlib. +- We now have a new dependency: `matplotlib-inline`, this helps to separate the + circular dependency between IPython/IPykernel and matplotlib. - - On POSIX systems, all outputs to stdout/stderr should now be captured, - including subprocesses and output of compiled libraries (blas, lapack....). - In notebook server, some outputs that would previously go to the notebooks - logs will now both head to notebook logs and in notebooks outputs. In - terminal frontend like Jupyter Console, Emacs or other, this may ends up as - duplicated outputs. +- On POSIX systems, all outputs to stdout/stderr should now be captured, + including subprocesses and output of compiled libraries (blas, lapack....). + In notebook server, some outputs that would previously go to the notebooks + logs will now both head to notebook logs and in notebooks outputs. In + terminal frontend like Jupyter Console, Emacs or other, this may ends up as + duplicated outputs. - - coroutines are now native (async-def) , instead of using tornado's - `@gen.coroutine` +- coroutines are now native (async-def) , instead of using tornado's + `@gen.coroutine` - - OutStreams can now be configured to report `istty() == True`, while this - should make some output nicer (for example colored), it is likely to break - others. Use with care. +- OutStreams can now be configured to report `istty() == True`, while this + should make some output nicer (for example colored), it is likely to break + others. Use with care. ### New features added @@ -471,13 +471,13 @@ following non-exhaustive changes. ### Deprecations in 6.0 - `Kernel`s now support only a single shell stream, multiple streams will now be ignored. The attribute - `Kernel.shell_streams` (plural) is deprecated in ipykernel 6.0. Use `Kernel.shell_stream` (singular) + `Kernel.shell_streams` (plural) is deprecated in ipykernel 6.0. Use `Kernel.shell_stream` (singular) - `Kernel._parent_header` is deprecated, even though it was private. Use `.get_parent()` now. ### Removal in 6.0 - `ipykernel.codeutils` was deprecated since 4.x series (2016) and has been removed, please import similar - functionalities from `ipyparallel` + functionalities from `ipyparallel` - remove `find_connection_file` and `profile` argument of `connect_qtconsole` and `get_connection_info`, deprecated since IPykernel 4.2.2 (2016). ### Contributors to this release @@ -489,116 +489,122 @@ following non-exhaustive changes. ## 5.5 ### 5.5.5 -* Keep preferring SelectorEventLoop on Windows. [#669](https://github.com/ipython/ipykernel/pull/669) + +- Keep preferring SelectorEventLoop on Windows. [#669](https://github.com/ipython/ipykernel/pull/669) ### 5.5.4 -* Import ``configure_inline_support`` from ``matplotlib_inline`` if available [#654](https://github.com/ipython/ipykernel/pull/654) - + +- Import `configure_inline_support` from `matplotlib_inline` if available [#654](https://github.com/ipython/ipykernel/pull/654) + ### 5.5.3 -* Revert Backport of #605: Fix Handling of ``shell.should_run_async`` [#622](https://github.com/ipython/ipykernel/pull/622) + +- Revert Backport of #605: Fix Handling of `shell.should_run_async` [#622](https://github.com/ipython/ipykernel/pull/622) ### 5.5.2 + **Note:** This release was deleted from PyPI since it had breaking changes. -* Changed default timeout to 0.0 seconds for stop_on_error_timeout. [#618](https://github.com/ipython/ipykernel/pull/618) +- Changed default timeout to 0.0 seconds for stop_on_error_timeout. [#618](https://github.com/ipython/ipykernel/pull/618) ### 5.5.1 + **Note:** This release was deleted from PyPI since it had breaking changes. -* Fix Handling of ``shell.should_run_async``. [#605](https://github.com/ipython/ipykernel/pull/605) +- Fix Handling of `shell.should_run_async`. [#605](https://github.com/ipython/ipykernel/pull/605) ### 5.5.0 -* kernelspec: ensure path is writable before writing `kernel.json`. [#593](https://github.com/ipython/ipykernel/pull/593) -* Add `configure_inline_support` and call it in the shell. [#590](https://github.com/ipython/ipykernel/pull/590) -* Fix `stop_on_error_timeout` to now properly abort `execute_request`'s that fall within the timeout after an error. [#572](https://github.com/ipython/ipykernel/pull/572) + +- kernelspec: ensure path is writable before writing `kernel.json`. [#593](https://github.com/ipython/ipykernel/pull/593) +- Add `configure_inline_support` and call it in the shell. [#590](https://github.com/ipython/ipykernel/pull/590) +- Fix `stop_on_error_timeout` to now properly abort `execute_request`'s that fall within the timeout after an error. [#572](https://github.com/ipython/ipykernel/pull/572) ## 5.4 ### 5.4.3 -* Rework `wait_for_ready` logic. [#578](https://github.com/ipython/ipykernel/pull/578) +- Rework `wait_for_ready` logic. [#578](https://github.com/ipython/ipykernel/pull/578) ### 5.4.2 -* Revert \"Fix stop_on_error_timeout blocking other messages in - queue\". [#570](https://github.com/ipython/ipykernel/pull/570) +- Revert \"Fix stop_on_error_timeout blocking other messages in + queue\". [#570](https://github.com/ipython/ipykernel/pull/570) ### 5.4.1 -* Invalid syntax in `ipykernel/log.py`. [#567](https://github.com/ipython/ipykernel/pull/567) +- Invalid syntax in `ipykernel/log.py`. [#567](https://github.com/ipython/ipykernel/pull/567) ### 5.4.0 5.4.0 is generally focused on code quality improvements and tornado asyncio compatibility. -* Add github actions, bail on asyncio patch for tornado 6.1. - [#564](https://github.com/ipython/ipykernel/pull/564) -* Start testing on Python 3.9. [#551](https://github.com/ipython/ipykernel/pull/551) -* Fix stack levels for ipykernel\'s deprecation warnings and stop - using some deprecated APIs. [#547](https://github.com/ipython/ipykernel/pull/547) -* Add env parameter to kernel installation [#541](https://github.com/ipython/ipykernel/pull/541) -* Fix stop_on_error_timeout blocking other messages in queue. - [#539](https://github.com/ipython/ipykernel/pull/539) -* Remove most of the python 2 compat code. [#537](https://github.com/ipython/ipykernel/pull/537) -* Remove u-prefix from strings. [#538](https://github.com/ipython/ipykernel/pull/538) +- Add github actions, bail on asyncio patch for tornado 6.1. + [#564](https://github.com/ipython/ipykernel/pull/564) +- Start testing on Python 3.9. [#551](https://github.com/ipython/ipykernel/pull/551) +- Fix stack levels for ipykernel\'s deprecation warnings and stop + using some deprecated APIs. [#547](https://github.com/ipython/ipykernel/pull/547) +- Add env parameter to kernel installation [#541](https://github.com/ipython/ipykernel/pull/541) +- Fix stop_on_error_timeout blocking other messages in queue. + [#539](https://github.com/ipython/ipykernel/pull/539) +- Remove most of the python 2 compat code. [#537](https://github.com/ipython/ipykernel/pull/537) +- Remove u-prefix from strings. [#538](https://github.com/ipython/ipykernel/pull/538) ## 5.3 ### 5.3.4 -* Only run Qt eventloop in the shell stream. [#531](https://github.com/ipython/ipykernel/pull/531) +- Only run Qt eventloop in the shell stream. [#531](https://github.com/ipython/ipykernel/pull/531) ### 5.3.3 -* Fix QSocketNotifier in the Qt event loop not being disabled for the - control channel. [#525](https://github.com/ipython/ipykernel/pull/525) +- Fix QSocketNotifier in the Qt event loop not being disabled for the + control channel. [#525](https://github.com/ipython/ipykernel/pull/525) ### 5.3.2 -* Restore timer based event loop as a Windows-compatible fallback. - [#523](https://github.com/ipython/ipykernel/pull/523) +- Restore timer based event loop as a Windows-compatible fallback. + [#523](https://github.com/ipython/ipykernel/pull/523) ### 5.3.1 -* Fix \#520: run post_execute and post_run_cell on async cells - [#521](https://github.com/ipython/ipykernel/pull/521) -* Fix exception causes in zmqshell.py [#516](https://github.com/ipython/ipykernel/pull/516) -* Make pdb on Windows interruptible [#490](https://github.com/ipython/ipykernel/pull/490) +- Fix \#520: run post_execute and post_run_cell on async cells + [#521](https://github.com/ipython/ipykernel/pull/521) +- Fix exception causes in zmqshell.py [#516](https://github.com/ipython/ipykernel/pull/516) +- Make pdb on Windows interruptible [#490](https://github.com/ipython/ipykernel/pull/490) ### 5.3.0 5.3.0 Adds support for Trio event loops and has some bug fixes. -* Fix ipython display imports [#509](https://github.com/ipython/ipykernel/pull/509) -* Skip test_unc_paths if OS is not Windows [#507](https://github.com/ipython/ipykernel/pull/507) -* Allow interrupting input() on Windows, as part of effort to make pdb - interruptible [#498](https://github.com/ipython/ipykernel/pull/498) -* Add Trio Loop [#479](https://github.com/ipython/ipykernel/pull/479) -* Flush from process even without newline [#478](https://github.com/ipython/ipykernel/pull/478) +- Fix ipython display imports [#509](https://github.com/ipython/ipykernel/pull/509) +- Skip test_unc_paths if OS is not Windows [#507](https://github.com/ipython/ipykernel/pull/507) +- Allow interrupting input() on Windows, as part of effort to make pdb + interruptible [#498](https://github.com/ipython/ipykernel/pull/498) +- Add Trio Loop [#479](https://github.com/ipython/ipykernel/pull/479) +- Flush from process even without newline [#478](https://github.com/ipython/ipykernel/pull/478) ## 5.2 ### 5.2.1 -* Handle system commands that use UNC paths on Windows - [#500](https://github.com/ipython/ipykernel/pull/500) -* Add offset argument to seek in io test [#496](https://github.com/ipython/ipykernel/pull/496) +- Handle system commands that use UNC paths on Windows + [#500](https://github.com/ipython/ipykernel/pull/500) +- Add offset argument to seek in io test [#496](https://github.com/ipython/ipykernel/pull/496) ### 5.2.0 5.2.0 Includes several bugfixes and internal logic improvements. -* Produce better traceback when kernel is interrupted - [#491](https://github.com/ipython/ipykernel/pull/491) -* Add `InProcessKernelClient.control_channel` for compatibility with - jupyter-client v6.0.0 [#489](https://github.com/ipython/ipykernel/pull/489) -* Drop support for Python 3.4 [#483](https://github.com/ipython/ipykernel/pull/483) -* Work around issue related to Tornado with python3.8 on Windows - ([#480](https://github.com/ipython/ipykernel/pull/480), [#481](https://github.com/ipython/ipykernel/pull/481)) -* Prevent entering event loop if it is None [#464](https://github.com/ipython/ipykernel/pull/464) -* Use `shell.input_transformer_manager` when available - [#411](https://github.com/ipython/ipykernel/pull/411) +- Produce better traceback when kernel is interrupted + [#491](https://github.com/ipython/ipykernel/pull/491) +- Add `InProcessKernelClient.control_channel` for compatibility with + jupyter-client v6.0.0 [#489](https://github.com/ipython/ipykernel/pull/489) +- Drop support for Python 3.4 [#483](https://github.com/ipython/ipykernel/pull/483) +- Work around issue related to Tornado with python3.8 on Windows + ([#480](https://github.com/ipython/ipykernel/pull/480), [#481](https://github.com/ipython/ipykernel/pull/481)) +- Prevent entering event loop if it is None [#464](https://github.com/ipython/ipykernel/pull/464) +- Use `shell.input_transformer_manager` when available + [#411](https://github.com/ipython/ipykernel/pull/411) ## 5.1 @@ -607,48 +613,48 @@ asyncio compatibility. 5.1.4 Includes a few bugfixes, especially for compatibility with Python 3.8 on Windows. -* Fix pickle issues when using inline matplotlib backend - [#476](https://github.com/ipython/ipykernel/pull/476) -* Fix an error during kernel shutdown [#463](https://github.com/ipython/ipykernel/pull/463) -* Fix compatibility issues with Python 3.8 ([#456](https://github.com/ipython/ipykernel/pull/456), [#461](https://github.com/ipython/ipykernel/pull/461)) -* Remove some dead code ([#474](https://github.com/ipython/ipykernel/pull/474), - [#467](https://github.com/ipython/ipykernel/pull/467)) +- Fix pickle issues when using inline matplotlib backend + [#476](https://github.com/ipython/ipykernel/pull/476) +- Fix an error during kernel shutdown [#463](https://github.com/ipython/ipykernel/pull/463) +- Fix compatibility issues with Python 3.8 ([#456](https://github.com/ipython/ipykernel/pull/456), [#461](https://github.com/ipython/ipykernel/pull/461)) +- Remove some dead code ([#474](https://github.com/ipython/ipykernel/pull/474), + [#467](https://github.com/ipython/ipykernel/pull/467)) ### 5.1.3 5.1.3 Includes several bugfixes and internal logic improvements. -* Fix comm shutdown behavior by adding a `deleting` option to `close` - which can be set to prevent registering new comm channels during - shutdown ([#433](https://github.com/ipython/ipykernel/pull/433), [#435](https://github.com/ipython/ipykernel/pull/435)) -* Fix `Heartbeat._bind_socket` to return on the first bind ([#431](https://github.com/ipython/ipykernel/pull/431)) -* Moved `InProcessKernelClient.flush` to `DummySocket` ([#437](https://github.com/ipython/ipykernel/pull/437)) -* Don\'t redirect stdout if nose machinery is not present ([#427](https://github.com/ipython/ipykernel/pull/427)) -* Rename `_asyncio.py` to - `_asyncio_utils.py` to avoid name conflicts on Python - 3.6+ ([#426](https://github.com/ipython/ipykernel/pull/426)) -* Only generate kernelspec when installing or building wheel ([#425](https://github.com/ipython/ipykernel/pull/425)) -* Fix priority ordering of control-channel messages in some cases - [#443](https://github.com/ipython/ipykernel/pull/443) +- Fix comm shutdown behavior by adding a `deleting` option to `close` + which can be set to prevent registering new comm channels during + shutdown ([#433](https://github.com/ipython/ipykernel/pull/433), [#435](https://github.com/ipython/ipykernel/pull/435)) +- Fix `Heartbeat._bind_socket` to return on the first bind ([#431](https://github.com/ipython/ipykernel/pull/431)) +- Moved `InProcessKernelClient.flush` to `DummySocket` ([#437](https://github.com/ipython/ipykernel/pull/437)) +- Don\'t redirect stdout if nose machinery is not present ([#427](https://github.com/ipython/ipykernel/pull/427)) +- Rename `_asyncio.py` to + `_asyncio_utils.py` to avoid name conflicts on Python + 3.6+ ([#426](https://github.com/ipython/ipykernel/pull/426)) +- Only generate kernelspec when installing or building wheel ([#425](https://github.com/ipython/ipykernel/pull/425)) +- Fix priority ordering of control-channel messages in some cases + [#443](https://github.com/ipython/ipykernel/pull/443) ### 5.1.2 5.1.2 fixes some socket-binding race conditions that caused testing failures in nbconvert. -* Fix socket-binding race conditions ([#412](https://github.com/ipython/ipykernel/pull/412), - [#419](https://github.com/ipython/ipykernel/pull/419)) -* Add a no-op `flush` method to `DummySocket` and comply with stream - API ([#405](https://github.com/ipython/ipykernel/pull/405)) -* Update kernel version to indicate kernel v5.3 support ([#394](https://github.com/ipython/ipykernel/pull/394)) -* Add testing for upcoming Python 3.8 and PEP 570 positional - parameters ([#396](https://github.com/ipython/ipykernel/pull/396), [#408](https://github.com/ipython/ipykernel/pull/408)) +- Fix socket-binding race conditions ([#412](https://github.com/ipython/ipykernel/pull/412), + [#419](https://github.com/ipython/ipykernel/pull/419)) +- Add a no-op `flush` method to `DummySocket` and comply with stream + API ([#405](https://github.com/ipython/ipykernel/pull/405)) +- Update kernel version to indicate kernel v5.3 support ([#394](https://github.com/ipython/ipykernel/pull/394)) +- Add testing for upcoming Python 3.8 and PEP 570 positional + parameters ([#396](https://github.com/ipython/ipykernel/pull/396), [#408](https://github.com/ipython/ipykernel/pull/408)) ### 5.1.1 5.1.1 fixes a bug that caused cells to get stuck in a busy state. -* Flush after sending replies [#390](https://github.com/ipython/ipykernel/pull/390) +- Flush after sending replies [#390](https://github.com/ipython/ipykernel/pull/390) ### 5.1.0 @@ -656,13 +662,13 @@ failures in nbconvert. [5.1.0 on GitHub](https://github.com/ipython/ipykernel/milestones/5.1) -* Fix message-ordering bug that could result in out-of-order - executions, especially on Windows [#356](https://github.com/ipython/ipykernel/pull/356) -* Fix classifiers to indicate dropped Python 2 support - [#354](https://github.com/ipython/ipykernel/pull/354) -* Remove some dead code [#355](https://github.com/ipython/ipykernel/pull/355) -* Support rich-media responses in `inspect_requests` (tooltips) - [#361](https://github.com/ipython/ipykernel/pull/361) +- Fix message-ordering bug that could result in out-of-order + executions, especially on Windows [#356](https://github.com/ipython/ipykernel/pull/356) +- Fix classifiers to indicate dropped Python 2 support + [#354](https://github.com/ipython/ipykernel/pull/354) +- Remove some dead code [#355](https://github.com/ipython/ipykernel/pull/355) +- Support rich-media responses in `inspect_requests` (tooltips) + [#361](https://github.com/ipython/ipykernel/pull/361) ## 5.0 @@ -670,18 +676,18 @@ failures in nbconvert. [5.0.0 on GitHub](https://github.com/ipython/ipykernel/milestones/5.0) -* Drop support for Python 2. `ipykernel` 5.0 requires Python \>= 3.4 -* Add support for IPython\'s asynchronous code execution - [#323](https://github.com/ipython/ipykernel/pull/323) -* Update release process in `CONTRIBUTING.md` [#339](https://github.com/ipython/ipykernel/pull/339) +- Drop support for Python 2. `ipykernel` 5.0 requires Python \>= 3.4 +- Add support for IPython\'s asynchronous code execution + [#323](https://github.com/ipython/ipykernel/pull/323) +- Update release process in `CONTRIBUTING.md` [#339](https://github.com/ipython/ipykernel/pull/339) ## 4.10 [4.10 on GitHub](https://github.com/ipython/ipykernel/milestones/4.10) -* Fix compatibility with IPython 7.0 [#348](https://github.com/ipython/ipykernel/pull/348) -* Fix compatibility in cases where sys.stdout can be None - [#344](https://github.com/ipython/ipykernel/pull/344) +- Fix compatibility with IPython 7.0 [#348](https://github.com/ipython/ipykernel/pull/348) +- Fix compatibility in cases where sys.stdout can be None + [#344](https://github.com/ipython/ipykernel/pull/344) ## 4.9 @@ -689,14 +695,14 @@ failures in nbconvert. [4.9.0 on GitHub](https://github.com/ipython/ipykernel/milestones/4.9) -* Python 3.3 is no longer supported [#336](https://github.com/ipython/ipykernel/pull/336) -* Flush stdout/stderr in KernelApp before replacing - [#314](https://github.com/ipython/ipykernel/pull/314) -* Allow preserving stdout and stderr in KernelApp - [#315](https://github.com/ipython/ipykernel/pull/315) -* Override writable method on OutStream [#316](https://github.com/ipython/ipykernel/pull/316) -* Add metadata to help display matplotlib figures legibly - [#336](https://github.com/ipython/ipykernel/pull/336) +- Python 3.3 is no longer supported [#336](https://github.com/ipython/ipykernel/pull/336) +- Flush stdout/stderr in KernelApp before replacing + [#314](https://github.com/ipython/ipykernel/pull/314) +- Allow preserving stdout and stderr in KernelApp + [#315](https://github.com/ipython/ipykernel/pull/315) +- Override writable method on OutStream [#316](https://github.com/ipython/ipykernel/pull/316) +- Add metadata to help display matplotlib figures legibly + [#336](https://github.com/ipython/ipykernel/pull/336) ## 4.8 @@ -704,29 +710,29 @@ failures in nbconvert. [4.8.2 on GitHub](https://github.com/ipython/ipykernel/milestones/4.8.2) -* Fix compatibility issue with qt eventloop and pyzmq 17 - [#307](https://github.com/ipython/ipykernel/pull/307). +- Fix compatibility issue with qt eventloop and pyzmq 17 + [#307](https://github.com/ipython/ipykernel/pull/307). ### 4.8.1 [4.8.1 on GitHub](https://github.com/ipython/ipykernel/milestones/4.8.1) -* set zmq.ROUTER_HANDOVER socket option when available to workaround - libzmq reconnect bug [#300](https://github.com/ipython/ipykernel/pull/300). -* Fix sdists including absolute paths for kernelspec files, which - prevented installation from sdist on Windows - [#306](https://github.com/ipython/ipykernel/pull/306). +- set zmq.ROUTER_HANDOVER socket option when available to workaround + libzmq reconnect bug [#300](https://github.com/ipython/ipykernel/pull/300). +- Fix sdists including absolute paths for kernelspec files, which + prevented installation from sdist on Windows + [#306](https://github.com/ipython/ipykernel/pull/306). ### 4.8.0 [4.8.0 on GitHub](https://github.com/ipython/ipykernel/milestones/4.8) -* Cleanly shutdown integrated event loops when shutting down the - kernel. [#290](https://github.com/ipython/ipykernel/pull/290) -* `%gui qt` now uses Qt 5 by default rather than Qt 4, following a - similar change in terminal IPython. [#293](https://github.com/ipython/ipykernel/pull/293) -* Fix event loop integration for `asyncio` when run with Tornado 5, which uses asyncio where - available. [#296](https://github.com/ipython/ipykernel/pull/296) +- Cleanly shutdown integrated event loops when shutting down the + kernel. [#290](https://github.com/ipython/ipykernel/pull/290) +- `%gui qt` now uses Qt 5 by default rather than Qt 4, following a + similar change in terminal IPython. [#293](https://github.com/ipython/ipykernel/pull/293) +- Fix event loop integration for `asyncio` when run with Tornado 5, which uses asyncio where + available. [#296](https://github.com/ipython/ipykernel/pull/296) ## 4.7 @@ -734,14 +740,14 @@ failures in nbconvert. [4.7.0 on GitHub](https://github.com/ipython/ipykernel/milestones/4.7) -* Add event loop integration for `asyncio`. -* Use the new IPython completer API. -* Add support for displaying GIF images (mimetype `image/gif`). -* Allow the kernel to be interrupted without killing the Qt console. -* Fix `is_complete` response with cell magics. -* Clean up encoding of bytes objects. -* Clean up help links to use `https` and improve display titles. -* Clean up ioloop handling in preparation for tornado 5. +- Add event loop integration for `asyncio`. +- Use the new IPython completer API. +- Add support for displaying GIF images (mimetype `image/gif`). +- Allow the kernel to be interrupted without killing the Qt console. +- Fix `is_complete` response with cell magics. +- Clean up encoding of bytes objects. +- Clean up help links to use `https` and improve display titles. +- Clean up ioloop handling in preparation for tornado 5. ## 4.6 @@ -749,52 +755,52 @@ failures in nbconvert. [4.6.1 on GitHub](https://github.com/ipython/ipykernel/milestones/4.6.1) -* Fix eventloop-integration bug preventing Qt windows/widgets from - displaying with ipykernel 4.6.0 and IPython ≥ 5.2. -* Avoid deprecation warnings about naive datetimes when working with - jupyter_client ≥ 5.0. +- Fix eventloop-integration bug preventing Qt windows/widgets from + displaying with ipykernel 4.6.0 and IPython ≥ 5.2. +- Avoid deprecation warnings about naive datetimes when working with + jupyter_client ≥ 5.0. ### 4.6.0 [4.6.0 on GitHub](https://github.com/ipython/ipykernel/milestones/4.6) -* Add to API `DisplayPublisher.publish` two new fully - backward-compatible keyword-args: +- Add to API `DisplayPublisher.publish` two new fully + backward-compatible keyword-args: - > * `update: bool` - > * `transient: dict` + > - `update: bool` + > - `transient: dict` -* Support new `transient` key in - `display_data` messages spec for `publish`. - For a display data message, `transient` contains data - that shouldn\'t be persisted to files or documents. Add a - `display_id` to this `transient` dict by - `display(obj, display_id=\...)` +- Support new `transient` key in + `display_data` messages spec for `publish`. + For a display data message, `transient` contains data + that shouldn\'t be persisted to files or documents. Add a + `display_id` to this `transient` dict by + `display(obj, display_id=\...)` -* Add `ipykernel_launcher` module which removes the - current working directory from `sys.path` before - launching the kernel. This helps to reduce the cases where the - kernel won\'t start because there\'s a `random.py` (or - similar) module in the current working directory. +- Add `ipykernel_launcher` module which removes the + current working directory from `sys.path` before + launching the kernel. This helps to reduce the cases where the + kernel won\'t start because there\'s a `random.py` (or + similar) module in the current working directory. -* Add busy/idle messages on IOPub during processing of aborted - requests +- Add busy/idle messages on IOPub during processing of aborted + requests -* Add active event loop setting to GUI, which enables the correct - response to IPython\'s `is_event_loop_running_xxx` +- Add active event loop setting to GUI, which enables the correct + response to IPython\'s `is_event_loop_running_xxx` -* Include IPython kernelspec in wheels to reduce reliance on \"native - kernel spec\" in jupyter_client +- Include IPython kernelspec in wheels to reduce reliance on \"native + kernel spec\" in jupyter_client -* Modify `OutStream` to inherit from - `TextIOBase` instead of object to improve API support - and error reporting +- Modify `OutStream` to inherit from + `TextIOBase` instead of object to improve API support + and error reporting -* Fix IPython kernel death messages at start, such as \"Kernel - Restarting\...\" and \"Kernel appears to have died\", when - parent-poller handles PID 1 +- Fix IPython kernel death messages at start, such as \"Kernel + Restarting\...\" and \"Kernel appears to have died\", when + parent-poller handles PID 1 -* Various bugfixes +- Various bugfixes ## 4.5 @@ -802,31 +808,31 @@ failures in nbconvert. [4.5.2 on GitHub](https://github.com/ipython/ipykernel/milestones/4.5.2) -* Fix bug when instantiating Comms outside of the IPython kernel - (introduced in 4.5.1). +- Fix bug when instantiating Comms outside of the IPython kernel + (introduced in 4.5.1). ### 4.5.1 [4.5.1 on GitHub](https://github.com/ipython/ipykernel/milestones/4.5.1) -* Add missing `stream` parameter to overridden - `getpass` -* Remove locks from iopub thread, which could cause deadlocks during - debugging -* Fix regression where KeyboardInterrupt was treated as an aborted - request, rather than an error -* Allow instantiating Comms outside of the IPython kernel +- Add missing `stream` parameter to overridden + `getpass` +- Remove locks from iopub thread, which could cause deadlocks during + debugging +- Fix regression where KeyboardInterrupt was treated as an aborted + request, rather than an error +- Allow instantiating Comms outside of the IPython kernel ### 4.5.0 [4.5 on GitHub](https://github.com/ipython/ipykernel/milestones/4.5) -* Use figure.dpi instead of savefig.dpi to set DPI for inline figures -* Support ipympl matplotlib backend (requires IPython update as well - to fully work) -* Various bugfixes, including fixes for output coming from threads, - and `input` when called with - non-string prompts, which stdlib allows. +- Use figure.dpi instead of savefig.dpi to set DPI for inline figures +- Support ipympl matplotlib backend (requires IPython update as well + to fully work) +- Various bugfixes, including fixes for output coming from threads, + and `input` when called with + non-string prompts, which stdlib allows. ## 4.4 @@ -834,61 +840,62 @@ failures in nbconvert. [4.4.1 on GitHub](https://github.com/ipython/ipykernel/milestones/4.4.1) -* Fix circular import of matplotlib on Python 2 caused by the inline - backend changes in 4.4.0. +- Fix circular import of matplotlib on Python 2 caused by the inline + backend changes in 4.4.0. ### 4.4.0 [4.4.0 on GitHub](https://github.com/ipython/ipykernel/milestones/4.4) -* Use - [MPLBACKEND](http://matplotlib.org/devel/coding_guide.html?highlight=mplbackend#developing-a-new-backend) - environment variable to tell matplotlib \>= 1.5 use use the inline - backend by default. This is only done if MPLBACKEND is not already - set and no backend has been explicitly loaded, so setting - `MPLBACKEND=Qt4Agg` or calling `%matplotlib notebook` or - `matplotlib.use('Agg')` will take precedence. -* Fixes for logging problems caused by 4.3, where logging could go to - the terminal instead of the notebook. -* Add `--sys-prefix` and `--profile` arguments to - `ipython kernel install`. -* Allow Comm (Widget) messages to be sent from background threads. -* Select inline matplotlib backend by default if `%matplotlib` magic - or `matplotlib.use()` are not called explicitly (for matplotlib \>= - 1.5). -* Fix some longstanding minor deviations from the message protocol - (missing status: ok in a few replies, connect_reply format). -* Remove calls to NoOpContext from IPython, deprecated in 5.0. +- Use + [MPLBACKEND](http://matplotlib.org/devel/coding_guide.html?highlight=mplbackend#developing-a-new-backend) + environment variable to tell matplotlib \>= 1.5 use use the inline + backend by default. This is only done if MPLBACKEND is not already + set and no backend has been explicitly loaded, so setting + `MPLBACKEND=Qt4Agg` or calling `%matplotlib notebook` or + `matplotlib.use('Agg')` will take precedence. +- Fixes for logging problems caused by 4.3, where logging could go to + the terminal instead of the notebook. +- Add `--sys-prefix` and `--profile` arguments to + `ipython kernel install`. +- Allow Comm (Widget) messages to be sent from background threads. +- Select inline matplotlib backend by default if `%matplotlib` magic + or `matplotlib.use()` are not called explicitly (for matplotlib \>= + 1.5). +- Fix some longstanding minor deviations from the message protocol + (missing status: ok in a few replies, connect_reply format). +- Remove calls to NoOpContext from IPython, deprecated in 5.0. ## 4.3 ### 4.3.2 -* Use a nonempty dummy session key for inprocess kernels to avoid - security warnings. +- Use a nonempty dummy session key for inprocess kernels to avoid + security warnings. ### 4.3.1 -* Fix Windows Python 3.5 incompatibility caused by faulthandler patch - in 4.3 +- Fix Windows Python 3.5 incompatibility caused by faulthandler patch + in 4.3 ### 4.3.0 [4.3.0 on GitHub](https://github.com/ipython/ipykernel/milestones/4.3) -* Publish all IO in a thread, via `IOPubThread`. This solves the problem of requiring - `sys.stdout.flush` to be called in - the notebook to produce output promptly during long-running cells. -* Remove references to outdated IPython guiref in kernel banner. -* Patch faulthandler to use `sys.__stderr__` instead of forwarded - `sys.stderr`, which has no fileno when forwarded. -* Deprecate some vestiges of the Big Split: - * `ipykernel.find_connection_file` - is deprecated. Use - `jupyter_client.find_connection_file` instead. +- Publish all IO in a thread, via `IOPubThread`. This solves the problem of requiring + `sys.stdout.flush` to be called in + the notebook to produce output promptly during long-running cells. +- Remove references to outdated IPython guiref in kernel banner. +- Patch faulthandler to use `sys.__stderr__` instead of forwarded + `sys.stderr`, which has no fileno when forwarded. +- Deprecate some vestiges of the Big Split: + + - `ipykernel.find_connection_file` + is deprecated. Use + `jupyter_client.find_connection_file` instead. - \- Various pieces of code specific to IPython parallel are - deprecated in ipykernel and moved to ipyparallel. + \- Various pieces of code specific to IPython parallel are + deprecated in ipykernel and moved to ipyparallel. ## 4.2 @@ -896,24 +903,24 @@ failures in nbconvert. [4.2.2 on GitHub](https://github.com/ipython/ipykernel/milestones/4.2.2) -* Don\'t show interactive debugging info when kernel crashes -* Fix handling of numerical types in json_clean -* Testing fixes for output capturing +- Don\'t show interactive debugging info when kernel crashes +- Fix handling of numerical types in json_clean +- Testing fixes for output capturing ### 4.2.1 [4.2.1 on GitHub](https://github.com/ipython/ipykernel/milestones/4.2.1) -* Fix default display name back to \"Python X\" instead of \"pythonX\" +- Fix default display name back to \"Python X\" instead of \"pythonX\" ### 4.2.0 [4.2 on GitHub](https://github.com/ipython/ipykernel/milestones/4.2) -* Support sending a full message in initial opening of comms - (metadata, buffers were not previously allowed) -* When using `ipython kernel install --name` to install the IPython - kernelspec, default display-name to the same value as `--name`. +- Support sending a full message in initial opening of comms + (metadata, buffers were not previously allowed) +- When using `ipython kernel install --name` to install the IPython + kernelspec, default display-name to the same value as `--name`. ## 4.1 @@ -921,17 +928,17 @@ failures in nbconvert. [4.1.1 on GitHub](https://github.com/ipython/ipykernel/milestones/4.1.1) -* Fix missing `ipykernel.__version__` on Python 2. -* Fix missing `target_name` when opening comms from the frontend. +- Fix missing `ipykernel.__version__` on Python 2. +- Fix missing `target_name` when opening comms from the frontend. ### 4.1.0 [4.1 on GitHub](https://github.com/ipython/ipykernel/milestones/4.1) -* add `ipython kernel install` entrypoint for installing the IPython - kernelspec -* provisional implementation of `comm_info` request/reply for msgspec - v5.1 +- add `ipython kernel install` entrypoint for installing the IPython + kernelspec +- provisional implementation of `comm_info` request/reply for msgspec + v5.1 ## 4.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98696576f..e54fe77f5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,9 +17,34 @@ cd ipykernel pip install -e . ``` +## Code Styling + +`ipykernel` has adopted automatic code formatting so you shouldn't +need to worry too much about your code style. +As long as your code is valid, +the pre-commit hook should take care of how it should look. +To install `pre-commit`, run the following:: + + pip install pre-commit + pre-commit install + +You can invoke the pre-commit hook by hand at any time with:: + + pre-commit run + +which should run any autoformatting on your code +and tell you about any errors it couldn't fix automatically. +You may also install [black integration](https://github.com/psf/black#editor-integration) +into your text editor to format code automatically. + +If you have already committed files before setting up the pre-commit +hook with `pre-commit install`, you can fix everything up using +`pre-commit run --all-files`. You need to make the fixing commit +yourself after that. + ## Releasing ipykernel -Releasing ipykernel is *almost* standard for a Python package: +Releasing ipykernel is _almost_ standard for a Python package: - set version for release - make and publish tag diff --git a/COPYING.md b/COPYING.md index 93f45a894..0ccda3eb1 100644 --- a/COPYING.md +++ b/COPYING.md @@ -24,7 +24,7 @@ software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER @@ -46,8 +46,8 @@ IPython uses a shared copyright model. Each contributor maintains copyright over their contributions to IPython. But, it is important to note that these contributions are typically only changes to the repositories. Thus, the IPython source code, in its entirety is not the copyright of any single person or -institution. Instead, it is the collective copyright of the entire IPython -Development Team. If individual contributors want to maintain a record of what +institution. Instead, it is the collective copyright of the entire IPython +Development Team. If individual contributors want to maintain a record of what changes/contributions they have specific copyright on, they should indicate their copyright in the commit message of the change, when they commit the change to one of the IPython repositories. diff --git a/MANIFEST.in b/MANIFEST.in index 155a5e4c4..e75739460 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -23,5 +23,6 @@ global-exclude .ipynb_checkpoints prune data_kernelspec exclude .mailmap exclude readthedocs.yml - exclude .coveragerc +exclude .pre-commit-config.yaml +exclude .git-blame-ignore-revs diff --git a/RELEASE.md b/RELEASE.md index 21c93a25d..2f3954582 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -20,6 +20,6 @@ git push --all git push --tags rm -rf dist build python -m build . -twine check dist/* +twine check dist/* twine upload dist/* ``` diff --git a/docs/index.rst b/docs/index.rst index c83dff2be..f58fc62fc 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,4 +20,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - diff --git a/docs/requirements.txt b/docs/requirements.txt index 3026b0bb2..b3608d506 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,2 @@ -sphinxcontrib_github_alt myst_parser +sphinxcontrib_github_alt diff --git a/examples/embedding/internal_ipkernel.py b/examples/embedding/internal_ipkernel.py index f5a1b3577..a0e89f5cc 100644 --- a/examples/embedding/internal_ipkernel.py +++ b/examples/embedding/internal_ipkernel.py @@ -27,7 +27,7 @@ def init_ipkernel(self, backend): self.ipkernel = mpl_kernel(backend) # To create and track active qt consoles self.consoles = [] - + # This application will also act on the shell user namespace self.namespace = self.ipkernel.shell.user_ns diff --git a/examples/embedding/ipkernel_qtapp.py b/examples/embedding/ipkernel_qtapp.py index 601c74884..4f9789580 100755 --- a/examples/embedding/ipkernel_qtapp.py +++ b/examples/embedding/ipkernel_qtapp.py @@ -69,7 +69,7 @@ def add_widgets(self): # Create our window win = SimpleWindow(app) win.show() - + # Very important, IPython-specific step: this gets GUI event loop # integration going, and it replaces calling app.exec_() win.ipkernel.start() diff --git a/ipykernel/__init__.py b/ipykernel/__init__.py index 6c7e5bc07..3f753e3ee 100644 --- a/ipykernel/__init__.py +++ b/ipykernel/__init__.py @@ -1,2 +1,2 @@ from ._version import version_info, __version__, kernel_protocol_version_info, kernel_protocol_version -from .connect import * \ No newline at end of file +from .connect import * diff --git a/ipykernel/comm/manager.py b/ipykernel/comm/manager.py index c70840369..631b67b13 100644 --- a/ipykernel/comm/manager.py +++ b/ipykernel/comm/manager.py @@ -117,7 +117,7 @@ def comm_close(self, stream, ident, msg): comm = self.get_comm(comm_id) if comm is None: return - + self.comms[comm_id]._closed = True del self.comms[comm_id] diff --git a/ipykernel/debugger.py b/ipykernel/debugger.py index dfe5d0a9b..f229c9402 100644 --- a/ipykernel/debugger.py +++ b/ipykernel/debugger.py @@ -270,7 +270,7 @@ class Debugger: # Requests that can be handled even if the debugger is not running static_debug_msg_types = [ - 'debugInfo', 'inspectVariables', + 'debugInfo', 'inspectVariables', 'richInspectVariables', 'modules' ] @@ -349,7 +349,7 @@ def _accept_stopped_thread(self, thread_name): 'Thread-4' ] return thread_name not in forbid_list - + async def handle_stopped_event(self): # Wait for a stopped event message in the stopped queue # This message is used for triggering the 'threads' request diff --git a/ipykernel/kernelspec.py b/ipykernel/kernelspec.py index 6a0bc639f..34e4960b0 100644 --- a/ipykernel/kernelspec.py +++ b/ipykernel/kernelspec.py @@ -68,7 +68,7 @@ def write_kernel_spec(path=None, overrides=None, extra_arguments=None): """ if path is None: path = os.path.join(tempfile.mkdtemp(suffix='_kernels'), KERNEL_NAME) - + # stage resources shutil.copytree(RESOURCES, path) @@ -84,7 +84,7 @@ def write_kernel_spec(path=None, overrides=None, extra_arguments=None): kernel_dict.update(overrides) with open(pjoin(path, 'kernel.json'), 'w') as f: json.dump(kernel_dict, f, indent=1) - + return path @@ -152,12 +152,12 @@ def install(kernel_spec_manager=None, user=False, kernel_name=KERNEL_NAME, displ class InstallIPythonKernelSpecApp(Application): """Dummy app wrapping argparse""" name = 'ipython-kernel-install' - + def initialize(self, argv=None): if argv is None: argv = sys.argv[1:] self.argv = argv - + def start(self): import argparse parser = argparse.ArgumentParser(prog=self.name, diff --git a/ipykernel/pickleutil.py b/ipykernel/pickleutil.py index fc8e4f2e3..834abea4d 100644 --- a/ipykernel/pickleutil.py +++ b/ipykernel/pickleutil.py @@ -47,7 +47,7 @@ def interactive(f): This results in the function being linked to the user_ns as globals() instead of the module globals(). """ - + # build new FunctionType, so it can have the right globals # interactive functions never have closures, that's kind of the point if isinstance(f, FunctionType): @@ -67,10 +67,10 @@ def use_dill(): """ # import dill causes most of the magic import dill - + # dill doesn't work with cPickle, # tell the two relevant modules to use plain pickle - + global pickle pickle = dill @@ -80,7 +80,7 @@ def use_dill(): pass else: serialize.pickle = dill - + # disable special function handling, let dill take care of it can_map.pop(FunctionType, None) @@ -90,7 +90,7 @@ def use_cloudpickle(): adds support for object methods and closures to serialization. """ import cloudpickle - + global pickle pickle = cloudpickle @@ -100,7 +100,7 @@ def use_cloudpickle(): pass else: serialize.pickle = cloudpickle - + # disable special function handling, let cloudpickle take care of it can_map.pop(FunctionType, None) @@ -134,7 +134,7 @@ def __init__(self, obj, keys=[], hook=None): self.hook = can(hook) for key in keys: setattr(self.obj, key, can(getattr(obj, key))) - + self.buffers = [] def get_object(self, g=None): @@ -143,12 +143,12 @@ def get_object(self, g=None): obj = self.obj for key in self.keys: setattr(obj, key, uncan(getattr(obj, key), g)) - + if self.hook: self.hook = uncan(self.hook, g) self.hook(obj, g) return self.obj - + class Reference(CannedObject): """object for wrapping a remote reference by name.""" @@ -164,7 +164,7 @@ def __repr__(self): def get_object(self, g=None): if g is None: g = {} - + return eval(self.name, g) @@ -172,7 +172,7 @@ class CannedCell(CannedObject): """Can a closure cell""" def __init__(self, cell): self.cell_contents = can(cell.cell_contents) - + def get_object(self, g=None): cell_contents = uncan(self.cell_contents, g) def inner(): @@ -189,13 +189,13 @@ def __init__(self, f): self.defaults = [ can(fd) for fd in f.__defaults__ ] else: self.defaults = None - + closure = f.__closure__ if closure: self.closure = tuple( can(cell) for cell in closure ) else: self.closure = None - + self.module = f.__module__ or '__main__' self.__name__ = f.__name__ self.buffers = [] @@ -236,7 +236,7 @@ def __init__(self, cls): mro = [] else: mro = cls.mro() - + self.parents = [ can(c) for c in mro[1:] ] self.buffers = [] @@ -267,7 +267,7 @@ def __init__(self, obj): # ensure contiguous obj = ascontiguousarray(obj, dtype=None) self.buffers = [buffer(obj)] - + def get_object(self, g=None): from numpy import frombuffer data = self.buffers[0] @@ -338,22 +338,22 @@ def istype(obj, check): def can(obj): """prepare an object for pickling""" - + import_needed = False - + for cls,canner in can_map.items(): if isinstance(cls, str): import_needed = True break elif istype(obj, cls): return canner(obj) - + if import_needed: # perform can_map imports, then try again # this will usually only happen once _import_mapping(can_map, _original_can_map) return can(obj) - + return obj def can_class(obj): @@ -384,7 +384,7 @@ def can_sequence(obj): def uncan(obj, g=None): """invert canning""" - + import_needed = False for cls,uncanner in uncan_map.items(): if isinstance(cls, str): @@ -392,13 +392,13 @@ def uncan(obj, g=None): break elif isinstance(obj, cls): return uncanner(obj, g) - + if import_needed: # perform uncan_map imports, then try again # this will usually only happen once _import_mapping(uncan_map, _original_uncan_map) return uncan(obj, g) - + return obj def uncan_dict(obj, g=None): diff --git a/ipykernel/tests/__init__.py b/ipykernel/tests/__init__.py index 58b12bfa6..399311940 100644 --- a/ipykernel/tests/__init__.py +++ b/ipykernel/tests/__init__.py @@ -29,7 +29,7 @@ def setup(): ] for p in patchers: p.start() - + # install IPython in the temp home: install(user=True) diff --git a/ipykernel/tests/test_debugger.py b/ipykernel/tests/test_debugger.py index 43a96ef22..d670df7fd 100644 --- a/ipykernel/tests/test_debugger.py +++ b/ipykernel/tests/test_debugger.py @@ -153,7 +153,7 @@ def test_stop_on_breakpoint(kernel_with_debug): wait_for_debug_request(kernel_with_debug, "configurationDone", full_reply=True) kernel_with_debug.execute(code) - + # Wait for stop on breakpoint msg = {"msg_type": "", "content": {}} while msg.get('msg_type') != 'debug_event' or msg["content"].get("event") != "stopped": @@ -189,7 +189,7 @@ def f(a, b): wait_for_debug_request(kernel_with_debug, "configurationDone", full_reply=True) kernel_with_debug.execute(code) - + # Wait for stop on breakpoint msg = {"msg_type": "", "content": {}} while msg.get('msg_type') != 'debug_event' or msg["content"].get("event") != "stopped": diff --git a/ipykernel/tests/test_kernelspec.py b/ipykernel/tests/test_kernelspec.py index c736a5833..94321a4d3 100644 --- a/ipykernel/tests/test_kernelspec.py +++ b/ipykernel/tests/test_kernelspec.py @@ -94,21 +94,21 @@ def test_install_kernelspec(): def test_install_user(): tmp = tempfile.mkdtemp() - + with mock.patch.dict(os.environ, {'HOME': tmp}): install(user=True) data_dir = jupyter_data_dir() - + assert_is_spec(os.path.join(data_dir, 'kernels', KERNEL_NAME)) def test_install(): system_jupyter_dir = tempfile.mkdtemp() - + with mock.patch('jupyter_client.kernelspec.SYSTEM_JUPYTER_PATH', [system_jupyter_dir]): install() - + assert_is_spec(os.path.join(system_jupyter_dir, 'kernels', KERNEL_NAME)) diff --git a/ipykernel/tests/test_pickleutil.py b/ipykernel/tests/test_pickleutil.py index 0bc6e457a..d81342ae0 100644 --- a/ipykernel/tests/test_pickleutil.py +++ b/ipykernel/tests/test_pickleutil.py @@ -17,7 +17,7 @@ def test_no_closure(): def foo(): a = 5 return a - + pfoo = dumps(foo) bar = loads(pfoo) assert foo() == bar() @@ -29,7 +29,7 @@ def foo(): i = 'i' r = [ i for j in (1,2) ] return r - + pfoo = dumps(foo) bar = loads(pfoo) assert foo() == bar() @@ -41,7 +41,7 @@ def foo(): def g(): return i return g() - + pfoo = dumps(foo) bar = loads(pfoo) assert foo() == bar() @@ -51,7 +51,7 @@ def test_closure(): @interactive def foo(): return i - + pfoo = dumps(foo) bar = loads(pfoo) assert foo() == bar() diff --git a/pyproject.toml b/pyproject.toml index ec9b08e49..9cc4eabfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,3 +28,12 @@ tag_template = "v{new_version}" [[tool.tbump.file]] src = "ipykernel/_version.py" + +[tool.pytest.ini_options] +addopts = "-raXs --durations 10 --color=yes --doctest-modules" +testpaths = [ + "ipykernel/tests/" +] +timeout = 300 +# Restore this setting to debug failures +# timeout_method = "thread" diff --git a/setup.cfg b/setup.cfg index 065b8a89c..2ee9451f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,33 +7,19 @@ license_file = COPYING.md version = attr: ipykernel._version.__version__ [flake8] -# References: -# https://flake8.readthedocs.io/en/latest/user/configuration.html -# https://flake8.readthedocs.io/en/latest/user/error-codes.html -# https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes -exclude = __init__.py,versioneer.py -ignore = - E20, # Extra space in brackets - E122, # continuation line missing indentation or outdented - E124, # closing bracket does not match visual indentation - E128,E127,E126 # continuation line over/under-indented for visual indent - E121,E125, # continuation line with same indent as next logical line - E226, # missing whitespace around arithmetic operator - E231,E241, # Multiple spaces around "," - E211, # whitespace before '(' - E221,E225,E228 # missing whitespace around operator - E271, # multiple spaces after keyword - E301,E303,E305,E306 # expected X blank lines - E26, # Comments - E251 # unexpected spaces around keyword / parameter equals - E302 # expected 2 blank lines, found 1 - E4, # Import formatting - E721, # Comparing types instead of isinstance - E731, # Assigning lambda expression - E741, # Ambiguous variable names - W293, # blank line contains whitespace - W503, # line break before binary operator - W504, # line break after binary operator - F811, # redefinition of unused 'loop' from line 10 -max-line-length = 120 - +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 + ipykernel/tests/*: B011, F841 diff --git a/setup.py b/setup.py index 513871ffa..1106d77be 100644 --- a/setup.py +++ b/setup.py @@ -77,6 +77,8 @@ def run(self): "pytest-cov", "flaky", "ipyparallel", + "pre-commit", + "pytest-timeout" ], }, classifiers=[