Skip to content

Commit

Permalink
Drop Python 3.8, test PyPy 3.10 (#323)
Browse files Browse the repository at this point in the history
* Drop Python 3.8, test PyPy 3.10

* Fix lint

* Require nbconvert>=7.1.0 in tests

* Fix tests

* Skip test Interrupt.ipynb on PyPy
  • Loading branch information
davidbrochart authored Dec 19, 2024
1 parent a6628b8 commit 5a68cb3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,10 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: windows-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "pypy-3.8"
- os: ubuntu-latest
python-version: "3.12"
- os: macos-latest
python-version: "3.10"
python-version: "pypy-3.10"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
5 changes: 3 additions & 2 deletions nbclient/_version.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Version info."""
from __future__ import annotations

import re
from typing import List, Union

__version__ = "0.10.1"

# Build up version_info tuple for backwards compatibility
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
match = re.match(pattern, __version__)
if match:
parts: List[Union[int, str]] = [int(match[part]) for part in ["major", "minor", "patch"]]
parts: list[int | str] = [int(match[part]) for part in ["major", "minor", "patch"]]
if match["rest"]:
parts.append(match["rest"])
else:
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dynamic = [
description = "A client library for executing notebooks. Formerly nbconvert's ExecutePreprocessor."
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.8.0"
requires-python = ">=3.9.0"
authors = [
{ name = "Jupyter Development Team", email = "[email protected]" },
]
Expand All @@ -29,10 +29,11 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"jupyter_client>=6.1.12",
Expand All @@ -47,7 +48,7 @@ test = [
"ipykernel>=6.19.3",
"ipython",
"ipywidgets",
"nbconvert>=7.0.0",
"nbconvert>=7.1.0",
"pytest-asyncio",
"pytest-cov>=4.0",
"pytest>=7.0,<8",
Expand Down
10 changes: 8 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from pathlib import Path
from subprocess import CalledProcessError, check_output
from unittest.mock import call, mock_open, patch
Expand All @@ -6,6 +7,11 @@

from nbclient.cli import NbClientApp

if sys.version_info >= (3, 13):
PATH_OPEN_CALL_STEP = 4
else:
PATH_OPEN_CALL_STEP = 3

current_dir = Path(__file__).parent.absolute()


Expand Down Expand Up @@ -60,7 +66,7 @@ def test_mult(input_names, relative, inplace, jupyterapp, client, reader, writer
# add suffix if needed
paths = [p.with_suffix(".ipynb") for p in paths]

assert path_open.mock_calls[::3] == [call(p) for p in paths]
assert path_open.mock_calls[::PATH_OPEN_CALL_STEP] == [call(p) for p in paths]
assert reader.call_count == len(paths)
# assert reader.mock_calls == [call(p, as_version=4) for p in paths]

Expand Down Expand Up @@ -114,7 +120,7 @@ def test_output(input_names, relative, output_base, jupyterapp, client, reader,
# add suffix if needed
paths = [p.with_suffix(".ipynb") for p in paths]

assert path_open.mock_calls[::3] == [call(p) for p in paths]
assert path_open.mock_calls[::PATH_OPEN_CALL_STEP] == [call(p) for p in paths]
assert reader.call_count == len(paths)

expected = []
Expand Down
4 changes: 3 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import threading
import warnings
from base64 import b64decode, b64encode
from platform import python_implementation
from queue import Empty
from typing import Any
from unittest.mock import MagicMock, Mock
Expand Down Expand Up @@ -325,14 +326,15 @@ def filter_messages_on_error_output(err_output):
("Factorials.ipynb", {"kernel_name": "python"}),
("HelloWorld.ipynb", {"kernel_name": "python"}),
("Inline Image.ipynb", {"kernel_name": "python"}),
(
pytest.param(
"Interrupt.ipynb",
{
"kernel_name": "python",
"timeout": 3,
"interrupt_on_timeout": True,
"allow_errors": True,
},
marks=pytest.mark.skipif(python_implementation() == "PyPy", reason="PyPy hangs"),
),
("JupyterWidgets.ipynb", {"kernel_name": "python"}),
("Skip Exceptions with Cell Tags.ipynb", {"kernel_name": "python"}),
Expand Down

0 comments on commit 5a68cb3

Please sign in to comment.