Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated zmq imports #1011

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
env:
OS: ${{ matrix.os }}
PYTHON: "3.9"
Expand All @@ -55,8 +55,6 @@ jobs:
pip install --upgrade setuptools pip
pip install --upgrade --upgrade-strategy eager --pre -e .[test] pytest-cov codecov 'coverage<5'
pip freeze
- name: Check types
run: mypy jupyter_client/manager.py jupyter_client/multikernelmanager.py jupyter_client/client.py jupyter_client/blocking/client.py jupyter_client/asynchronous/client.py jupyter_client/channels.py jupyter_client/session.py jupyter_client/adapter.py jupyter_client/connect.py jupyter_client/consoleapp.py jupyter_client/jsonutil.py jupyter_client/kernelapp.py jupyter_client/launcher.py jupyter_client/threaded.py
- name: Run the tests
run: py.test --cov jupyter_client -v jupyter_client
- name: Code coverage
Expand Down
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.9.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 24.2.0
hooks:
- id: black
args: ["--line-length", "100"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
hooks:
- id: prettier
- repo: https://gitlab.com/pycqa/flake8
rev: "3.8.4"
- repo: https://github.com/PyCQA/flake8
rev: "7.0.0"
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
9 changes: 5 additions & 4 deletions readthedocs.yml → .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ version: 2
sphinx:
configuration: docs/conf.py
python:
version: 3.7
install:
# install docs requirements
- requirements: docs/requirements.txt
# install jupyter-client itself
- method: pip
path: .
path: ".[doc]"
build:
os: ubuntu-22.04
tools:
python: "3.11"
1 change: 1 addition & 0 deletions jupyter_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Client-side implementations of the Jupyter protocol"""

from ._version import __version__ # noqa
from ._version import protocol_version # noqa
from ._version import protocol_version_info # noqa
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Adapters for Jupyter msg spec versions."""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/asynchronous/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implements an async kernel client"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from traitlets import Type # type: ignore
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/blocking/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Useful for test suites and blocking terminal interfaces.
"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from traitlets import Type # type: ignore
Expand Down
7 changes: 4 additions & 3 deletions jupyter_client/channels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base classes to manage a Client's interaction with a running kernel"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio
Expand Down Expand Up @@ -255,7 +256,7 @@ async def _recv(self, **kwargs) -> t.Dict[str, t.Any]:
return self.session.deserialize(smsg)

async def get_msg(self, timeout: t.Optional[float] = None) -> t.Dict[str, t.Any]:
""" Gets a message if there is one that is ready. """
"""Gets a message if there is one that is ready."""
if timeout is not None:
timeout *= 1000 # seconds to ms
assert self.socket is not None
Expand All @@ -268,7 +269,7 @@ async def get_msg(self, timeout: t.Optional[float] = None) -> t.Dict[str, t.Any]
raise Empty

async def get_msgs(self) -> t.List[t.Dict[str, t.Any]]:
""" Get all messages that are currently ready. """
"""Get all messages that are currently ready."""
msgs = []
while True:
try:
Expand All @@ -278,7 +279,7 @@ async def get_msgs(self) -> t.List[t.Dict[str, t.Any]]:
return msgs

async def msg_ready(self) -> bool:
""" Is there a message that has been received? """
"""Is there a message that has been received?"""
assert self.socket is not None
return bool(await self.socket.poll(timeout=0))

Expand Down
1 change: 1 addition & 0 deletions jupyter_client/channelsabc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Abstract base classes for kernel client channels"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import abc
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base class to manage the interaction with a running kernel"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/clientabc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Abstract base class for kernel clients"""

# -----------------------------------------------------------------------------
# Copyright (c) The Jupyter Development Team
#
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The :class:`ConnectionFileMixin` class in this module encapsulates the logic
related to writing and reading connections files.
"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import errno
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/consoleapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
input, there is no real readline support, among other limitations. This is a
refactoring of what used to be the IPython/qt/console/qtconsoleapp.py
"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import atexit
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/ioloop/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A kernel manager with a tornado IOLoop"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from tornado import ioloop
Expand Down
3 changes: 3 additions & 0 deletions jupyter_client/ioloop/restarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This watches a kernel's state using KernelManager.is_alive and auto
restarts the kernel if it dies.
"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import warnings
Expand All @@ -24,6 +25,8 @@ def _loop_default(self):
DeprecationWarning,
stacklevel=4,
)
from tornado import ioloop

return ioloop.IOLoop.current()

_pcallback = None
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/jsonutil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities to manipulate JSON objects."""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import re
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/kernelspec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for managing kernel specs"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import io
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/launcher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for launching kernels"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/localinterfaces.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for identifying local IP addresses."""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base class to manage a running kernel"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/managerabc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Abstract base class for kernel managers."""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import abc
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/multikernelmanager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A kernel manager for multiple kernels"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/restarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

It is an incomplete base class, and must be subclassed.
"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from traitlets import Bool # type: ignore
Expand Down
7 changes: 4 additions & 3 deletions jupyter_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Sessions.
* A Message object for convenience that allows attribute-access to the msg dict.
"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import hashlib
Expand All @@ -27,6 +28,7 @@
) # We are using compare_digest to limit the surface of timing attacks

import zmq
from tornado.ioloop import IOLoop
from traitlets import Any # type: ignore
from traitlets import Bool
from traitlets import CBytes
Expand All @@ -43,7 +45,6 @@
from traitlets.config.configurable import LoggingConfigurable
from traitlets.log import get_logger # type: ignore
from traitlets.utils.importstring import import_item # type: ignore
from zmq.eventloop.ioloop import IOLoop
from zmq.eventloop.zmqstream import ZMQStream
from zmq.utils import jsonapi

Expand Down Expand Up @@ -444,7 +445,7 @@ def _new_auth(self) -> None:

digest_history = Set()
digest_history_size = Integer(
2 ** 16,
2**16,
config=True,
help="""The maximum number of digests to remember.

Expand Down Expand Up @@ -483,7 +484,7 @@ def _unpack_changed(self, change):

# thresholds:
copy_threshold = Integer(
2 ** 16,
2**16,
config=True,
help="Threshold (in bytes) beyond which a buffer should be sent without copying.",
)
Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/ssh/tunnel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Basic ssh tunnel utilities, and convenience functions for tunneling
zeromq connections.
"""

# Copyright (C) 2010-2011 IPython Development Team
# Copyright (C) 2011- PyZMQ Developers
#
Expand Down Expand Up @@ -28,7 +29,6 @@
class SSHException(Exception): # type: ignore
pass


else:
from .forward import forward_tunnel

Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/signalkernel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test kernel for signalling subprocesses"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/test_adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for adapting Jupyter msg spec versions"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import copy
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the KernelClient"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
Expand Down
5 changes: 3 additions & 2 deletions jupyter_client/tests/test_connect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for kernel connection utilities"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
Expand Down Expand Up @@ -84,7 +85,7 @@ def test_write_connection_file():


def test_load_connection_file_session():
"""test load_connection_file() after """
"""test load_connection_file() after"""
session = Session()
app = DummyConsoleApp(session=Session())
app.initialize(argv=[])
Expand All @@ -101,7 +102,7 @@ def test_load_connection_file_session():


def test_load_connection_file_session_with_kn():
"""test load_connection_file() after """
"""test load_connection_file() after"""
session = Session()
app = DummyConsoleApp(session=Session())
app.initialize(argv=[])
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/test_jsonutil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test suite for our JSON utilities."""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import datetime
Expand Down
7 changes: 2 additions & 5 deletions jupyter_client/tests/test_kernelmanager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the KernelManager"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio
Expand All @@ -11,8 +12,6 @@
from subprocess import PIPE

import pytest
from async_generator import async_generator
from async_generator import yield_
from jupyter_core import paths
from traitlets.config.loader import Config

Expand Down Expand Up @@ -136,11 +135,9 @@ def async_km_subclass(config):


@pytest.fixture
@async_generator # This is only necessary while Python 3.5 is support afterwhich both it and
# yield_() can be removed
async def start_async_kernel():
km, kc = await start_new_async_kernel(kernel_name="signaltest")
await yield_((km, kc))
await km, kc
kc.stop_channels()
await km.shutdown_kernel()
assert km.context.closed
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/test_kernelspec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the KernelSpecManager"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import copy
Expand Down
3 changes: 2 additions & 1 deletion jupyter_client/tests/test_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for KernelManager"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
Expand All @@ -10,7 +11,7 @@


def test_connection_file_real_path():
""" Verify realpath is used when formatting connection file """
"""Verify realpath is used when formatting connection file"""
with mock.patch("os.path.realpath") as patched_realpath:
patched_realpath.return_value = "foobar"
km = KernelManager(
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/test_multikernelmanager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the notebook kernel and session manager."""

import asyncio
import concurrent.futures
import sys
Expand Down
1 change: 1 addition & 0 deletions jupyter_client/tests/test_public_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test the jupyter_client public API
"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import jupyter_client
Expand Down
Loading
Loading