From 62d83db28bdb169c6758533ed4f9aa937940a54b Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Sun, 3 Jul 2022 00:31:22 +0200 Subject: [PATCH] Fix #969 --- docs/CHANGELOG.md | 5 ++++- jupytext/cli.py | 27 ++++++++++++--------------- tests/conftest.py | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e76980f04..7dcc86e32 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,12 +1,15 @@ Jupytext ChangeLog ================== -1.13.9 (2022-06-30) +1.13.9 (2022-07-??) ------------------- **Changed** - Hidden configuration files like `.jupytext.toml` or `.jupytext.py` are now ignored by Jupytext's contents manager when `allow_hidden=False` (that option was introduced in `jupyter_server==2.0.0a1`) ([#964](https://github.com/mwouts/jupytext/issues/964)). +**Changed** +- `jupytext --set-formats ipynb,py test.py` will not override `test.ipynb` if the file exists already ([#969](https://github.com/mwouts/jupytext/issues/969)). + 1.13.8 (2022-04-04) ------------------- diff --git a/jupytext/cli.py b/jupytext/cli.py index f710a363b..dcb1b9630 100644 --- a/jupytext/cli.py +++ b/jupytext/cli.py @@ -629,27 +629,24 @@ def jupytext_single_file(nb_file, args, log): recursive_update(notebook.metadata, args.update_metadata) - # Read paired notebooks, except if the pair is being created + # Read paired notebooks nb_files = [nb_file, nb_dest] if args.sync: formats = notebook_formats( notebook, config, nb_file, fallback_on_current_fmt=False ) set_prefix_and_suffix(fmt, formats, nb_file) - if args.set_formats is None: - try: - notebook, inputs_nb_file, outputs_nb_file = load_paired_notebook( - notebook, fmt, config, formats, nb_file, log, args.pre_commit_mode - ) - nb_files = [inputs_nb_file, outputs_nb_file] - except NotAPairedNotebook as err: - sys.stderr.write("[jupytext] Warning: " + str(err) + "\n") - return 0 - except InconsistentVersions as err: - sys.stderr.write("[jupytext] Error: " + str(err) + "\n") - return 1 - else: - nb_files = [nb_file] + try: + notebook, inputs_nb_file, outputs_nb_file = load_paired_notebook( + notebook, fmt, config, formats, nb_file, log, args.pre_commit_mode + ) + nb_files = [inputs_nb_file, outputs_nb_file] + except NotAPairedNotebook as err: + sys.stderr.write("[jupytext] Warning: " + str(err) + "\n") + return 0 + except InconsistentVersions as err: + sys.stderr.write("[jupytext] Error: " + str(err) + "\n") + return 1 # II. ### Apply commands onto the notebook ### # Pipe the notebook into the desired commands diff --git a/tests/conftest.py b/tests/conftest.py index d35315e15..7e1eada9d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -76,7 +76,7 @@ def notebook_with_outputs(): execution_count=1, outputs=[ new_output( - data={"text/plain": ["2"]}, + data={"text/plain": "2"}, execution_count=1, output_type="execute_result", )