Skip to content

Commit

Permalink
Use metadata to determine the extension of notebooks coming from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Dec 7, 2024
1 parent dc909e6 commit 6e5ec72
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/jupytext/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,14 @@ def check_file_version(notebook, source_path, outputs_path):
if not insert_or_test_version_number():
return

_, ext = os.path.splitext(source_path)
assert not ext.endswith(".ipynb"), "source_path={} should be a text file".format(
source_path
)
if source_path == "-":
# https://github.com/mwouts/jupytext/issues/1282
ext = notebook.metadata["jupytext"]["text_representation"]["extension"]

Check warning on line 423 in src/jupytext/formats.py

View check run for this annotation

Codecov / codecov/patch

src/jupytext/formats.py#L423

Added line #L423 was not covered by tests
else:
_, ext = os.path.splitext(source_path)
assert not ext.endswith(
".ipynb"
), "source_path={} should be a text file".format(source_path)

version = (
notebook.metadata.get("jupytext", {})
Expand Down

0 comments on commit 6e5ec72

Please sign in to comment.