diff --git a/jupyterlab/packages/jupyterlab-jupytext-extension/src/commands.ts b/jupyterlab/packages/jupyterlab-jupytext-extension/src/commands.ts index 7e49778e4..64781576c 100644 --- a/jupyterlab/packages/jupyterlab-jupytext-extension/src/commands.ts +++ b/jupyterlab/packages/jupyterlab-jupytext-extension/src/commands.ts @@ -68,9 +68,9 @@ function getSelectedFormats(notebookTracker: INotebookTracker): Array { if (languageInfo && languageInfo.file_extension) { const scriptExt = languageInfo.file_extension.substring(1); formats = formats.map((format) => { - // By default use light format + // By default use percent format if (format === scriptExt) { - return 'auto:light'; + return 'auto:percent'; } // Replace language specific extension with auto return format.replace(`${scriptExt}:`, 'auto:'); @@ -102,8 +102,8 @@ function getSelectedFormats(notebookTracker: INotebookTracker): Array { 'jupytext' ) as IJupytextSection; const formatName = jupytext - ? jupytext?.text_representation?.formatName || 'light' - : 'light'; + ? jupytext?.text_representation?.formatName || 'percent' + : 'percent'; formats.push(`auto:${formatName}`); } return formats; diff --git a/jupyterlab/packages/jupyterlab-jupytext-extension/src/tokens.ts b/jupyterlab/packages/jupyterlab-jupytext-extension/src/tokens.ts index 8dcaeef02..1d13bfc47 100644 --- a/jupyterlab/packages/jupyterlab-jupytext-extension/src/tokens.ts +++ b/jupyterlab/packages/jupyterlab-jupytext-extension/src/tokens.ts @@ -84,17 +84,6 @@ export const JUPYTEXT_PAIR_COMMANDS_FILETYPE_DATA = new Map< }, ], ], - [ - 'auto:light', - [ - { - fileExt: 'auto:light', - paletteLabel: 'Pair with light script', - caption: 'Pair Notebook with Light Format', - iconName: 'ui-components:text-editor', - }, - ], - ], [ 'auto:percent', [ @@ -107,12 +96,12 @@ export const JUPYTEXT_PAIR_COMMANDS_FILETYPE_DATA = new Map< ], ], [ - 'auto:hydrogen', + 'auto:light', [ { - fileExt: 'auto:hydrogen', - paletteLabel: 'Pair with hydrogen script', - caption: 'Pair Notebook with Hydrogen Format', + fileExt: 'auto:light', + paletteLabel: 'Pair with light script', + caption: 'Pair Notebook with Light Format', iconName: 'ui-components:text-editor', }, ], @@ -250,17 +239,6 @@ export const JUPYTEXT_CREATE_TEXT_NOTEBOOK_FILETYPE_DATA = new Map< string, IFileTypeData[] >([ - [ - 'auto:light', - [ - { - fileExt: 'auto:light', - paletteLabel: 'Light Format', - caption: 'Light Format', - launcherLabel: 'Light Format', - }, - ], - ], [ 'auto:percent', [ @@ -273,13 +251,13 @@ export const JUPYTEXT_CREATE_TEXT_NOTEBOOK_FILETYPE_DATA = new Map< ], ], [ - 'auto:hydrogen', + 'auto:light', [ { - fileExt: 'auto:hydrogen', - paletteLabel: 'Hydrogen Format', - caption: 'Hydrogen Format', - launcherLabel: 'Hydrogen Format', + fileExt: 'auto:light', + paletteLabel: 'Light Format', + caption: 'Light Format', + launcherLabel: 'Light Format', }, ], ], @@ -364,7 +342,6 @@ export const TEXT_NOTEBOOKS_LAUNCHER_ICONS = JUPYTEXT_FORMATS.filter( (format) => { return ![ 'ipynb', - 'auto:hydrogen', 'auto:nomarker', 'qmd', 'custom', diff --git a/jupyterlab/packages/jupyterlab-jupytext-extension/src/utils.ts b/jupyterlab/packages/jupyterlab-jupytext-extension/src/utils.ts index 859987d36..af5a24e52 100644 --- a/jupyterlab/packages/jupyterlab-jupytext-extension/src/utils.ts +++ b/jupyterlab/packages/jupyterlab-jupytext-extension/src/utils.ts @@ -163,7 +163,7 @@ export async function getAvailableCreateTextNotebookCommands( fileTypes.map((fileType: IFileTypeData) => { // If format is auto, we need to add all currently available kernels // For instance if there are Python and R kernels available, format - // auto:light will be replaced by py:light and R:light + // auto:percent will be replaced by py:percent and R:percent if (format.startsWith('auto')) { const formatType = format.split(':')[1]; let mapIndex = 0; diff --git a/src/jupytext/cli.py b/src/jupytext/cli.py index 6ce98a033..7e922ccf2 100644 --- a/src/jupytext/cli.py +++ b/src/jupytext/cli.py @@ -117,11 +117,10 @@ def parse_jupytext_args(args=None): } ) ) - + "The default format for scripts is the 'light' format, " - "which uses few cell markers (none when possible). " - "Alternatively, a format compatible with many editors is the " - "'percent' format, which uses '# %%%%' as cell markers. " - "The main formats (markdown, light, percent) preserve " + + "The default format for scripts is the 'percent' format, " + "which uses '# %%%%' as cell markers and is compatible with VS Code and PyCharm. " + "Alternatively, you can also use the 'light' format, which uses fewer cell markers. " + "The main formats (MyST Markdown, Markdown, percent, light) preserve " "notebooks and text documents in a roundtrip. Use the " "--test and and --test-strict commands to test the roundtrip on your files. " "Read more about the available formats at " diff --git a/src/jupytext/jupytext.py b/src/jupytext/jupytext.py index 780f412ae..a78700240 100644 --- a/src/jupytext/jupytext.py +++ b/src/jupytext/jupytext.py @@ -30,6 +30,7 @@ metadata_and_cell_to_header, ) from .languages import ( + _SCRIPT_EXTENSIONS, default_language_from_metadata_and_ext, set_main_and_cell_language, ) @@ -476,6 +477,11 @@ def writes(notebook, fmt, version=nbformat.NO_CONVERT, config=None, **kwargs): if not format_name: format_name = format_name_for_ext(metadata, ext, explicit_default=False) + # Since Jupytext==1.17, the default format for + # writing a notebook to a script is the percent format + if not format_name and "cell_markers" not in fmt and ext in _SCRIPT_EXTENSIONS: + format_name = "percent" + if format_name: fmt["format_name"] = format_name update_jupytext_formats_metadata(metadata, fmt) diff --git a/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.R b/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.R index 4f9368f05..a47f08aa7 100644 --- a/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.R +++ b/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.R @@ -1,12 +1,12 @@ -# --- -# jupyter: -# kernelspec: -# display_name: R -# language: R -# name: ir -# --- +#' --- +#' jupyter: +#' kernelspec: +#' display_name: R +#' language: R +#' name: ir +#' --- -# This notebook was created with IRKernel 0.8.12, and is not completely valid, as the code cell below contains an unexpected 'source' entry. This did cause https://github.com/mwouts/jupytext/issues/234. Note that the problem is solved when one upgrades to IRKernel 1.0.0. +#' This notebook was created with IRKernel 0.8.12, and is not completely valid, as the code cell below contains an unexpected 'source' entry. This did cause https://github.com/mwouts/jupytext/issues/234. Note that the problem is solved when one upgrades to IRKernel 1.0.0. library("ggplot2") ggplot(mtcars, aes(mpg)) + stat_ecdf() diff --git a/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.low.r b/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.low.r index 4f9368f05..a47f08aa7 100644 --- a/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.low.r +++ b/tests/data/notebooks/outputs/ipynb_to_spin/R notebook with invalid cell keys.low.r @@ -1,12 +1,12 @@ -# --- -# jupyter: -# kernelspec: -# display_name: R -# language: R -# name: ir -# --- +#' --- +#' jupyter: +#' kernelspec: +#' display_name: R +#' language: R +#' name: ir +#' --- -# This notebook was created with IRKernel 0.8.12, and is not completely valid, as the code cell below contains an unexpected 'source' entry. This did cause https://github.com/mwouts/jupytext/issues/234. Note that the problem is solved when one upgrades to IRKernel 1.0.0. +#' This notebook was created with IRKernel 0.8.12, and is not completely valid, as the code cell below contains an unexpected 'source' entry. This did cause https://github.com/mwouts/jupytext/issues/234. Note that the problem is solved when one upgrades to IRKernel 1.0.0. library("ggplot2") ggplot(mtcars, aes(mpg)) + stat_ecdf() diff --git a/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.R b/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.R index 8c887742e..30d996f3c 100644 --- a/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.R +++ b/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.R @@ -1,12 +1,12 @@ -# --- -# jupyter: -# kernelspec: -# display_name: R -# language: R -# name: ir -# --- - -# This is a jupyter notebook that uses the IR kernel. +#' --- +#' jupyter: +#' kernelspec: +#' display_name: R +#' language: R +#' name: ir +#' --- + +#' This is a jupyter notebook that uses the IR kernel. sum(1:10) diff --git a/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.low.r b/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.low.r index 8c887742e..30d996f3c 100644 --- a/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.low.r +++ b/tests/data/notebooks/outputs/ipynb_to_spin/ir_notebook.low.r @@ -1,12 +1,12 @@ -# --- -# jupyter: -# kernelspec: -# display_name: R -# language: R -# name: ir -# --- - -# This is a jupyter notebook that uses the IR kernel. +#' --- +#' jupyter: +#' kernelspec: +#' display_name: R +#' language: R +#' name: ir +#' --- + +#' This is a jupyter notebook that uses the IR kernel. sum(1:10) diff --git a/tests/external/pre_commit/test_pre_commit_mode.py b/tests/external/pre_commit/test_pre_commit_mode.py index 125775f9b..65b0b00fc 100644 --- a/tests/external/pre_commit/test_pre_commit_mode.py +++ b/tests/external/pre_commit/test_pre_commit_mode.py @@ -40,7 +40,7 @@ def test_ignore_unmatched_ignores(tmpdir, cwd_tmpdir): # Run jupytext status = jupytext( - ["--from", "ipynb", "--to", "py:light", "--pre-commit-mode", file] + ["--from", "ipynb", "--to", "py:percent", "--pre-commit-mode", file] ) assert status == 0 @@ -90,7 +90,7 @@ def test_alert_untracked_alerts_for_modified(tmpdir, cwd_tmpdir, tmp_repo, capsy # Run jupytext status = jupytext( - ["--from", "ipynb", "--to", "py:light", "--pre-commit-mode", "test.ipynb"] + ["--from", "ipynb", "--to", "py:percent", "--pre-commit-mode", "test.ipynb"] ) assert status == 1 diff --git a/tests/external/pre_commit/test_pre_commit_scripts.py b/tests/external/pre_commit/test_pre_commit_scripts.py index 885986db9..05b526ff8 100644 --- a/tests/external/pre_commit/test_pre_commit_scripts.py +++ b/tests/external/pre_commit/test_pre_commit_scripts.py @@ -43,7 +43,7 @@ def test_pre_commit_hook(tmpdir): git = git_in_tmpdir(tmpdir) hook = str(tmpdir.join(".git/hooks/pre-commit")) with open(hook, "w") as fp: - fp.write("#!/bin/sh\n" "jupytext --to py:light --pre-commit\n") + fp.write("#!/bin/sh\n" "jupytext --to py:percent --pre-commit\n") st = os.stat(hook) os.chmod(hook, st.st_mode | stat.S_IEXEC) @@ -148,7 +148,7 @@ def test_pre_commit_hook_in_subfolder(tmpdir): hook = str(tmpdir.join(".git/hooks/pre-commit")) with open(hook, "w") as fp: fp.write( - "#!/bin/sh\n" "jupytext --from ipynb --to python//py:light --pre-commit\n" + "#!/bin/sh\n" "jupytext --from ipynb --to python//py:percent --pre-commit\n" ) st = os.stat(hook) @@ -178,8 +178,8 @@ def test_pre_commit_hook_py_to_ipynb_and_md(tmpdir): with open(hook, "w") as fp: fp.write( "#!/bin/sh\n" - "jupytext --from py:light --to ipynb --pre-commit\n" - "jupytext --from py:light --to md --pre-commit\n" + "jupytext --from py:percent --to ipynb --pre-commit\n" + "jupytext --from py:percent --to md --pre-commit\n" ) st = os.stat(hook) diff --git a/tests/functional/cli/test_cli.py b/tests/functional/cli/test_cli.py index a3d229083..1dcde0c63 100644 --- a/tests/functional/cli/test_cli.py +++ b/tests/functional/cli/test_cli.py @@ -1262,7 +1262,7 @@ def test_jupytext_to_ipynb_does_not_update_timestamp_if_not_paired( assert "Updating the timestamp" not in capture.out -@pytest.mark.parametrize("formats", ["ipynb,py", "py:percent", "py", None]) +@pytest.mark.parametrize("formats", ["ipynb,py", "py:percent", "py:light", None]) def test_use_source_timestamp(tmpdir, cwd_tmpdir, python_notebook, capsys, formats): # Write a text notebook nb = python_notebook @@ -1302,7 +1302,7 @@ def test_use_source_timestamp(tmpdir, cwd_tmpdir, python_notebook, capsys, forma os.utime(test_py, (src_timestamp, src_timestamp)) # Then we can't open paired notebooks - if formats == "ipynb,py": + if formats == "ipynb,py:percent": from tornado.web import HTTPError with pytest.raises(HTTPError, match="is more recent than test.py"): diff --git a/tests/functional/others/test_active_cells.py b/tests/functional/others/test_active_cells.py index 1403caf3e..08ada1dd3 100644 --- a/tests/functional/others/test_active_cells.py +++ b/tests/functional/others/test_active_cells.py @@ -36,7 +36,7 @@ } ACTIVE_ALL = { - ".py": """# + active="ipynb,py,R,Rmd" + ".py": """# %% active="ipynb,py,R,Rmd" # This cell is active in all extensions """, ".Rmd": """```{python active="ipynb,py,R,Rmd"} @@ -47,7 +47,7 @@ # This cell is active in all extensions ``` """, - ".R": """# + active="ipynb,py,R,Rmd" + ".R": """# %% active="ipynb,py,R,Rmd" # This cell is active in all extensions """, ".ipynb": { @@ -75,7 +75,7 @@ def test_active_all(ext, no_jupytext_version_number): ACTIVE_IPYNB = { - ".py": """# + active="ipynb" + ".py": """# %% active="ipynb" # # This cell is active only in ipynb # %matplotlib inline """, @@ -89,7 +89,7 @@ def test_active_all(ext, no_jupytext_version_number): %matplotlib inline ``` """, - ".R": """# + active="ipynb" + ".R": """# %% active="ipynb" # # This cell is active only in ipynb # %matplotlib inline """, @@ -109,7 +109,7 @@ def test_active_ipynb(ext, no_jupytext_version_number): ACTIVE_IPYNB_RMD_USING_TAG = { - ".py": """# + tags=["active-ipynb-Rmd"] + ".py": """# %% tags=["active-ipynb-Rmd"] # # This cell is active only in ipynb and Rmd # %matplotlib inline """, @@ -123,7 +123,7 @@ def test_active_ipynb(ext, no_jupytext_version_number): %matplotlib inline ``` """, - ".R": """# + tags=["active-ipynb-Rmd"] + ".R": """# %% tags=["active-ipynb-Rmd"] # # This cell is active only in ipynb and Rmd # %matplotlib inline """, @@ -166,7 +166,7 @@ def test_active_ipynb_rspin(no_jupytext_version_number): ACTIVE_PY_IPYNB = { - ".py": """# + active="ipynb,py" + ".py": """# %% active="ipynb,py" # This cell is active in py and ipynb extensions """, ".Rmd": """```{python active="ipynb,py", eval=FALSE} @@ -177,7 +177,7 @@ def test_active_ipynb_rspin(no_jupytext_version_number): # This cell is active in py and ipynb extensions ``` """, - ".R": """# + active="ipynb,py" + ".R": """# %% active="ipynb,py" # # This cell is active in py and ipynb extensions """, ".ipynb": { @@ -196,14 +196,14 @@ def test_active_py_ipynb(ext, no_jupytext_version_number): ACTIVE_PY_R_IPYNB = { - ".py": """# + active="ipynb,py,R" + ".py": """# %% active="ipynb,py,R" # This cell is active in py, R and ipynb extensions """, ".Rmd": """```{python active="ipynb,py,R", eval=FALSE} # This cell is active in py, R and ipynb extensions ``` """, - ".R": """# + active="ipynb,py,R" + ".R": """# %% active="ipynb,py,R" # This cell is active in py, R and ipynb extensions """, ".ipynb": { @@ -222,14 +222,14 @@ def test_active_py_r_ipynb(ext, no_jupytext_version_number): ACTIVE_RMD = { - ".py": """# + active="Rmd" + ".py": """# %% active="Rmd" # # This cell is active in Rmd only """, ".Rmd": """```{python active="Rmd"} # This cell is active in Rmd only ``` """, - ".R": """# + active="Rmd" + ".R": """# %% active="Rmd" # # This cell is active in Rmd only """, ".ipynb": { @@ -246,14 +246,14 @@ def test_active_rmd(ext, no_jupytext_version_number): ACTIVE_NOT_INCLUDE_RMD = { - ".py": """# + tags=["remove_cell"] active="Rmd" + ".py": """# %% tags=["remove_cell"] active="Rmd" # # This cell is active in Rmd only """, ".Rmd": """```{python include=FALSE, active="Rmd"} # This cell is active in Rmd only ``` """, - ".R": """# + tags=["remove_cell"] active="Rmd" + ".R": """# %% tags=["remove_cell"] active="Rmd" # # This cell is active in Rmd only """, ".ipynb": { @@ -346,13 +346,13 @@ def test_comments_plus_code_work_in_active_cells_from_py_light_1131( def test_active_cells_from_py_light( - text="""# + active="py" + text="""# %% active="py" print('should only be displayed in py file') -# + tags=["active-py"] +# %% tags=["active-py"] print('should only be displayed in py file') -# + active="ipynb" +# %% active="ipynb" # print('only in jupyter') """, ): diff --git a/tests/functional/round_trip/test_mirror.py b/tests/functional/round_trip/test_mirror.py index 8a04f75be..695b212cc 100644 --- a/tests/functional/round_trip/test_mirror.py +++ b/tests/functional/round_trip/test_mirror.py @@ -42,7 +42,7 @@ def test_ipynb_to_hydrogen(ipynb_file, no_jupytext_version_number): def test_ipynb_to_light(ipynb_to_light, no_jupytext_version_number): - assert_conversion_same_as_mirror(ipynb_to_light, "auto", "ipynb_to_script") + assert_conversion_same_as_mirror(ipynb_to_light, "auto:light", "ipynb_to_script") def test_ipynb_to_md(ipynb_file, no_jupytext_version_number): @@ -70,7 +70,7 @@ def test_ipynb_to_myst(ipynb_file, no_jupytext_version_number): def test_script_to_ipynb(script_to_ipynb, no_jupytext_version_number): - assert_conversion_same_as_mirror(script_to_ipynb, "ipynb", "script_to_ipynb") + assert_conversion_same_as_mirror(script_to_ipynb, "ipynb:light", "script_to_ipynb") def test_percent_to_ipynb(percent_file, no_jupytext_version_number): @@ -129,8 +129,8 @@ def test_ipynb_to_python_vscode(ipynb_py_file, no_jupytext_version_number): ) -def test_ipynb_to_r(ipynb_R_file, no_jupytext_version_number): - assert_conversion_same_as_mirror(ipynb_R_file, ".low.r", "ipynb_to_script") +def test_ipynb_to_r_light(ipynb_R_file, no_jupytext_version_number): + assert_conversion_same_as_mirror(ipynb_R_file, ".low.r:light", "ipynb_to_script") def test_ipynb_to_r_percent(ipynb_R_file, no_jupytext_version_number): @@ -138,16 +138,20 @@ def test_ipynb_to_r_percent(ipynb_R_file, no_jupytext_version_number): def test_ipynb_to_R_spin(ipynb_R_file, no_jupytext_version_number): - assert_conversion_same_as_mirror(ipynb_R_file, "R", "ipynb_to_spin") + assert_conversion_same_as_mirror(ipynb_R_file, "R:spin", "ipynb_to_spin") def test_ipynb_to_r_spin(ipynb_R_file, no_jupytext_version_number): - assert_conversion_same_as_mirror(ipynb_R_file, ".low.r", "ipynb_to_spin") + assert_conversion_same_as_mirror(ipynb_R_file, ".low.r:spin", "ipynb_to_spin") @pytest.mark.parametrize("extension", ("ss", "scm")) -def test_ipynb_to_scheme(ipynb_scheme_file, extension, no_jupytext_version_number): - assert_conversion_same_as_mirror(ipynb_scheme_file, extension, "ipynb_to_script") +def test_ipynb_to_scheme_light( + ipynb_scheme_file, extension, no_jupytext_version_number +): + assert_conversion_same_as_mirror( + ipynb_scheme_file, f"{extension}:light", "ipynb_to_script" + ) @pytest.mark.parametrize("extension", ("ss", "scm")) diff --git a/tests/functional/simple_notebooks/test_read_simple_csharp.py b/tests/functional/simple_notebooks/test_read_simple_csharp.py index 17d2b813b..d4df68614 100644 --- a/tests/functional/simple_notebooks/test_read_simple_csharp.py +++ b/tests/functional/simple_notebooks/test_read_simple_csharp.py @@ -23,7 +23,7 @@ def test_simple_cs(lang): cs = jupytext.writes(nb, "cs") assert source in cs if lang != "csharp": - assert cs.startswith(f'// + language="{lang}"') + assert cs.startswith(f'// %% language="{lang}"') md2 = jupytext.writes(nb, "md") compare(md2, md) diff --git a/tests/functional/simple_notebooks/test_read_simple_matlab.py b/tests/functional/simple_notebooks/test_read_simple_matlab.py index 2676f7d28..fee8ac580 100644 --- a/tests/functional/simple_notebooks/test_read_simple_matlab.py +++ b/tests/functional/simple_notebooks/test_read_simple_matlab.py @@ -10,7 +10,7 @@ def test_hide_code_tag( metadata={"jupytext": {"main_language": "matlab"}}, cells=[new_code_cell("1 + 1", metadata={"tags": ["hide_code"]})], ), - text="""% + tags=["hide_code"] + text="""% %% tags=["hide_code"] 1 + 1 """, ): diff --git a/tests/functional/simple_notebooks/test_read_simple_percent.py b/tests/functional/simple_notebooks/test_read_simple_percent.py index eea25a5cd..471c8a3f1 100644 --- a/tests/functional/simple_notebooks/test_read_simple_percent.py +++ b/tests/functional/simple_notebooks/test_read_simple_percent.py @@ -456,7 +456,10 @@ def test_cell_markers_in_contents_manager_does_not_impact_light_format(tmpdir): nb = new_notebook( cells=[new_code_cell("1 + 1"), new_markdown_cell("a\nlong\ncell")], metadata={ - "jupytext": {"formats": "ipynb,py", "notebook_metadata_filter": "-all"} + "jupytext": { + "formats": "ipynb,py:light", + "notebook_metadata_filter": "-all", + } }, ) with pytest.warns(UserWarning, match="Ignored cell markers"): diff --git a/tests/functional/simple_notebooks/test_read_simple_python.py b/tests/functional/simple_notebooks/test_read_simple_python.py index efe0699d2..01568b3ea 100644 --- a/tests/functional/simple_notebooks/test_read_simple_python.py +++ b/tests/functional/simple_notebooks/test_read_simple_python.py @@ -978,7 +978,6 @@ def test_round_trip_python_with_js_cell_no_cell_metadata(): def test_raw_with_metadata( - no_jupytext_version_number, text="""# + key="value" active="" # Raw cell # # Commented line @@ -989,7 +988,7 @@ def test_raw_with_metadata( ): nb2 = jupytext.reads(text, "py") compare_notebooks(nb2, notebook) - text2 = jupytext.writes(notebook, "py") + text2 = jupytext.writes(nb2, "py") compare(text2, text) @@ -1008,7 +1007,6 @@ def test_raw_with_metadata_2( def test_markdown_with_metadata( - no_jupytext_version_number, text="""# + [markdown] key="value" # Markdown cell """, @@ -1018,7 +1016,7 @@ def test_markdown_with_metadata( ): nb2 = jupytext.reads(text, "py") compare_notebooks(nb2, notebook) - text2 = jupytext.writes(notebook, "py") + text2 = jupytext.writes(nb2, "py") compare(text2, text) @@ -1139,7 +1137,7 @@ def test_indented_bash_command( """, ): """Reproduces https://github.com/mwouts/jupytext/issues/437""" - py = jupytext.writes(nb, "py") + py = jupytext.writes(nb, "py:light") compare(py, text) nb2 = jupytext.reads(py, "py") compare_notebooks(nb2, nb) diff --git a/tests/integration/contents_manager/test_contentsmanager.py b/tests/integration/contents_manager/test_contentsmanager.py index 355a67d23..3dac50afe 100644 --- a/tests/integration/contents_manager/test_contentsmanager.py +++ b/tests/integration/contents_manager/test_contentsmanager.py @@ -495,10 +495,10 @@ def test_outdated_text_notebook_diff_is_shown(tmpdir, python_notebook): """Differences (jupytext --diff notebook.py notebook.ipynb) are: --- notebook.py +++ notebook.ipynb -@@ -12,5 +12,5 @@ - # name: python_kernel +@@ -13,5 +13,5 @@ # --- + # %%%% [markdown] -# Text version 1.0 +# Text version 2.0 @@ -1373,7 +1373,7 @@ def test_vim_folding_markers(tmpdir): # Default Vim folding markers cm.cell_markers = "{{{,}}}" - cm.formats = "ipynb,py" + cm.formats = "ipynb,py:light" nb = new_notebook( cells=[ @@ -1429,7 +1429,7 @@ def test_vscode_pycharm_folding_markers(tmpdir): # Default VScode/PyCharm folding markers cm.cell_markers = "region,endregion" - cm.formats = "ipynb,py" + cm.formats = "ipynb,py:light" nb = new_notebook( cells=[ diff --git a/tests/unit/test_escape_magics.py b/tests/unit/test_escape_magics.py index e4c6585d3..8abeb9c59 100644 --- a/tests/unit/test_escape_magics.py +++ b/tests/unit/test_escape_magics.py @@ -238,7 +238,7 @@ def g(x): ] ) - text = jupytext.writes(nb, "py") + text = jupytext.writes(nb, "py:light") compare( text, """# + @@ -263,7 +263,7 @@ def test_configure_magic(no_jupytext_version_number): ] ) - text = jupytext.writes(nb, "py") + text = jupytext.writes(nb, "py:light") compare( text, """# %%configure -f \\ diff --git a/tests/unit/test_header.py b/tests/unit/test_header.py index dbe47934d..dd84eefce 100644 --- a/tests/unit/test_header.py +++ b/tests/unit/test_header.py @@ -131,13 +131,19 @@ def test_multiline_metadata( "multiline": """A multiline string with a blank line""", - "jupytext": {"notebook_metadata_filter": "all"}, + "jupytext": { + "notebook_metadata_filter": "all", + "text_representation": {"extension": ".md", "format_name": "markdown"}, + }, } ), markdown="""--- jupyter: jupytext: notebook_metadata_filter: all + text_representation: + extension: .md + format_name: markdown multiline: 'A multiline string