From 840a49bce94e738d9a4f5cf2fa59d681dcc4ac5f Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Sun, 2 Jun 2024 18:11:44 +0100 Subject: [PATCH] Allow an empty prefix in format dict --- CHANGELOG.md | 2 ++ src/jupytext/config.py | 4 +++- tests/functional/config/test_config.py | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a577ff6a1..09e9b5694 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,11 @@ Jupytext ChangeLog **Fixed** - We have fixed a typo when `build_jupytext_contents_manager_class` can't be imported ([#1162](https://github.com/mwouts/jupytext/issues/1162)) +- Some dependencies of the JupyterLab extensions were updated ([#1243](https://github.com/mwouts/jupytext/issues/1243), [#1245](https://github.com/mwouts/jupytext/issues/1245)) **Added** - Added support for Lua notebooks ([#1252](https://github.com/mwouts/jupytext/pull/1252)) - thanks to [erentar](https://github.com/erentar) for this contribution +- Empty prefixes are now allowed in Jupytext format when specified as a dictionary ([#1144](https://github.com/mwouts/jupytext/issues/1144)) 1.16.2 (2024-05-05) diff --git a/src/jupytext/config.py b/src/jupytext/config.py index 81bdfe38f..3b0269b04 100644 --- a/src/jupytext/config.py +++ b/src/jupytext/config.py @@ -398,7 +398,9 @@ def load_jupytext_configuration_file(config_file, stream=None): # formats can be a dict prefix => format if isinstance(config.formats, dict): config.formats = [ - (prefix[:-1] if prefix.endswith("/") else prefix) + "///" + fmt + fmt + if not prefix + else (prefix[:-1] if prefix.endswith("/") else prefix) + "///" + fmt for prefix, fmt in config.formats.items() ] config.formats = short_form_multiple_formats(config.formats) diff --git a/tests/functional/config/test_config.py b/tests/functional/config/test_config.py index 240ba4bc3..8c705622d 100644 --- a/tests/functional/config/test_config.py +++ b/tests/functional/config/test_config.py @@ -158,6 +158,15 @@ def test_load_jupytext_configuration_file(tmpdir, config_file): """, "notebooks///ipynb,scripts///py:percent", ), + ( + """# Pair local notebooks to scripts in 'notebooks_py' and md files in 'notebooks_md' +[formats] +"" = "ipynb" +"notebooks_py" = "py:percent" +"notebooks_md" = "md:myst" +""", + "ipynb,notebooks_py///py:percent,notebooks_md///md:myst", + ), ], ) def test_jupytext_formats(tmpdir, content_toml, formats_short_form):