Skip to content

Commit

Permalink
Don't override TOML paths with empty CLI paths.
Browse files Browse the repository at this point in the history
The paths CLI argument did not use the default=missing sentinel, and so
returned an empty list if no paths were given to the CLI. This meant any
paths configured in pyproject.toml were overridden with an empty list,
making the path= setting useless.

Adding the sentinel to the CLI fixes this behaviour. A regression test
is also added to make sure TOML paths are used if no CLI paths are
given.
  • Loading branch information
bcbnz committed Sep 8, 2020
1 parent 59bba3e commit 24f36f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ def test_config_merging_missing():
assert result["ignore_names"] == ["name1"]


def test_config_merging_toml_paths_only():
"""
If we have paths in the TOML but not on the CLI, the TOML paths should be
used.
"""
toml = StringIO(
dedent(
"""\
[tool.vulture]
paths = ["path1", "path2"]
"""
)
)
cliargs = [
"--exclude=test_*.py"
]
result = make_config(cliargs, toml)
assert result["paths"] == ["path1", "path2"]
assert result["exclude"] == ["test_*.py"]


def test_invalid_config_options_output():
"""
If the config file contains unknown options we want to abort.
Expand Down
1 change: 1 addition & 0 deletions vulture/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def csv(exclude):
"paths",
nargs="*",
metavar="PATH",
default=missing,
help="Paths may be Python files or directories. For each directory"
" Vulture analyzes all contained *.py files.",
)
Expand Down

0 comments on commit 24f36f1

Please sign in to comment.