Skip to content

Commit d3f9e77

Browse files
committed
Don't import notebook when jupyter_server is available
1 parent 2ac808a commit d3f9e77

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Jupytext ChangeLog
77
**Changed**
88
- We have updated the pre-commit hooks. The code is now formatted using `ruff format`, and updated for Python 3.9+ using https://github.com/asottile/pyupgrade ([#1423](https://github.com/mwouts/jupytext/issues/1423))
99

10+
**Fixed**
11+
- We don't import `notebook` when `jupyter_server` is available ([#1436](https://github.com/mwouts/jupytext/issues/1436))
12+
1013

1114
1.17.3 (2025-08-28)
1215
-------------------

src/jupytext/async_contentsmanager.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
import nbformat
1919
from tornado.web import HTTPError
2020

21-
# import notebook.transutils before notebook.services.contents.filemanager #75
22-
try:
23-
import notebook.transutils # noqa
24-
except ImportError:
25-
pass
26-
2721
from .async_pairs import read_pair, write_pair
2822
from .config import (
2923
JUPYTEXT_CONFIG_FILES,
@@ -681,7 +675,13 @@ def _drop_formats_if_they_dont_match_path(self, path, fmt, formats):
681675

682676
AsyncTextFileContentsManager = build_async_jupytext_contents_manager_class(AsyncLargeFileManager)
683677
except ImportError:
684-
# If we can't find jupyter_server then we take it from notebook
678+
# If we can't find jupyter_server then we take the file manager from notebook
679+
# import notebook.transutils needs to happen before notebook.services.contents.filemanager, see #75
680+
try:
681+
import notebook.transutils # noqa
682+
except ImportError:
683+
pass
684+
685685
try:
686686
from notebook.services.contents.largefilemanager import AsyncLargeFileManager
687687

src/jupytext/sync_contentsmanager.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
import nbformat
2525
from tornado.web import HTTPError
2626

27-
# import notebook.transutils before notebook.services.contents.filemanager #75
28-
try:
29-
import notebook.transutils # noqa
30-
except ImportError:
31-
pass
32-
3327
from .sync_pairs import read_pair, write_pair
3428
from .config import (
3529
JUPYTEXT_CONFIG_FILES,
@@ -760,7 +754,13 @@ def _drop_formats_if_they_dont_match_path(self, path, fmt, formats):
760754
LargeFileManager
761755
)
762756
except ImportError:
763-
# If we can't find jupyter_server then we take it from notebook
757+
# If we can't find jupyter_server then we take the file manager from notebook
758+
# import notebook.transutils needs to happen before notebook.services.contents.filemanager, see #75
759+
try:
760+
import notebook.transutils # noqa
761+
except ImportError:
762+
pass
763+
764764
try:
765765
from notebook.services.contents.largefilemanager import LargeFileManager
766766

0 commit comments

Comments
 (0)