From ce85355ace12ee22a4b59045f7eb794f7cdf9b5b Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Nov 2025 14:31:09 +0000 Subject: [PATCH 1/3] Set Jupyter platform directories environment variable to avoid DeprecationWarning --- tests/test_tutorials.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_tutorials.py b/tests/test_tutorials.py index c4d481b12..65c141840 100644 --- a/tests/test_tutorials.py +++ b/tests/test_tutorials.py @@ -1,3 +1,9 @@ +import os + +# Ensure Jupyter uses the new platformdirs paths to avoid DeprecationWarning +# This will become the default in `jupyter_core` v6 +os.environ.setdefault("JUPYTER_PLATFORM_DIRS", "1") + import contextlib from pathlib import Path From 8970d9b5f1579d09c5120b97cb475075ff10b204 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Nov 2025 14:39:37 +0000 Subject: [PATCH 2/3] flake8 --- tests/test_tutorials.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_tutorials.py b/tests/test_tutorials.py index 65c141840..7c8034195 100644 --- a/tests/test_tutorials.py +++ b/tests/test_tutorials.py @@ -1,10 +1,5 @@ -import os - -# Ensure Jupyter uses the new platformdirs paths to avoid DeprecationWarning -# This will become the default in `jupyter_core` v6 -os.environ.setdefault("JUPYTER_PLATFORM_DIRS", "1") - import contextlib +import os from pathlib import Path import nbformat @@ -12,6 +7,10 @@ from nbclient import NotebookClient from nbclient.exceptions import CellExecutionError +# Ensure Jupyter uses the new platformdirs paths to avoid DeprecationWarning +# This will become the default in `jupyter_core` v6 +os.environ.setdefault("JUPYTER_PLATFORM_DIRS", "1") + def _find_tutorial_notebooks(): """Return a sorted list of notebook Paths under doc/tutorials. From 35cc540eb71ec4c6e2fc5772de2ab66962477b08 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 19 Nov 2025 14:43:22 +0000 Subject: [PATCH 3/3] ignore flake8 for nbclient imports so os.environ.setdefault("JUPYTER_PLATFORM_DIRS", "1") can be run before importing jupyter paths. --- tests/test_tutorials.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_tutorials.py b/tests/test_tutorials.py index 7c8034195..4ba936a55 100644 --- a/tests/test_tutorials.py +++ b/tests/test_tutorials.py @@ -4,13 +4,14 @@ import nbformat import pytest -from nbclient import NotebookClient -from nbclient.exceptions import CellExecutionError # Ensure Jupyter uses the new platformdirs paths to avoid DeprecationWarning # This will become the default in `jupyter_core` v6 os.environ.setdefault("JUPYTER_PLATFORM_DIRS", "1") +from nbclient import NotebookClient # noqa: E402 +from nbclient.exceptions import CellExecutionError # noqa: E402 + def _find_tutorial_notebooks(): """Return a sorted list of notebook Paths under doc/tutorials.