Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jupyter/jupyter_client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.4.0
Choose a base ref
...
head repository: jupyter/jupyter_client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ff94e310c2af3546f2f9384e6b35fd11c3d09a71
Choose a head ref
  • 3 commits
  • 31 files changed
  • 2 contributors

Commits on Oct 15, 2023

  1. Copy the full SHA
    05e88b1 View commit details

Commits on Oct 23, 2023

  1. Allow to update kernels env in between restart. (#987)

    This allow to update the running env of kernels.
    
    This will allow resolves some inconsistencies between kernel restart, and actually
    stopping and starting a kernel session.
    
    In parsley via a few lines in Jupyter Server in update_session, this
    will let us update the `__session__` which is supposed to reflect some
    information about the current session, and help correct
    ipython/ipykernel#1102 where renaming a notebook is not reflected in the
    kernel unless you manually stop/start the session, or restart the
    server.
    Carreau authored Oct 23, 2023
    Copy the full SHA
    49dbf0f View commit details

Commits on Oct 25, 2023

  1. Enable strict typing (#984)

    * Use strict typing
    
    * fix imports
    
    * ignore pep585 and 604 typing changes
    blink1073 authored Oct 25, 2023
    Copy the full SHA
    ff94e31 View commit details
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
import os.path as osp
import shutil

from sphinx.util import logging # type:ignore[import]
from sphinx.util import logging # type:ignore[import-not-found]

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -51,7 +51,7 @@ def filter(self, record: pylogging.LogRecord) -> bool:
# End of a workaround

try:
import enchant # type:ignore[import] # noqa
import enchant # type:ignore[import-not-found] # noqa

extensions += ["sphinxcontrib.spelling"]
except ImportError:
@@ -329,7 +329,7 @@ def filter(self, record: pylogging.LogRecord) -> bool:
intersphinx_mapping = {'ipython': ('http://ipython.readthedocs.io/en/stable/', None)}


def setup(app):
def setup(app: object) -> None:
HERE = osp.abspath(osp.dirname(__file__))
dest = osp.join(HERE, 'changelog.md')
shutil.copy(osp.join(HERE, '..', 'CHANGELOG.md'), dest)
7 changes: 5 additions & 2 deletions jupyter_client/asynchronous/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Implements an async kernel client"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations

import typing as t

import zmq.asyncio
from traitlets import Instance, Type
@@ -9,10 +12,10 @@
from ..client import KernelClient, reqrep


def wrapped(meth, channel):
def wrapped(meth: t.Callable, channel: str) -> t.Callable:
"""Wrap a method on a channel and handle replies."""

def _(self, *args, **kwargs):
def _(self: AsyncKernelClient, *args: t.Any, **kwargs: t.Any) -> t.Any:
reply = kwargs.pop("reply", False)
timeout = kwargs.pop("timeout", None)
msg_id = meth(self, *args, **kwargs)
8 changes: 6 additions & 2 deletions jupyter_client/blocking/client.py
Original file line number Diff line number Diff line change
@@ -4,17 +4,21 @@
"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations

import typing as t

from traitlets import Type

from ..channels import HBChannel, ZMQSocketChannel
from ..client import KernelClient, reqrep
from ..utils import run_sync


def wrapped(meth, channel):
def wrapped(meth: t.Callable, channel: str) -> t.Callable:
"""Wrap a method on a channel and handle replies."""

def _(self, *args, **kwargs):
def _(self: BlockingKernelClient, *args: t.Any, **kwargs: t.Any) -> t.Any:
reply = kwargs.pop("reply", False)
timeout = kwargs.pop("timeout", None)
msg_id = meth(self, *args, **kwargs)
2 changes: 1 addition & 1 deletion jupyter_client/channels.py
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ def __init__(
context: t.Optional[zmq.Context] = None,
session: t.Optional[Session] = None,
address: t.Union[t.Tuple[str, int], str] = "",
):
) -> None:
"""Create the heartbeat monitor thread.
Parameters
14 changes: 7 additions & 7 deletions jupyter_client/channelsabc.py
Original file line number Diff line number Diff line change
@@ -8,17 +8,17 @@ class ChannelABC(metaclass=abc.ABCMeta):
"""A base class for all channel ABCs."""

@abc.abstractmethod
def start(self):
def start(self) -> None:
"""Start the channel."""
pass

@abc.abstractmethod
def stop(self):
def stop(self) -> None:
"""Stop the channel."""
pass

@abc.abstractmethod
def is_alive(self):
def is_alive(self) -> bool:
"""Test whether the channel is alive."""
pass

@@ -32,20 +32,20 @@ class HBChannelABC(ChannelABC):
"""

@abc.abstractproperty
def time_to_dead(self):
def time_to_dead(self) -> float:
pass

@abc.abstractmethod
def pause(self):
def pause(self) -> None:
"""Pause the heartbeat channel."""
pass

@abc.abstractmethod
def unpause(self):
def unpause(self) -> None:
"""Unpause the heartbeat channel."""
pass

@abc.abstractmethod
def is_beating(self):
def is_beating(self) -> bool:
"""Test whether the channel is beating."""
pass
4 changes: 2 additions & 2 deletions jupyter_client/client.py
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ def _context_default(self) -> zmq.Context:
# flag for whether execute requests should be allowed to call raw_input:
allow_stdin: bool = True

def __del__(self):
def __del__(self) -> None:
"""Handle garbage collection. Destroy context if applicable."""
if (
self._created_context
@@ -511,7 +511,7 @@ async def _async_execute_interactive(
if output_hook is None and "IPython" in sys.modules:
from IPython import get_ipython

ip = get_ipython()
ip = get_ipython() # type:ignore[no-untyped-call]
in_kernel = getattr(ip, "kernel", False)
if in_kernel:
output_hook = partial(
41 changes: 27 additions & 14 deletions jupyter_client/clientabc.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,13 @@
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
from __future__ import annotations

import abc
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from .channelsabc import ChannelABC

# -----------------------------------------------------------------------------
# Main kernel client class
@@ -24,64 +30,71 @@ class KernelClientABC(metaclass=abc.ABCMeta):
"""

@abc.abstractproperty
def kernel(self):
def kernel(self) -> Any:
pass

@abc.abstractproperty
def shell_channel_class(self):
def shell_channel_class(self) -> type[ChannelABC]:
pass

@abc.abstractproperty
def iopub_channel_class(self):
def iopub_channel_class(self) -> type[ChannelABC]:
pass

@abc.abstractproperty
def hb_channel_class(self):
def hb_channel_class(self) -> type[ChannelABC]:
pass

@abc.abstractproperty
def stdin_channel_class(self):
def stdin_channel_class(self) -> type[ChannelABC]:
pass

@abc.abstractproperty
def control_channel_class(self):
def control_channel_class(self) -> type[ChannelABC]:
pass

# --------------------------------------------------------------------------
# Channel management methods
# --------------------------------------------------------------------------

@abc.abstractmethod
def start_channels(self, shell=True, iopub=True, stdin=True, hb=True, control=True):
def start_channels(
self,
shell: bool = True,
iopub: bool = True,
stdin: bool = True,
hb: bool = True,
control: bool = True,
) -> None:
"""Start the channels for the client."""
pass

@abc.abstractmethod
def stop_channels(self):
def stop_channels(self) -> None:
"""Stop the channels for the client."""
pass

@abc.abstractproperty
def channels_running(self):
def channels_running(self) -> bool:
"""Get whether the channels are running."""
pass

@abc.abstractproperty
def shell_channel(self):
def shell_channel(self) -> ChannelABC:
pass

@abc.abstractproperty
def iopub_channel(self):
def iopub_channel(self) -> ChannelABC:
pass

@abc.abstractproperty
def stdin_channel(self):
def stdin_channel(self) -> ChannelABC:
pass

@abc.abstractproperty
def hb_channel(self):
def hb_channel(self) -> ChannelABC:
pass

@abc.abstractproperty
def control_channel(self):
def control_channel(self) -> ChannelABC:
pass
Loading