Skip to content

Commit

Permalink
Merge pull request #83 from MarcoGorelli/allow-only-values
Browse files Browse the repository at this point in the history
BUG allow only keys
  • Loading branch information
MarcoGorelli committed Jul 19, 2020
2 parents a4e4235 + 1b5a410 commit 3547fe9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions nbqa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,13 @@ def main(raw_args=None):
replace_magics.main(temp_python_file)
_create_blank_init_files(notebook, tmpdirname)

config = configparser.ConfigParser()
config = configparser.ConfigParser(allow_no_value=True)
config.read(".nbqa.ini")
if command in config.sections():
configs = [[f"--{key}", val] for key, val in config[command].items()]
configs = [
[f"--{key}", val] if val is not None else [f"--{key}"]
for key, val in config[command].items()
]
kwargs.extend([j for i in configs for j in i])
out, err, output_code = _run_command(
command, root_dir, tmpdirname, nb_to_py_mapping, kwargs
Expand Down
4 changes: 2 additions & 2 deletions tests/test_nbqa_ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_nbqa_ini_works(tmp_notebook_for_testing, capsys):
"""

with open(".nbqa.ini", "w") as f:
f.write("[flake8]\nignore=F401\nselect=E303\n")
f.write("[flake8]\nignore=F401\nselect=E303\nquiet\n")

# check diff
with open(tmp_notebook_for_testing, "r") as handle:
Expand All @@ -30,7 +30,7 @@ def test_nbqa_ini_works(tmp_notebook_for_testing, capsys):

# check out and err
out, err = capsys.readouterr()
expected_out = "tests/data/notebook_starting_with_md.ipynb:cell_3:0:1: E303 too many blank lines (3)\n"
expected_out = "tests/data/notebook_starting_with_md.ipynb\n"
expected_err = ""
assert sorted(out.splitlines()) == sorted(expected_out.splitlines())
assert sorted(err.splitlines()) == sorted(expected_err.splitlines())

0 comments on commit 3547fe9

Please sign in to comment.