Skip to content

Commit

Permalink
Pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Jan 12, 2019
1 parent 253175f commit 34c824d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions jupytext/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def convert_notebook_files(nb_files, fmt, input_format=None, output=None, pre_co

for file in modified:
dest_file = file[:-len(input_ext)] + ext
nb = readf(file)
writef(nb, dest_file, format_name=format_name)
notebook = readf(file)
writef(notebook, dest_file, format_name=format_name)
system('git', 'add', dest_file)

for file in deleted:
Expand Down
17 changes: 9 additions & 8 deletions jupytext/contentsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ def kernelspec_from_language(language):


def jupytext_formats_from_metadata(metadata, ext):
"""Are the paired formats stored in the metadata in the text representation?"""
if ext == '.ipynb':
return True
else:
notebook_metadata_filter = metadata_filter_as_dict(
metadata.get('jupytext', {}).get('metadata_filter', {}).get('notebook', ''))
if 'jupytext' in notebook_metadata_filter.get('additional', []):
return True
excluded = notebook_metadata_filter.get('excluded', [])
if 'jupytext' in excluded or excluded == 'all':
return False

notebook_metadata_filter = metadata_filter_as_dict(
metadata.get('jupytext', {}).get('metadata_filter', {}).get('notebook', ''))
if 'jupytext' in notebook_metadata_filter.get('additional', []):
return True
excluded = notebook_metadata_filter.get('excluded', [])
if 'jupytext' in excluded or excluded == 'all':
return False
return True


def _jupytext_writes(ext, format_name):
Expand Down
3 changes: 1 addition & 2 deletions jupytext/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ def guess_format(text, ext):
if double_percent_count >= 1:
if magic_command_count:
return 'hydrogen'
else:
return 'percent'
return 'percent'

if twenty_hash_count >= 2:
return 'sphinx'
Expand Down
3 changes: 1 addition & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ def test_combine_lower_version_raises(tmpdir):
writef(nb, tmp_ipynb)

with pytest.raises(SystemExit):
with mock.patch('jupytext.header.INSERT_AND_CHECK_VERSION_NUMBER',
True):
with mock.patch('jupytext.header.INSERT_AND_CHECK_VERSION_NUMBER', True):
jupytext(args=[tmp_nbpy, '--to', 'ipynb', '--update'])


Expand Down

0 comments on commit 34c824d

Please sign in to comment.