Skip to content

Commit

Permalink
Merge pull request #31 from cfournie/exclude
Browse files Browse the repository at this point in the history
Fix exclude
  • Loading branch information
cfournie committed Feb 5, 2017
2 parents 00ecbd9 + 3ab340b commit f4565e8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Check for unused requirements but exclude test files using:

.. code:: bash
$ important -v --requirements requirements.txt **/test_*.py .
$ important -v --requirements requirements.txt --exclude **/test_*.py .
Parsed 52 imports in 8 files
Error: Unused requirements or violated constraints found
caniusepython3 (unused requirement)
Expand Down Expand Up @@ -88,7 +88,6 @@ Alternatively, you can configure important using a ``setup.cfg`` file in the cur
flake8
exclude=
.git
.cache
sourcecode=.
Then run using:
Expand Down
9 changes: 5 additions & 4 deletions important/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ def split(key_value):
type=click.Path(exists=True, file_okay=True, dir_okay=False,
writable=False, readable=True,
resolve_path=True))
@click.argument('exclude', nargs=-1,
type=click.Path(exists=True, file_okay=True, dir_okay=True,
writable=False, readable=True,
resolve_path=True))
@click.option('--exclude', '-e', multiple=True,
help="Python files or directories to exclude from analysis",
type=click.Path(exists=True, file_okay=True, dir_okay=True,
writable=False, readable=True,
resolve_path=True))
@click.argument('sourcecode', nargs=1,
type=click.Path(exists=True, file_okay=True, dir_okay=True,
writable=False, readable=True,
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ ignore=
flake8
exclude=
.git
.cache
sourcecode=.
7 changes: 4 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def run_check(tmpdir, encoding, requirements=None, constraints=None,
runner_args.append('-' + verbose * 'v')
setup_cfg_args.append('-' + verbose * 'v')
if exclude:
runner_args.extend(exclude)
for excluded_path in exclude:
runner_args.extend(['--exclude', excluded_path])
setup_cfg['exclude'] = exclude
runner_args.append(sourcecode)
setup_cfg['sourcecode'] = sourcecode
Expand Down Expand Up @@ -496,7 +497,7 @@ def test_insufficient_args(python_source_file, setupcfg, tmpdir, encoding):
)
assert result.exit_code == 2
assert result.output == ('''
Usage: check [OPTIONS] [EXCLUDE]... SOURCECODE
Usage: check [OPTIONS] SOURCECODE
Error: Invalid value: no checks performed; supply either --requirements '''
'''or --contraints
Expand All @@ -519,7 +520,7 @@ def test_socket(requirements_file, constraints_file, encoding):
)
assert result.exit_code == 2
assert result.output == ('''
Usage: check [OPTIONS] [EXCLUDE]... SOURCECODE
Usage: check [OPTIONS] SOURCECODE
Error: Invalid value: could not parse SOURCECODE '%s'; path is either not a '''
'''file or not a directory
Expand Down

0 comments on commit f4565e8

Please sign in to comment.