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 61fda6a
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"]
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 61fda6a

Please sign in to comment.