Skip to content

Commit

Permalink
Determine the auto extension from jupytext.mainlanguage
Browse files Browse the repository at this point in the history
when available
  • Loading branch information
mwouts committed Nov 2, 2019
1 parent b007837 commit 47ed450
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
6 changes: 3 additions & 3 deletions jupytext/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 0 additions & 14 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

0 comments on commit 47ed450

Please sign in to comment.