Skip to content

Commit 41a965e

Browse files
Carreauminrk
andauthored
start testing on 3.13 (#1277)
Co-authored-by: Min RK <[email protected]>
1 parent a60c864 commit 41a965e

File tree

10 files changed

+33
-24
lines changed

10 files changed

+33
-24
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: [ubuntu-latest, windows-latest, macos-latest]
25-
python-version: ["3.9", "3.12"]
25+
python-version: ["3.9", "3.13"]
2626
include:
2727
- os: ubuntu-latest
2828
python-version: "pypy-3.9"
2929
- os: macos-latest
3030
python-version: "3.10"
3131
- os: ubuntu-latest
3232
python-version: "3.11"
33+
- os: ubuntu-latest
34+
python-version: "3.12"
3335
steps:
3436
- name: Checkout
3537
uses: actions/checkout@v4
@@ -148,6 +150,7 @@ jobs:
148150
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
149151
with:
150152
dependency_type: minimum
153+
python_version: "3.9"
151154

152155
- name: List installed packages
153156
run: |

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
import shutil
1515
from pathlib import Path
16-
from typing import Any, Dict, List
16+
from typing import Any
1717

1818
# If extensions (or modules to document with autodoc) are in another directory,
1919
# add these directories to sys.path here. If the directory is relative to the
@@ -70,7 +70,7 @@
7070
# built documents.
7171
#
7272

73-
version_ns: Dict[str, Any] = {}
73+
version_ns: dict[str, Any] = {}
7474
here = Path(__file__).parent.resolve()
7575
version_py = Path(here) / os.pardir / "ipykernel" / "_version.py"
7676
with open(version_py) as f:
@@ -159,7 +159,7 @@
159159
# Add any paths that contain custom static files (such as style sheets) here,
160160
# relative to this directory. They are copied after the builtin static files,
161161
# so a file named "default.css" will overwrite the builtin "default.css".
162-
html_static_path: List[str] = []
162+
html_static_path: list[str] = []
163163

164164
# Add any extra paths that contain custom files (such as robots.txt or
165165
# .htaccess) here, relative to this directory. These files are copied
@@ -226,7 +226,7 @@
226226

227227
# -- Options for LaTeX output ---------------------------------------------
228228

229-
latex_elements: Dict[str, object] = {}
229+
latex_elements: dict[str, object] = {}
230230

231231
# Grouping the document tree into LaTeX files. List of tuples
232232
# (source start file, target name, title,

ipykernel/_version.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
store the current version info of the server.
33
"""
44
import re
5-
from typing import List
65

76
# Version string must appear intact for hatch versioning
87
__version__ = "7.0.0a0"
@@ -11,7 +10,7 @@
1110
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
1211
match = re.match(pattern, __version__)
1312
assert match is not None
14-
parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
13+
parts: list[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
1514
if match["rest"]:
1615
parts.append(match["rest"])
1716
version_info = tuple(parts)

ipykernel/debugger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _reset_tcp_pos(self):
130130

131131
def _put_message(self, raw_msg):
132132
self.log.debug("QUEUE - _put_message:")
133-
msg = t.cast(t.Dict[str, t.Any], jsonapi.loads(raw_msg))
133+
msg = t.cast(dict[str, t.Any], jsonapi.loads(raw_msg))
134134
if msg["type"] == "event":
135135
self.log.debug("QUEUE - received event:")
136136
self.log.debug(msg)

ipykernel/inprocess/channels.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# Copyright (c) IPython Development Team.
44
# Distributed under the terms of the Modified BSD License.
55

6-
from typing import List
7-
86
from jupyter_client.channelsabc import HBChannelABC
97

108
# -----------------------------------------------------------------------------
@@ -15,7 +13,7 @@
1513
class InProcessChannel:
1614
"""Base class for in-process channels."""
1715

18-
proxy_methods: List[object] = []
16+
proxy_methods: list[object] = []
1917

2018
def __init__(self, client=None):
2119
"""Initialize the channel."""

ipykernel/iostream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from collections import defaultdict, deque
1616
from io import StringIO, TextIOBase
1717
from threading import Event, Thread, local
18-
from typing import Any, Callable, Deque, Dict, Optional
18+
from typing import Any, Callable, Optional
1919

2020
import zmq
2121
from anyio import create_task_group, run, sleep, to_thread
@@ -94,8 +94,8 @@ def __init__(self, socket, pipe=False):
9494
if pipe:
9595
self._setup_pipe_in()
9696
self._local = threading.local()
97-
self._events: Deque[Callable[..., Any]] = deque()
98-
self._event_pipes: Dict[threading.Thread, Any] = {}
97+
self._events: deque[Callable[..., Any]] = deque()
98+
self._event_pipes: dict[threading.Thread, Any] = {}
9999
self._event_pipe_gc_lock: threading.Lock = threading.Lock()
100100
self._event_pipe_gc_seconds: float = 10
101101
self._setup_event_pipe()
@@ -470,7 +470,7 @@ def __init__(
470470
self.pub_thread = pub_thread
471471
self.name = name
472472
self.topic = b"stream." + name.encode()
473-
self._parent_header: contextvars.ContextVar[Dict[str, Any]] = contextvars.ContextVar(
473+
self._parent_header: contextvars.ContextVar[dict[str, Any]] = contextvars.ContextVar(
474474
"parent_header"
475475
)
476476
self._parent_header.set({})

ipykernel/ipkernel.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""The IPython kernel implementation"""
22

3+
from __future__ import annotations
4+
35
import builtins
46
import gc
57
import getpass
@@ -16,7 +18,7 @@
1618
from IPython.core import release
1719
from IPython.utils.tokenutil import line_at_cursor, token_at_cursor
1820
from jupyter_client.session import extract_header
19-
from traitlets import Any, Bool, HasTraits, Instance, List, Type, observe, observe_compat
21+
from traitlets import Any, Bool, HasTraits, Instance, List, Type, default, observe, observe_compat
2022

2123
from .comm.comm import BaseComm
2224
from .comm.manager import CommManager
@@ -46,7 +48,7 @@ def _create_comm(*args, **kwargs):
4648

4749
# there can only be one comm manager in a ipykernel process
4850
_comm_lock = threading.Lock()
49-
_comm_manager: t.Optional[CommManager] = None
51+
_comm_manager: CommManager | None = None
5052

5153

5254
def _get_comm_manager(*args, **kwargs):
@@ -84,7 +86,11 @@ def _user_module_changed(self, change):
8486
if self.shell is not None:
8587
self.shell.user_module = change["new"]
8688

87-
user_ns = Instance(dict, args=None, allow_none=True)
89+
user_ns = Instance("collections.abc.Mapping", allow_none=True)
90+
91+
@default("user_ns")
92+
def _default_user_ns(self):
93+
return dict()
8894

8995
@observe("user_ns")
9096
@observe_compat
@@ -353,7 +359,7 @@ async def do_execute(
353359

354360
self._forward_input(allow_stdin)
355361

356-
reply_content: t.Dict[str, t.Any] = {}
362+
reply_content: dict[str, t.Any] = {}
357363
if hasattr(shell, "run_cell_async") and hasattr(shell, "should_run_async"):
358364
run_cell = shell.run_cell_async
359365
should_run_async = shell.should_run_async
@@ -559,7 +565,7 @@ def do_inspect(self, code, cursor_pos, detail_level=0, omit_sections=()):
559565
"""Handle code inspection."""
560566
name = token_at_cursor(code, cursor_pos)
561567

562-
reply_content: t.Dict[str, t.Any] = {"status": "ok"}
568+
reply_content: dict[str, t.Any] = {"status": "ok"}
563569
reply_content["data"] = {}
564570
reply_content["metadata"] = {}
565571
assert self.shell is not None
@@ -755,7 +761,7 @@ def init_closure(self: threading.Thread, *args, **kwargs):
755761
threading.Thread.run = run_closure # type:ignore[method-assign]
756762

757763
def _clean_thread_parent_frames(
758-
self, phase: t.Literal["start", "stop"], info: t.Dict[str, t.Any]
764+
self, phase: t.Literal["start", "stop"], info: dict[str, t.Any]
759765
):
760766
"""Clean parent frames of threads which are no longer running.
761767
This is meant to be invoked by garbage collector callback hook.

ipykernel/pickleutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def __init__(self, f):
209209
"""Initialize the can"""
210210
self._check_type(f)
211211
self.code = f.__code__
212-
self.defaults: typing.Optional[typing.List[typing.Any]]
212+
self.defaults: typing.Optional[list[typing.Any]]
213213
if f.__defaults__:
214214
self.defaults = [can(fd) for fd in f.__defaults__]
215215
else:
@@ -475,7 +475,7 @@ def uncan_sequence(obj, g=None):
475475
if buffer is not memoryview:
476476
can_map[buffer] = CannedBuffer
477477

478-
uncan_map: typing.Dict[type, typing.Any] = {
478+
uncan_map: dict[type, typing.Any] = {
479479
CannedObject: lambda obj, g: obj.get_object(g),
480480
dict: uncan_dict,
481481
}

ipykernel/thread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, **kwargs):
1717
self.pydev_do_not_trace = True
1818
self.is_pydev_daemon_thread = True
1919
self.__stop = Event()
20-
self._tasks_and_args: t.List[t.Tuple[t.Any, t.Any]] = []
20+
self._tasks_and_args: list[tuple[t.Any, t.Any]] = []
2121

2222
def add_task(self, task: t.Any, *args: t.Any) -> None:
2323
# May only add tasks before the thread is started.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ filterwarnings= [
187187

188188
# https://github.com/python-trio/trio/issues/3053
189189
"ignore:The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025.",
190+
191+
# ignore unclosed sqlite in traits
192+
"ignore:unclosed database in <sqlite3.Connection:ResourceWarning",
190193
]
191194

192195
[tool.coverage.report]

0 commit comments

Comments
 (0)