Repository: mwouts/jupytext

Issue:
Jupytext --to script uses the same destination extension for all the notebooks
Running `jupytext --to script NotebookExamples\*\*\*.ipynb` on [dotnet\interactive](https://github.com/dotnet/interactive/) only produces `.cs` files, when we would have expected `.cs`, `.fs` and `.ps1` files.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/mwouts/jupytext/pull/430?src=pr&el=h1) Report
> Merging [#430](https://codecov.io/gh/mwouts/jupytext/pull/430?src=pr&el=desc) into [master](https://codecov.io/gh/mwouts/jupytext/commit/0dec43d03be1144f042d28cb8f91ebe2378669d8?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/mwouts/jupytext/pull/430/graphs/tree.svg?width=650&token=a1pNjsiILi&height=150&src=pr)](https://codecov.io/gh/mwouts/jupytext/pull/430?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #430      +/-   ##
==========================================
+ Coverage   98.94%   98.94%   +<.01%     
==========================================
  Files          75       75              
  Lines        7645     7646       +1     
==========================================
+ Hits         7564     7565       +1     
  Misses         81       81
```


| [Impacted Files](https://codecov.io/gh/mwouts/jupytext/pull/430?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [jupytext/cli.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-anVweXRleHQvY2xpLnB5) | `95.62% <100%> (ø)` | :arrow_up: |
| [tests/test\_mirror.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9taXJyb3IucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [jupytext/version.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-anVweXRleHQvdmVyc2lvbi5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [jupytext/formats.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-anVweXRleHQvZm9ybWF0cy5weQ==) | `98.67% <100%> (ø)` | :arrow_up: |
| [tests/test\_pep8.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9wZXA4LnB5) | `98.38% <0%> (ø)` | :arrow_up: |
| [tests/test\_cli.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9jbGkucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [tests/test\_black.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9ibGFjay5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [tests/test\_active\_cells.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9hY3RpdmVfY2VsbHMucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [tests/test\_knitr\_spin.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9rbml0cl9zcGluLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [tests/test\_compare.py](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9jb21wYXJlLnB5) | `100% <0%> (ø)` | :arrow_up: |
| ... and [21 more](https://codecov.io/gh/mwouts/jupytext/pull/430/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/mwouts/jupytext/pull/430?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mwouts/jupytext/pull/430?src=pr&el=footer). Last update [0dec43d...6345de8](https://codecov.io/gh/mwouts/jupytext/pull/430?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/jupytext/cli.py b/jupytext/cli.py
index 2b250fe..dff62c1 100644
--- a/jupytext/cli.py
+++ b/jupytext/cli.py
@@ -315,7 +315,7 @@ def jupytext_single_file(nb_file, args, log):
     # Compute actual extension when using script/auto, and update nb_dest if necessary
     dest_fmt = args.to
     if dest_fmt and dest_fmt['extension'] == '.auto':
-        check_auto_ext(dest_fmt, notebook.metadata, '--to')
+        dest_fmt = check_auto_ext(dest_fmt, notebook.metadata, '--to')
         if not args.output and nb_file != '-':
             nb_dest = full_path(base_path(nb_file, args.input_format), dest_fmt)
 
@@ -625,7 +625,7 @@ def pipe_notebook(notebook, command, fmt='py:percent', update=True, prefix=None)
         command = command + ' {}'
 
     fmt = long_form_one_format(fmt, notebook.metadata, auto_ext_requires_language_info=False)
-    check_auto_ext(fmt, notebook.metadata, '--pipe-fmt')
+    fmt = check_auto_ext(fmt, notebook.metadata, '--pipe-fmt')
     text = writes(notebook, fmt)
 
     command = command.split(' ')
diff --git a/jupytext/formats.py b/jupytext/formats.py
index dcd5e4d..3ad1ab5 100644
--- a/jupytext/formats.py
+++ b/jupytext/formats.py
@@ -587,14 +587,15 @@ def auto_ext_from_metadata(metadata):
 
 
 def check_auto_ext(fmt, metadata, option):
-    """Raise a ValueError when the .auto extension cannot be determined"""
+    """Replace the auto extension with the actual file extension, and raise a ValueError if it cannot be determined"""
     if fmt['extension'] != '.auto':
-        return
+        return fmt
 
     auto_ext = auto_ext_from_metadata(metadata)
     if auto_ext:
+        fmt = fmt.copy()
         fmt['extension'] = auto_ext
-        return
+        return fmt
 
     raise ValueError("The notebook does not have a 'language_info' metadata. "
                      "Please replace 'auto' with the actual language extension in the {} option (currently {})."
diff --git a/jupytext/version.py b/jupytext/version.py
index 6b2562e..2857452 100644
--- a/jupytext/version.py
+++ b/jupytext/version.py
@@ -1,3 +1,3 @@
 """Jupytext's version number"""
 
-__version__ = '1.3.3'
+__version__ = '1.3.3+dev'


Test patch:
diff --git a/tests/test_mirror.py b/tests/test_mirror.py
index 8143409..ddacf0c 100644
--- a/tests/test_mirror.py
+++ b/tests/test_mirror.py
@@ -35,7 +35,7 @@ def assert_conversion_same_as_mirror(nb_file, fmt, mirror_name, compare_notebook
     file_name, org_ext = os.path.splitext(basename)
     fmt = long_form_one_format(fmt)
     notebook = jupytext.read(nb_file, fmt=fmt)
-    check_auto_ext(fmt, notebook.metadata, '')
+    fmt = check_auto_ext(fmt, notebook.metadata, '')
     ext = fmt['extension']
     mirror_file = os.path.join(dirname, '..', 'mirror', mirror_name, full_path(file_name, fmt))