Skip to content
Open
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
chore: drop support for Python < 3.10
- Require Python >= 3.10 in pyproject.toml and mypy configuration
- Update CI workflow matrix to test Python 3.10-3.13 and PyPy 3.10
- Modernize type annotations in comm/base_comm.py to Python 3.10+ syntax
  • Loading branch information
schwehr committed Aug 21, 2026
commit 1e7b68e2cc50fb63fe127a9847c9c19336785b0d
8 changes: 4 additions & 4 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.12", "3.13"]
python-version: ["3.10", "3.13"]
include:
- os: windows-latest
python-version: "3.9"
python-version: "3.11"
- os: ubuntu-latest
python-version: "pypy-3.9"
python-version: "pypy-3.10"
- os: ubuntu-latest
python-version: "3.10"
python-version: "3.12"
- os: macos-latest
python-version: "3.11"
steps:
Expand Down
13 changes: 7 additions & 6 deletions comm/base_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

logger = logging.getLogger("Comm")

MessageType = t.Dict[str, t.Any]
MaybeDict = t.Optional[t.Dict[str, t.Any]]
BuffersType = t.Optional[t.List[bytes]]
MessageType = dict[str, t.Any]
MaybeDict = dict[str, t.Any] | None
BuffersType = list[bytes] | None
CommCallback = t.Callable[[MessageType], None]
CommTargetCallback = t.Callable[["BaseComm", MessageType], None]

Expand Down Expand Up @@ -209,22 +209,23 @@ def register_target(self, target_name: str, f: CommTargetCallback | str) -> None

f can be a Python callable or an import string for one.
"""
func: t.Any = f
if isinstance(f, str):
parts = f.rsplit(".", 1)
if len(parts) == 2:
# called with 'foo.bar....'
package, obj = parts
module = __import__(package, fromlist=[obj])
try:
f = getattr(module, obj)
func = getattr(module, obj)
except AttributeError as e:
error_msg = f"No module named {obj}"
raise ImportError(error_msg) from e
else:
# called with un-dotted string
f = __import__(parts[0])
func = __import__(parts[0])

self.targets[target_name] = t.cast(CommTargetCallback, f)
self.targets[target_name] = t.cast(CommTargetCallback, func)

def unregister_target(self, target_name: str, f: CommTargetCallback) -> CommTargetCallback: # noqa: ARG002
"""Unregister a callable registered with register_target"""
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
description = "Jupyter Python Comm implementation, for usage in ipykernel, xeus-python etc."
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.8"
requires-python = ">=3.10"
authors = [
{ name = "Jupyter contributors" },
]
Expand Down Expand Up @@ -74,7 +74,7 @@ filterwarnings = ["error"]

[tool.mypy]
files = "comm"
python_version = "3.8"
python_version = "3.10"
strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true
Expand Down
Loading