Skip to content

Commit 76a0f57

Browse files
authored
Support Python 3.8-3.11 (#866)
1 parent e05fdd1 commit 76a0f57

23 files changed

+47
-46
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ jobs:
4141
fail-fast: false
4242
matrix:
4343
os: [ubuntu-latest, windows-latest, macos-latest]
44-
python-version: ["3.7", "3.10"]
44+
python-version: ["3.8", "3.11"]
4545
include:
4646
- os: windows-latest
4747
python-version: "3.9"
4848
- os: ubuntu-latest
4949
python-version: "pypy-3.8"
5050
- os: ubuntu-latest
51-
python-version: "3.11-dev"
51+
python-version: "3.10"
5252
- os: macos-latest
5353
python-version: "3.8"
5454
steps:
@@ -86,7 +86,7 @@ jobs:
8686
- name: Base Setup
8787
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
8888
with:
89-
python_version: "3.7"
89+
python_version: "3.8"
9090
- name: Install miniumum versions
9191
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
9292
- name: Run the unit tests

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ repos:
3737
hooks:
3838
- id: mdformat
3939

40+
- repo: https://github.com/asottile/pyupgrade
41+
rev: v3.1.0
42+
hooks:
43+
- id: pyupgrade
44+
args: [--py38-plus]
45+
4046
- repo: https://github.com/PyCQA/doc8
4147
rev: v1.0.0
4248
hooks:

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
sphinx:
33
configuration: docs/conf.py
44
python:
5-
version: 3.7
5+
version: 3.8
66
install:
77
# install jupyter-client itself
88
- method: pip

jupyter_client/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def extract_oname_v4(code: str, cursor_pos: int) -> str:
5656
return ""
5757

5858

59-
class Adapter(object):
59+
class Adapter:
6060
"""Base class for adapting messages
6161
6262
Override message_type(msg) methods to create adapters.

jupyter_client/channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def call_handlers(self, since_last_heartbeat: float) -> None:
191191
HBChannelABC.register(HBChannel)
192192

193193

194-
class ZMQSocketChannel(object):
194+
class ZMQSocketChannel:
195195
"""A ZMQ socket wrapper"""
196196

197197
def __init__(self, socket: zmq.Socket, session: Session, loop: t.Any = None) -> None:

jupyter_client/channelsabc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import abc
55

66

7-
class ChannelABC(object, metaclass=abc.ABCMeta):
7+
class ChannelABC(metaclass=abc.ABCMeta):
88
"""A base class for all channel ABCs."""
99

1010
@abc.abstractmethod

jupyter_client/clientabc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# -----------------------------------------------------------------------------
1616

1717

18-
class KernelClientABC(object, metaclass=abc.ABCMeta):
18+
class KernelClientABC(metaclass=abc.ABCMeta):
1919
"""KernelManager ABC.
2020
2121
The docstrings for this class can be found in the base implementation:

jupyter_client/connect.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def write_connection_file(
130130
else:
131131
N = 1
132132
for _ in range(ports_needed):
133-
while os.path.exists("%s-%s" % (ip, str(N))):
133+
while os.path.exists(f"{ip}-{str(N)}"):
134134
N += 1
135135
ports.append(N)
136136
N += 1
@@ -229,7 +229,7 @@ def find_connection_file(
229229
try:
230230
# first, try explicit name
231231
return _filefind(filename, path)
232-
except IOError:
232+
except OSError:
233233
pass
234234

235235
# not found by full name
@@ -247,7 +247,7 @@ def find_connection_file(
247247

248248
matches = [os.path.abspath(m) for m in matches]
249249
if not matches:
250-
raise IOError("Could not find %r in %r" % (filename, path))
250+
raise OSError(f"Could not find {filename!r} in {path!r}")
251251
elif len(matches) == 1:
252252
return matches[0]
253253
else:
@@ -605,7 +605,7 @@ def _make_url(self, channel: str) -> str:
605605
if transport == "tcp":
606606
return "tcp://%s:%i" % (ip, port)
607607
else:
608-
return "%s://%s-%s" % (transport, ip, port)
608+
return f"{transport}://{ip}-{port}"
609609

610610
def _create_connected_socket(
611611
self, channel: str, identity: Optional[bytes] = None

jupyter_client/consoleapp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def init_connection_file(self) -> None:
202202
self.connection_file = cf
203203
try:
204204
self.connection_file = _filefind(self.connection_file, [".", self.runtime_dir])
205-
except IOError:
205+
except OSError:
206206
self.log.debug("Connection File not found: %s", self.connection_file)
207207
return
208208

@@ -247,7 +247,7 @@ def init_ssh(self) -> None:
247247
control_port=self.control_port,
248248
)
249249

250-
self.log.info("Forwarding connections to %s via %s" % (ip, self.sshserver))
250+
self.log.info(f"Forwarding connections to {ip} via {self.sshserver}")
251251

252252
# tunnels return a new set of ports, which will be on localhost:
253253
self.ip = localhost()

jupyter_client/kernelspec.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Tools for managing kernel specs"""
22
# Copyright (c) Jupyter Development Team.
33
# Distributed under the terms of the Modified BSD License.
4-
import io
54
import json
65
import os
76
import re
@@ -47,7 +46,7 @@ def from_resource_dir(cls, resource_dir):
4746
Pass the path to the *directory* containing kernel.json.
4847
"""
4948
kernel_file = pjoin(resource_dir, "kernel.json")
50-
with io.open(kernel_file, "r", encoding="utf-8") as f:
49+
with open(kernel_file, encoding="utf-8") as f:
5150
kernel_dict = json.load(f)
5251
return cls(resource_dir=resource_dir, **kernel_dict)
5352

@@ -106,7 +105,7 @@ def _list_kernels_in(dir):
106105
key = f.lower()
107106
if not _is_valid_kernel_name(key):
108107
warnings.warn(
109-
"Invalid kernelspec directory name (%s): %s" % (_kernel_name_description, path),
108+
f"Invalid kernelspec directory name ({_kernel_name_description}): {path}",
110109
stacklevel=3,
111110
)
112111
kernels[key] = path
@@ -118,7 +117,7 @@ def __init__(self, name):
118117
self.name = name
119118

120119
def __str__(self):
121-
return "No such kernel named {}".format(self.name)
120+
return f"No such kernel named {self.name}"
122121

123122

124123
class KernelSpecManager(LoggingConfigurable):
@@ -375,9 +374,7 @@ def install_kernel_spec(
375374
kernel_name = os.path.basename(source_dir)
376375
kernel_name = kernel_name.lower()
377376
if not _is_valid_kernel_name(kernel_name):
378-
raise ValueError(
379-
"Invalid kernel name %r. %s" % (kernel_name, _kernel_name_description)
380-
)
377+
raise ValueError(f"Invalid kernel name {kernel_name!r}. {_kernel_name_description}")
381378

382379
if user and prefix:
383380
raise ValueError("Can't specify both user and prefix. Please choose one or the other.")

0 commit comments

Comments
 (0)