From 1eb17ac49fae2e562dcf3d6ef8544c57128d8588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Thu, 14 Sep 2023 10:28:31 -0400 Subject: [PATCH] Simplify NotebookNotary._data_dir_default The code for that function originally predates the introduction of the function `jupyter_core.paths.jupyter_data_dir` which can now be used to determine the Jupyter data directory instead of initializing an instance of JupyterApp just to figure its data directory. --- nbformat/sign.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/nbformat/sign.py b/nbformat/sign.py index 90ea140..0d10ed5 100644 --- a/nbformat/sign.py +++ b/nbformat/sign.py @@ -37,8 +37,9 @@ def convert_datetime(val): from base64 import encodebytes from jupyter_core.application import JupyterApp, base_flags +from jupyter_core.paths import jupyter_data_dir from traitlets import Any, Bool, Bytes, Callable, Enum, Instance, Integer, Unicode, default, observe -from traitlets.config import LoggingConfigurable, MultipleInstanceError +from traitlets.config import LoggingConfigurable from . import NO_CONVERT, __version__, read, reads @@ -341,17 +342,7 @@ class NotebookNotary(LoggingConfigurable): @default("data_dir") def _data_dir_default(self): - app = None - try: - if JupyterApp.initialized(): - app = JupyterApp.instance() - except MultipleInstanceError: - pass - if app is None: - # create an app, without the global instance - app = JupyterApp() - app.initialize(argv=[]) - return app.data_dir + return jupyter_data_dir() store_factory = Callable( help="""A callable returning the storage backend for notebook signatures.