Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-ipykernel for openSUSE:Factory checked in at 2023-02-06 14:15:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-ipykernel (Old) and /work/SRC/openSUSE:Factory/.python-ipykernel.new.4462 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-ipykernel" Mon Feb 6 14:15:17 2023 rev:35 rq:1063284 version:6.21.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-ipykernel/python-ipykernel.changes 2023-01-24 20:31:54.004237819 +0100 +++ /work/SRC/openSUSE:Factory/.python-ipykernel.new.4462/python-ipykernel.changes 2023-02-06 14:15:18.516538256 +0100 @@ -1,0 +2,9 @@ +Sun Feb 5 15:09:43 UTC 2023 - Ben Greiner <c...@bnavigator.de> + +- Update to 6.21.1 + * Restore nest-asyncio for tk loop #1086 (@blink1073) +- Release 6.21.0 + * Expose session start file in file. #1078 (@Carreau) + * Add copy_to_globals debug request handling #1055 (@brichet) + +------------------------------------------------------------------- Old: ---- ipykernel-6.20.2.tar.gz New: ---- ipykernel-6.21.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-ipykernel.spec ++++++ --- /var/tmp/diff_new_pack.LNbhv7/_old 2023-02-06 14:15:19.052540928 +0100 +++ /var/tmp/diff_new_pack.LNbhv7/_new 2023-02-06 14:15:19.064540987 +0100 @@ -17,7 +17,7 @@ Name: python-ipykernel -Version: 6.20.2 +Version: 6.21.1 Release: 0 Summary: IPython Kernel for Jupyter License: BSD-3-Clause @@ -44,7 +44,7 @@ # /SECTION # SECTION dependencies BuildRequires: %{python_module comm >= 0.1.1} -BuildRequires: %{python_module debugpy >= 1.0} +BuildRequires: %{python_module debugpy >= 1.6.5} BuildRequires: %{python_module ipython >= 7.23.1} BuildRequires: %{python_module jupyter-client >= 6.1.12} BuildRequires: %{python_module matplotlib-inline >= 0.1} @@ -54,8 +54,9 @@ BuildRequires: %{python_module pyzmq >= 17} BuildRequires: %{python_module tornado >= 6.1} BuildRequires: %{python_module traitlets >= 5.1.0} +BuildRequires: %{python_module jupyter-core >= 5.1 or (%python-jupyter-core >= 4.12 with %python-jupyter-core < 5.0)} Requires: python-comm >= 0.1.1 -Requires: python-debugpy >= 1.0 +Requires: python-debugpy >= 1.6.5 Requires: python-ipython >= 7.23.1 Requires: python-jupyter-client >= 6.1.12 Requires: python-matplotlib-inline >= 0.1 @@ -65,6 +66,7 @@ Requires: python-pyzmq >= 17 Requires: python-tornado >= 6.1 Requires: python-traitlets >= 5.4.0 +Requires: (python-jupyter-core >= 5.1 or (python-jupyter-core >= 4.12 with python-jupyter-core < 5.0)) # /SECTION # SECTION test requirements BuildRequires: %{python_module flaky} ++++++ ipykernel-6.20.2.tar.gz -> ipykernel-6.21.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/.github/workflows/ci.yml new/ipykernel-6.21.1/.github/workflows/ci.yml --- old/ipykernel-6.20.2/.github/workflows/ci.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/.github/workflows/ci.yml 2020-02-02 01:00:00.000000000 +0100 @@ -4,6 +4,8 @@ push: branches: ["main"] pull_request: + schedule: + - cron: "0 0 * * *" concurrency: group: ci-${{ github.ref }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/.github/workflows/downstream.yml new/ipykernel-6.21.1/.github/workflows/downstream.yml --- old/ipykernel-6.20.2/.github/workflows/downstream.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/.github/workflows/downstream.yml 2020-02-02 01:00:00.000000000 +0100 @@ -90,13 +90,11 @@ steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup Python uses: actions/setup-python@v4 with: python-version: "3.9" architecture: "x64" - - name: Install System Packages run: | sudo apt-get update @@ -109,16 +107,46 @@ cd qtconsole ${pythonLocation}/bin/python -m pip install -e ".[test]" ${pythonLocation}/bin/python -m pip install pyqt5 - - name: Install Jupyter-Client changes + - name: Install Ipykernel changes shell: bash -l {0} run: ${pythonLocation}/bin/python -m pip install -e . - - name: Test qtconsole shell: bash -l {0} run: | cd ${GITHUB_WORKSPACE}/../qtconsole xvfb-run --auto-servernum ${pythonLocation}/bin/python -m pytest -x -vv -s --full-trace --color=yes qtconsole + spyder_kernels: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + architecture: "x64" + - name: Install System Packages + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends libegl1-mesa + - name: Install spyder-kernels dependencies + shell: bash -l {0} + run: | + cd ${GITHUB_WORKSPACE}/.. + git clone https://github.com/spyder-ide/spyder-kernels.git + cd spyder-kernels + ${pythonLocation}/bin/python -m pip install -e ".[test]" + - name: Install IPykernel changes + shell: bash -l {0} + run: ${pythonLocation}/bin/python -m pip install -e . + - name: Test spyder-kernels + shell: bash -l {0} + run: | + cd ${GITHUB_WORKSPACE}/../spyder-kernels + xvfb-run --auto-servernum ${pythonLocation}/bin/python -m pytest -x -vv -s --full-trace --color=yes spyder_kernels + downstream_check: # This job does nothing and is only used for the branch protection if: always() needs: @@ -127,6 +155,7 @@ - jupyter_client - ipyparallel - jupyter_kernel_test + - spyder_kernels - qtconsole runs-on: ubuntu-latest steps: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/.pre-commit-config.yaml new/ipykernel-6.21.1/.pre-commit-config.yaml --- old/ipykernel-6.20.2/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 @@ -36,7 +36,7 @@ - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.215 + rev: v0.0.236 hooks: - id: ruff args: ["--fix"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/CHANGELOG.md new/ipykernel-6.21.1/CHANGELOG.md --- old/ipykernel-6.20.2/CHANGELOG.md 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/CHANGELOG.md 2020-02-02 01:00:00.000000000 +0100 @@ -2,6 +2,43 @@ <!-- <START NEW CHANGELOG ENTRY> --> +## 6.21.1 + +([Full Changelog](https://github.com/ipython/ipykernel/compare/v6.21.0...ac7776dfd68861ae005e1f142ec87cd6703847ea)) + +### Maintenance and upkeep improvements + +- Restore nest-asyncio for tk loop [#1086](https://github.com/ipython/ipykernel/pull/1086) ([@blink1073](https://github.com/blink1073)) + +### Contributors to this release + +([GitHub contributors page for this release](https://github.com/ipython/ipykernel/graphs/contributors?from=2023-01-30&to=2023-02-02&type=c)) + +[@blink1073](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3Ablink1073+updated%3A2023-01-30..2023-02-02&type=Issues) + +<!-- <END NEW CHANGELOG ENTRY> --> + +## 6.21.0 + +([Full Changelog](https://github.com/ipython/ipykernel/compare/v6.20.2...dde698850d865dec89bba2305d1f3dc3134f8413)) + +### Enhancements made + +- Expose session start file in __file__. [#1078](https://github.com/ipython/ipykernel/pull/1078) ([@Carreau](https://github.com/Carreau)) +- Add copy_to_globals debug request handling [#1055](https://github.com/ipython/ipykernel/pull/1055) ([@brichet](https://github.com/brichet)) + +### Maintenance and upkeep improvements + +- Adopt more lint rules [#1082](https://github.com/ipython/ipykernel/pull/1082) ([@blink1073](https://github.com/blink1073)) +- Maintenance updates [#1081](https://github.com/ipython/ipykernel/pull/1081) ([@blink1073](https://github.com/blink1073)) +- Test spyder kernels [#1080](https://github.com/ipython/ipykernel/pull/1080) ([@blink1073](https://github.com/blink1073)) + +### Contributors to this release + +([GitHub contributors page for this release](https://github.com/ipython/ipykernel/graphs/contributors?from=2023-01-16&to=2023-01-30&type=c)) + +[@agronholm](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3Aagronholm+updated%3A2023-01-16..2023-01-30&type=Issues) | [@blink1073](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3Ablink1073+updated%3A2023-01-16..2023-01-30&type=Issues) | [@brichet](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3Abrichet+updated%3A2023-01-16..2023-01-30&type=Issues) | [@Carreau](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3ACarreau+updated%3A2023-01-16..2023-01-30&type=Issues) | [@ccordoba12](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3Accordoba12+updated%3A2023-01-16..2023-01-30&type=Issues) | [@minrk](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3Aminrk+updated%3A2023-01-16..2023-01-30&type=Issues) + ## 6.20.2 ([Full Changelog](https://github.com/ipython/ipykernel/compare/v6.20.1...203ee2bce0b506257bd561d082e983330d1ebd14)) @@ -16,8 +53,6 @@ [@ilyasher](https://github.com/search?q=repo%3Aipython%2Fipykernel+involves%3Ailyasher+updated%3A2023-01-09..2023-01-16&type=Issues) -<!-- <END NEW CHANGELOG ENTRY> --> - ## 6.20.1 ([Full Changelog](https://github.com/ipython/ipykernel/compare/v6.20.0...5f07abc22a1c75672f7bee129505f19c954a7c36)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/PKG-INFO new/ipykernel-6.21.1/PKG-INFO --- old/ipykernel-6.20.2/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: ipykernel -Version: 6.20.2 +Version: 6.21.1 Summary: IPython Kernel for Jupyter Project-URL: Homepage, https://ipython.org Author-email: IPython Development Team <ipython-...@scipy.org> @@ -80,9 +80,10 @@ Requires-Python: >=3.8 Requires-Dist: appnope; platform_system == 'Darwin' Requires-Dist: comm>=0.1.1 -Requires-Dist: debugpy>=1.0 +Requires-Dist: debugpy>=1.6.5 Requires-Dist: ipython>=7.23.1 Requires-Dist: jupyter-client>=6.1.12 +Requires-Dist: jupyter-core!=5.0.*,>=4.12 Requires-Dist: matplotlib-inline>=0.1 Requires-Dist: nest-asyncio Requires-Dist: packaging diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/_version.py new/ipykernel-6.21.1/ipykernel/_version.py --- old/ipykernel-6.20.2/ipykernel/_version.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/_version.py 2020-02-02 01:00:00.000000000 +0100 @@ -5,7 +5,7 @@ from typing import List # Version string must appear intact for hatch versioning -__version__ = "6.20.2" +__version__ = "6.21.1" # Build up version_info tuple for backwards compatibility pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/compiler.py new/ipykernel-6.21.1/ipykernel/compiler.py --- old/ipykernel-6.20.2/ipykernel/compiler.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/compiler.py 2020-02-02 01:00:00.000000000 +0100 @@ -29,7 +29,7 @@ val = length & 0x03 k = 0 - if val == 3: + if val == 3: # noqa k = (ord(data[rounded_end + 2]) & 0xFF) << 16 if val in [2, 3]: k |= (ord(data[rounded_end + 1]) & 0xFF) << 8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/connect.py new/ipykernel-6.21.1/ipykernel/connect.py --- old/ipykernel-6.20.2/ipykernel/connect.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/connect.py 2020-02-02 01:00:00.000000000 +0100 @@ -117,7 +117,7 @@ kwargs["start_new_session"] = True return Popen( - [sys.executable, "-c", cmd, "--existing", cf] + argv, + [sys.executable, "-c", cmd, "--existing", cf, *argv], stdout=PIPE, stderr=PIPE, close_fds=(sys.platform != "win32"), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/debugger.py new/ipykernel-6.21.1/ipykernel/debugger.py --- old/ipykernel-6.20.2/ipykernel/debugger.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/debugger.py 2020-02-02 01:00:00.000000000 +0100 @@ -316,7 +316,13 @@ ] # Requests that can be handled even if the debugger is not running - static_debug_msg_types = ["debugInfo", "inspectVariables", "richInspectVariables", "modules"] + static_debug_msg_types = [ + "debugInfo", + "inspectVariables", + "richInspectVariables", + "modules", + "copyToGlobals", + ] def __init__( self, log, debugpy_stream, event_callback, shell_socket, session, just_my_code=True @@ -662,6 +668,26 @@ reply["success"] = True return reply + async def copyToGlobals(self, message): + dst_var_name = message["arguments"]["dstVariableName"] + src_var_name = message["arguments"]["srcVariableName"] + src_frame_id = message["arguments"]["srcFrameId"] + + expression = f"globals()['{dst_var_name}']" + seq = message["seq"] + return await self._forward_message( + { + "type": "request", + "command": "setExpression", + "seq": seq + 1, + "arguments": { + "expression": expression, + "value": src_var_name, + "frameId": src_frame_id, + }, + } + ) + async def modules(self, message): """Handle a modules message.""" modules = list(sys.modules.values()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/eventloops.py new/ipykernel-6.21.1/ipykernel/eventloops.py --- old/ipykernel-6.20.2/ipykernel/eventloops.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/eventloops.py 2020-02-02 01:00:00.000000000 +0100 @@ -471,10 +471,9 @@ QT_API_PYSIDE6: 'qt6', QT_API_PYQT6: 'qt6', } - if loaded is not None and gui != 'qt': - if qt_env2gui[loaded] != gui: - print(f'Cannot switch Qt versions for this session; you must use {qt_env2gui[loaded]}.') - return + if loaded is not None and gui != 'qt' and qt_env2gui[loaded] != gui: + print(f'Cannot switch Qt versions for this session; you must use {qt_env2gui[loaded]}.') + return if qt_api is not None and gui != 'qt': if qt_env2gui[qt_api] != gui: @@ -510,7 +509,7 @@ os.environ["QT_API"] = "pyqt6" elif gui == 'qt': # Don't set QT_API; let IPython logic choose the version. - if 'QT_API' in os.environ.keys(): + if 'QT_API' in os.environ: del os.environ['QT_API'] else: print(f'Unrecognized Qt version: {gui}. Should be "qt5", "qt6", or "qt".') @@ -521,7 +520,7 @@ from IPython.external.qt_for_kernel import QtCore, QtGui # noqa except Exception as e: # Clear the environment variable for the next attempt. - if 'QT_API' in os.environ.keys(): + if 'QT_API' in os.environ: del os.environ["QT_API"] print(f"QT_API couldn't be set due to error {e}") return diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/inprocess/client.py new/ipykernel-6.21.1/ipykernel/inprocess/client.py --- old/ipykernel-6.20.2/ipykernel/inprocess/client.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/inprocess/client.py 2020-02-02 01:00:00.000000000 +0100 @@ -15,11 +15,7 @@ from jupyter_client.client import KernelClient from jupyter_client.clientabc import KernelClientABC - -try: - from jupyter_client.utils import run_sync # requires 7.0+ -except ImportError: - run_sync = None # type:ignore +from jupyter_core.utils import run_sync # IPython imports from traitlets import Instance, Type, default @@ -165,10 +161,7 @@ def comm_info(self, target_name=None): """Request a dictionary of valid comms and their targets.""" - if target_name is None: - content = {} - else: - content = dict(target_name=target_name) + content = {} if target_name is None else dict(target_name=target_name) msg = self.session.msg("comm_info_request", content) self._dispatch_to_kernel(msg) return msg["header"]["msg_id"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/iostream.py new/ipykernel-6.21.1/ipykernel/iostream.py --- old/ipykernel-6.20.2/ipykernel/iostream.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/iostream.py 2020-02-02 01:00:00.000000000 +0100 @@ -234,7 +234,7 @@ # new context/socket for every pipe-out # since forks don't teardown politely, use ctx.term to ensure send has completed ctx, pipe_out = self._setup_pipe_out() - pipe_out.send_multipart([self._pipe_uuid] + msg, *args, **kwargs) + pipe_out.send_multipart([self._pipe_uuid, *msg], *args, **kwargs) pipe_out.close() ctx.term() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/ipkernel.py new/ipykernel-6.21.1/ipykernel/ipkernel.py --- old/ipykernel-6.20.2/ipykernel/ipkernel.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/ipkernel.py 2020-02-02 01:00:00.000000000 +0100 @@ -3,6 +3,7 @@ import asyncio import builtins import getpass +import os import signal import sys import threading @@ -126,6 +127,11 @@ compiler_class=XCachingCompiler, ) self.shell.displayhook.session = self.session + + jupyter_session_name = os.environ.get('JPY_SESSION_NAME') + if jupyter_session_name: + self.shell.user_ns['__file__'] = jupyter_session_name + self.shell.displayhook.pub_socket = self.iopub_socket self.shell.displayhook.topic = self._topic("execute_result") self.shell.display_pub.session = self.session @@ -425,10 +431,7 @@ finally: self._restore_input() - if res.error_before_exec is not None: - err = res.error_before_exec - else: - err = res.error_in_exec + err = res.error_before_exec if res.error_before_exec is not None else res.error_in_exec if res.success: reply_content["status"] = "ok" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/jsonutil.py new/ipykernel-6.21.1/ipykernel/jsonutil.py --- old/ipykernel-6.20.2/ipykernel/jsonutil.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/jsonutil.py 2020-02-02 01:00:00.000000000 +0100 @@ -26,7 +26,7 @@ # holy crap, strptime is not threadsafe. # Calling it once at import seems to help. -datetime.strptime("1", "%d") +datetime.strptime("1", "%d") # noqa # ----------------------------------------------------------------------------- # Classes and functions @@ -98,7 +98,7 @@ it simply sanitizes it so that there will be no encoding errors later. """ - if int(JUPYTER_CLIENT_MAJOR_VERSION) >= 7: + if int(JUPYTER_CLIENT_MAJOR_VERSION) >= 7: # noqa return obj # types that are 'atomic' and ok in json as-is. @@ -156,7 +156,7 @@ for k, v in obj.items(): out[str(k)] = json_clean(v) return out - if isinstance(obj, datetime) or isinstance(obj, date): + if isinstance(obj, (datetime, date)): return obj.strftime(ISO8601) # we don't understand it, it's probably an unserializable object diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/kernelapp.py new/ipykernel-6.21.1/ipykernel/kernelapp.py --- old/ipykernel-6.20.2/ipykernel/kernelapp.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/kernelapp.py 2020-02-02 01:00:00.000000000 +0100 @@ -13,6 +13,7 @@ from functools import partial from io import FileIO, TextIOWrapper from logging import StreamHandler +from typing import Optional import zmq from IPython.core.application import ( # type:ignore[attr-defined] @@ -131,7 +132,7 @@ poller = Any() # don't restrict this even though current pollers are all Threads heartbeat = Instance(Heartbeat, allow_none=True) - context = Any() + context: Optional[zmq.Context] = Any() # type:ignore[assignment] shell_socket = Any() control_socket = Any() debugpy_socket = Any() @@ -403,7 +404,8 @@ if socket and not socket.closed: socket.close() self.log.debug("Terminating zmq context") - self.context.term() + if self.context: + self.context.term() self.log.debug("Terminated zmq context") def log_connection_info(self): @@ -445,7 +447,7 @@ def init_blackhole(self): """redirects stdout/stderr to devnull if necessary""" if self.no_stdout or self.no_stderr: - blackhole = open(os.devnull, "w") + blackhole = open(os.devnull, "w") # noqa if self.no_stdout: sys.stdout = sys.__stdout__ = blackhole if self.no_stderr: @@ -471,7 +473,9 @@ if hasattr(sys.stderr, "_original_stdstream_copy"): for handler in self.log.handlers: - if isinstance(handler, StreamHandler) and (handler.stream.buffer.fileno() == 2): + if isinstance(handler, StreamHandler) and ( + handler.stream.buffer.fileno() == 2 # noqa + ): self.log.debug("Seeing logger to stderr, rerouting to raw filedescriptor.") handler.stream = TextIOWrapper( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/kernelbase.py new/ipykernel-6.21.1/ipykernel/kernelbase.py --- old/ipykernel-6.20.2/ipykernel/kernelbase.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/kernelbase.py 2020-02-02 01:00:00.000000000 +0100 @@ -252,7 +252,8 @@ "apply_request", ] # add deprecated ipyparallel control messages - control_msg_types = msg_types + [ + control_msg_types = [ + *msg_types, "clear_request", "abort_request", "debug_request", @@ -544,10 +545,7 @@ self.control_stream.on_recv(self.dispatch_control, copy=False) - if self.control_thread: - control_loop = self.control_thread.io_loop - else: - control_loop = self.io_loop + control_loop = self.control_thread.io_loop if self.control_thread else self.io_loop asyncio.run_coroutine_threadsafe(self.poll_control_queue(), control_loop.asyncio_loop) @@ -844,10 +842,7 @@ async def connect_request(self, stream, ident, parent): """Handle a connect request.""" - if self._recorded_ports is not None: - content = self._recorded_ports.copy() - else: - content = {} + content = self._recorded_ports.copy() if self._recorded_ports is not None else {} content["status"] = "ok" msg = self.session.send(stream, "connect_reply", content, parent, ident) self.log.debug("%s", msg) @@ -982,7 +977,7 @@ """Handle a usage request.""" reply_content = {"hostname": socket.gethostname(), "pid": os.getpid()} current_process = psutil.Process() - all_processes = [current_process] + current_process.children(recursive=True) + all_processes = [current_process, *current_process.children(recursive=True)] # Ensure 1) self.processes is updated to only current subprocesses # and 2) we reuse processes when possible (needed for accurate CPU) self.processes = { @@ -1004,7 +999,7 @@ cpu_percent = psutil.cpu_percent() # https://psutil.readthedocs.io/en/latest/index.html?highlight=cpu#psutil.cpu_percent # The first time cpu_percent is called it will return a meaningless 0.0 value which you are supposed to ignore. - if cpu_percent is not None and cpu_percent != 0.0: + if cpu_percent is not None and cpu_percent != 0.0: # noqa reply_content["host_cpu_percent"] = cpu_percent reply_content["cpu_count"] = psutil.cpu_count(logical=True) reply_content["host_virtual_memory"] = dict(psutil.virtual_memory()._asdict()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/pickleutil.py new/ipykernel-6.21.1/ipykernel/pickleutil.py --- old/ipykernel-6.20.2/ipykernel/pickleutil.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/pickleutil.py 2020-02-02 01:00:00.000000000 +0100 @@ -236,14 +236,8 @@ if g is None: g = {} - if self.defaults: - defaults = tuple(uncan(cfd, g) for cfd in self.defaults) - else: - defaults = None - if self.closure: - closure = tuple(uncan(cell, g) for cell in self.closure) - else: - closure = None + defaults = tuple(uncan(cfd, g) for cfd in self.defaults) if self.defaults else None + closure = tuple(uncan(cell, g) for cell in self.closure) if self.closure else None newFunc = FunctionType(self.code, g, self.__name__, defaults, closure) return newFunc @@ -260,10 +254,7 @@ for k, v in cls.__dict__.items(): if k not in ("__weakref__", "__dict__"): self._canned_dict[k] = can(v) - if self.old_style: - mro = [] - else: - mro = cls.mro() + mro = [] if self.old_style else cls.mro() self.parents = [can(c) for c in mro[1:]] self.buffers = [] @@ -376,10 +367,7 @@ This won't catch subclasses. """ if isinstance(check, tuple): - for cls in check: - if type(obj) is cls: - return True - return False + return any(type(obj) is cls for cls in check) else: return type(obj) is check diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/serialize.py new/ipykernel-6.21.1/ipykernel/serialize.py --- old/ipykernel-6.20.2/ipykernel/serialize.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/serialize.py 2020-02-02 01:00:00.000000000 +0100 @@ -181,7 +181,7 @@ """unpack f,args,kwargs from buffers packed by pack_apply_message() Returns: original f,args,kwargs""" bufs = list(bufs) # allow us to pop - assert len(bufs) >= 2, "not enough buffers!" + assert len(bufs) >= 2, "not enough buffers!" # noqa pf = bufs.pop(0) f = uncan(pickle.loads(pf), g) pinfo = bufs.pop(0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/tests/test_debugger.py new/ipykernel-6.21.1/ipykernel/tests/test_debugger.py --- old/ipykernel-6.20.2/ipykernel/tests/test_debugger.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/tests/test_debugger.py 2020-02-02 01:00:00.000000000 +0100 @@ -282,3 +282,100 @@ from ipykernel.compiler import _convert_to_long_pathname _convert_to_long_pathname(__file__) + + +def test_copy_to_globals(kernel_with_debug): + local_var_name = "var" + global_var_name = "var_copy" + code = f"""from IPython.core.display import HTML +def my_test(): + {local_var_name} = HTML('<p>test content</p>') + pass +a = 2 +my_test()""" + + # Init debugger and set breakpoint + r = wait_for_debug_request(kernel_with_debug, "dumpCell", {"code": code}) + source = r["body"]["sourcePath"] + + wait_for_debug_request( + kernel_with_debug, + "setBreakpoints", + { + "breakpoints": [{"line": 4}], + "source": {"path": source}, + "sourceModified": False, + }, + ) + + wait_for_debug_request(kernel_with_debug, "debugInfo") + + wait_for_debug_request(kernel_with_debug, "configurationDone") + + # Execute code + kernel_with_debug.execute(code) + + # Wait for stop on breakpoint + msg: dict = {"msg_type": "", "content": {}} + while msg.get("msg_type") != "debug_event" or msg["content"].get("event") != "stopped": + msg = kernel_with_debug.get_iopub_msg(timeout=TIMEOUT) + + stacks = wait_for_debug_request(kernel_with_debug, "stackTrace", {"threadId": 1})["body"][ + "stackFrames" + ] + + # Get local frame id + frame_id = stacks[0]["id"] + + # Copy the variable + wait_for_debug_request( + kernel_with_debug, + "copyToGlobals", + { + "srcVariableName": local_var_name, + "dstVariableName": global_var_name, + "srcFrameId": frame_id, + }, + ) + + # Get the scopes + scopes = wait_for_debug_request(kernel_with_debug, "scopes", {"frameId": frame_id})["body"][ + "scopes" + ] + + # Get the local variable + locals_ = wait_for_debug_request( + kernel_with_debug, + "variables", + { + "variablesReference": next(filter(lambda s: s["name"] == "Locals", scopes))[ + "variablesReference" + ] + }, + )["body"]["variables"] + + local_var = None + for variable in locals_: + if local_var_name in variable["evaluateName"]: + local_var = variable + assert local_var is not None + + # Get the global variable (copy of the local variable) + globals_ = wait_for_debug_request( + kernel_with_debug, + "variables", + { + "variablesReference": next(filter(lambda s: s["name"] == "Globals", scopes))[ + "variablesReference" + ] + }, + )["body"]["variables"] + + global_var = None + for variable in globals_: + if global_var_name in variable["evaluateName"]: + global_var = variable + assert global_var is not None + + # Compare local and global variable + assert global_var["value"] == local_var["value"] and global_var["type"] == local_var["type"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/tests/test_eventloop.py new/ipykernel-6.21.1/ipykernel/tests/test_eventloop.py --- old/ipykernel-6.20.2/ipykernel/tests/test_eventloop.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/tests/test_eventloop.py 2020-02-02 01:00:00.000000000 +0100 @@ -33,7 +33,7 @@ try: __import__(gui_to_module[gui]) qt_guis_avail.append(gui) - if 'QT_API' in os.environ.keys(): + if 'QT_API' in os.environ: del os.environ['QT_API'] except ImportError: pass # that version of Qt isn't available. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/tests/test_jsonutil.py new/ipykernel-6.21.1/ipykernel/tests/test_jsonutil.py --- old/ipykernel-6.20.2/ipykernel/tests/test_jsonutil.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/tests/test_jsonutil.py 2020-02-02 01:00:00.000000000 +0100 @@ -53,7 +53,7 @@ # More exotic objects ((x for x in range(3)), [0, 1, 2]), (iter([1, 2]), [1, 2]), - (datetime(1991, 7, 3, 12, 00), "1991-07-03T12:00:00.000000"), + (datetime(1991, 7, 3, 12, 00), "1991-07-03T12:00:00.000000"), # noqa (date(1991, 7, 3), "1991-07-03T00:00:00.000000"), (MyFloat(), 3.14), (MyInt(), 389), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/ipykernel/tests/test_parentpoller.py new/ipykernel-6.21.1/ipykernel/tests/test_parentpoller.py --- old/ipykernel-6.20.2/ipykernel/tests/test_parentpoller.py 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/ipykernel/tests/test_parentpoller.py 2020-02-02 01:00:00.000000000 +0100 @@ -33,7 +33,7 @@ def mock_wait(*args, **kwargs): return -1 - with mock.patch("ctypes.windll.kernel32.WaitForMultipleObjects", mock_wait): + with mock.patch("ctypes.windll.kernel32.WaitForMultipleObjects", mock_wait): # noqa with warnings.catch_warnings(): warnings.simplefilter("ignore") poller.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipykernel-6.20.2/pyproject.toml new/ipykernel-6.21.1/pyproject.toml --- old/ipykernel-6.20.2/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/ipykernel-6.21.1/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -25,17 +25,19 @@ urls = {Homepage = "https://ipython.org"} requires-python = ">=3.8" dependencies = [ - "debugpy>=1.0", + "debugpy>=1.6.5", "ipython>=7.23.1", "comm>=0.1.1", "traitlets>=5.4.0", "jupyter_client>=6.1.12", + "jupyter_core>=4.12,!=5.0.*", + # For tk event loop support only. + "nest_asyncio", "tornado>=6.1", "matplotlib-inline>=0.1", 'appnope;platform_system=="Darwin"', "pyzmq>=17", "psutil", - "nest_asyncio", "packaging", ] @@ -114,7 +116,7 @@ test = "mypy --install-types --non-interactive {args:.}" [tool.hatch.envs.lint] -dependencies = ["black==22.12.0", "mdformat>0.7", "ruff==0.0.215"] +dependencies = ["black==22.12.0", "mdformat>0.7", "ruff==0.0.236"] detached = true [tool.hatch.envs.lint.scripts] style = [ @@ -211,8 +213,31 @@ target-version = "py37" line-length = 100 select = [ - "A", "B", "C", "E", "EM", "F", "FBT", "I", "N", "Q", "RUF", "S", "T", - "UP", "W", "YTT", + "A", + "B", + "C", + "DTZ", + "E", + "EM", + "F", + "FBT", + "I", + "ICN", + "ISC", + "N", + "PLC", + "PLE", + "PLR", + "PLW", + "Q", + "RUF", + "S", + "SIM", + "T", + "TID", + "UP", + "W", + "YTT", ] ignore = [ # Allow non-abstract empty methods in abstract base classes @@ -247,6 +272,8 @@ "C408", # N801 Class name `directional_link` should use CapWords convention "N801", + # SIM105 Use `contextlib.suppress(ValueError)` instead of try-except-pass + "SIM105", ] unfixable = [ # Don't touch print statements @@ -265,7 +292,8 @@ # N802 Function name `assertIn` should be lowercase # F841 Local variable `t` is assigned to but never used # EM101 Exception must not use a string literal, assign to variable first -"ipykernel/tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "F841", "EM101", "EM102"] +# PLR2004 Magic value used in comparison +"ipykernel/tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "F841", "EM101", "EM102", "EM103", "PLR2004"] [tool.interrogate] ignore-init-module=true