From 61fda6a224c849a33f92823e8aed582badd4d64d Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Sat, 7 Dec 2024 15:02:48 +0000 Subject: [PATCH] Use metadata to determine the extension of notebooks coming from stdin --- src/jupytext/formats.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jupytext/formats.py b/src/jupytext/formats.py index efed28cd..54e7fd1d 100644 --- a/src/jupytext/formats.py +++ b/src/jupytext/formats.py @@ -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", {})