From 47ed450cf1c0233f845102502b4ecd1a98954c97 Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Thu, 31 Oct 2019 00:21:05 +0100 Subject: [PATCH] Determine the auto extension from jupytext.mainlanguage when available --- jupytext/formats.py | 6 +++--- tests/test_cli.py | 14 -------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/jupytext/formats.py b/jupytext/formats.py index f28494ce4..7e0c09b2c 100644 --- a/jupytext/formats.py +++ b/jupytext/formats.py @@ -567,10 +567,10 @@ def auto_ext_from_metadata(metadata): auto_ext = metadata.get('language_info', {}).get('file_extension') if auto_ext is None: - kernel_language = metadata.get('kernelspec', {}).get('language') - if kernel_language: + language = metadata.get('kernelspec', {}).get('language') or metadata.get('jupytext', {}).get('main_language') + if language: for ext in _SCRIPT_EXTENSIONS: - if same_language(kernel_language, _SCRIPT_EXTENSIONS[ext]['language']): + if same_language(language, _SCRIPT_EXTENSIONS[ext]['language']): auto_ext = ext break diff --git a/tests/test_cli.py b/tests/test_cli.py index c2052b47b..c2440aa73 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -990,17 +990,3 @@ def test_339_require_to(tmpdir): with pytest.raises(ValueError, match='--to'): jupytext([tmp_py, '--test-strict']) - - -@requires_black -def test_detailed_message_missing_language_info(tmpdir): - text = """```python -1 + 1 -``` -""" - tmp_md = str(tmpdir.join('test.md')) - with open(tmp_md, 'w') as fp: - fp.write(text) - - with pytest.raises(ValueError, match='--pipe-fmt'): - jupytext([tmp_md, '--pipe', 'black'])