Skip to content

Commit

Permalink
Allow an empty prefix in format dict
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Jun 30, 2024
1 parent 29a979f commit 840a49b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/jupytext/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 840a49b

Please sign in to comment.