Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow an empty prefix in format dict #1238

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading