From 76e052aa9094708e24783641aa0f3c30df791535 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:11:58 +0000 Subject: [PATCH 1/8] Switch collection hook to use pathlib paths --- nbval/plugin.py | 13 +++---------- setup.py | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/nbval/plugin.py b/nbval/plugin.py index 7e75a5d..aee551f 100644 --- a/nbval/plugin.py +++ b/nbval/plugin.py @@ -134,21 +134,14 @@ def pytest_configure(config): -def pytest_collect_file(path, parent): +def pytest_collect_file(collection_path, parent): """ Collect IPython notebooks using the specified pytest hook """ opt = parent.config.option - if (opt.nbval or opt.nbval_lax) and path.fnmatch("*.ipynb"): + if (opt.nbval or opt.nbval_lax) and collection_path.suffix == ".ipynb": # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent - if hasattr(IPyNbFile, "from_parent"): - try: # Pytest >= 7.0.0 - return IPyNbFile.from_parent(parent, path=Path(path)) - except AssertionError: - return IPyNbFile.from_parent(parent, fspath=path) - else: # Pytest < 5.4 - return IPyNbFile(path, parent) - + return IPyNbFile.from_parent(parent, path=collection_path) comment_markers = { diff --git a/setup.py b/setup.py index 3448f98..f20eb7b 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ ] }, install_requires = [ - 'pytest >= 2.8', + 'pytest >= 7', 'jupyter_client', 'nbformat', 'ipykernel', From 3581d24cbde5d9bb1c81fa199a444a753e8c4d9c Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:19:00 +0000 Subject: [PATCH 2/8] Correct parameter name for hook --- nbval/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nbval/plugin.py b/nbval/plugin.py index aee551f..97c8268 100644 --- a/nbval/plugin.py +++ b/nbval/plugin.py @@ -134,14 +134,14 @@ def pytest_configure(config): -def pytest_collect_file(collection_path, parent): +def pytest_collect_file(file_path, parent): """ Collect IPython notebooks using the specified pytest hook """ opt = parent.config.option - if (opt.nbval or opt.nbval_lax) and collection_path.suffix == ".ipynb": + if (opt.nbval or opt.nbval_lax) and file_path.suffix == ".ipynb": # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent - return IPyNbFile.from_parent(parent, path=collection_path) + return IPyNbFile.from_parent(parent, path=file_path) comment_markers = { From d8d7c01fb71fbdf4eebcdeb6a4bdbda731aadaae Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:19:43 +0000 Subject: [PATCH 3/8] Remove some more compatibility code for old pytest (versions < 6) --- nbval/plugin.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/nbval/plugin.py b/nbval/plugin.py index 97c8268..ee3ff29 100644 --- a/nbval/plugin.py +++ b/nbval/plugin.py @@ -344,13 +344,9 @@ def collect(self): options.update(comment_opts) options.setdefault('check', self.compare_outputs) name = 'Cell ' + str(cell_num) - # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent - if hasattr(IPyNbCell, "from_parent"): - yield IPyNbCell.from_parent( - self, name=name, cell_num=cell_num, cell=cell, options=options - ) - else: - yield IPyNbCell(name, self, cell_num, cell, options) + yield IPyNbCell.from_parent( + self, name=name, cell_num=cell_num, cell=cell, options=options + ) # Update 'code' cell count cell_num += 1 From 1d9f4db5f56ada7ac10fd948cfe275e47651c963 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:23:33 +0000 Subject: [PATCH 4/8] Try to fix readthedocs build --- readthedocs.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/readthedocs.yml b/readthedocs.yml index 2d7bf30..f4992b4 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -1,6 +1,13 @@ -type: sphinx -python: - version: 3.8 - pip_install: true +version: 2 + +build: + os: "ubuntu-22.04" + tools: + python: "mambaforge-23.11" + conda: - file: docs/environment.yml + environment: docs/environment.yml + +python: + install: + - method: pip From 8e3d157204c4156063a0758833e6a593998fce1a Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:24:56 +0000 Subject: [PATCH 5/8] Build docs with 'mambaforge-latest' Python --- readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs.yml b/readthedocs.yml index f4992b4..6dbda31 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -3,7 +3,7 @@ version: 2 build: os: "ubuntu-22.04" tools: - python: "mambaforge-23.11" + python: "mambaforge-latest" conda: environment: docs/environment.yml From ba129a1dcbe5e5d325878434f732a15ed842bce3 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:25:52 +0000 Subject: [PATCH 6/8] RTD needs the path to pip install --- readthedocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/readthedocs.yml b/readthedocs.yml index 6dbda31..d9f416b 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -11,3 +11,4 @@ conda: python: install: - method: pip + path: . From 8248f5895da6a5f2deae92bb9c4ac9639564e4c4 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:38:09 +0000 Subject: [PATCH 7/8] Drop testing on Python 3.6 --- appveyor.yml | 1 - setup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 84c587c..2deeda1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,6 @@ image: Visual Studio 2019 # environment variables environment: matrix: - - PYTHON: "C:\\Python36-x64" - PYTHON: "C:\\Python37-x64" - PYTHON: "C:\\Python38-x64" - PYTHON: "C:\\Python39-x64" diff --git a/setup.py b/setup.py index f20eb7b..8d97337 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ 'ipykernel', 'coverage', ], - python_requires='>=3.6, <4', + python_requires='>=3.7, <4', classifiers = [ 'Framework :: IPython', 'Framework :: Pytest', From 5f56faeb7bca2f315bc1be143d727e4e33d305ec Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 4 Mar 2024 10:38:59 +0000 Subject: [PATCH 8/8] Install sphinx-rtd-theme for building docs --- docs/environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/environment.yml b/docs/environment.yml index 654c741..908a360 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -7,3 +7,4 @@ dependencies: - matplotlib - sphinx - nbsphinx>=0.3.1 +- sphinx-rtd-theme