Skip to content

Commit

Permalink
ADD CLI option for --install-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mknorps committed Jul 28, 2023
1 parent da47cba commit 4644fcf
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ Here is a complete list of configuration directives we support:
declared dependencies. Must be one of `"requirements.txt"`, `"setup.py"`,
`"setup.cfg"`, `"pyproject.toml"`, or leave it unset (i.e. the default) for
auto-detection (based on filename).
- `install-deps`: Install Python dependencies gathered with FawltyDeps to
a temporary virtual environment. Dependencies will be installed from PyPI.
- `verbosity`: An integer controlling the default log level of FawltyDeps:
- `-2`: Only `CRITICAL`-level log messages are shown.
- `-1`: `ERROR`-level log messages and above are shown.
Expand Down
9 changes: 9 additions & 0 deletions fawltydeps/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ def populate_parser_paths_options(parser: argparse._ActionsContainer) -> None:
" Python environment where FawltyDeps is installed."
),
)
parser.add_argument(
"--install-deps",
dest="install_deps",
action="store_true",
help=(
"Allow FawltyDeps to `pip install` declared dependencies into a"
" separate temporary virtualenv to discover the imports they expose."
),
)
parser.add_argument(
"--custom-mapping-file",
nargs="+",
Expand Down
24 changes: 24 additions & 0 deletions tests/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,30 @@ def test_cmdline_on_ignored_undeclared_option(
).splitlines(),
id="generate_toml_config_with_multiple_pyenvs",
),
pytest.param(
{},
["--install-deps", "--generate-toml-config"],
dedent(
"""\
# Copy this TOML section into your pyproject.toml to configure FawltyDeps
# (default values are commented)
[tool.fawltydeps]
# actions = ['check_undeclared', 'check_unused']
# output_format = 'human_summary'
# code = ['.']
# deps = ['.']
# pyenvs = []
# ignore_undeclared = []
# ignore_unused = []
# deps_parser_choice = ...
install_deps = true
# verbosity = 0
# custom_mapping_file = []
# [tool.fawltydeps.custom_mapping]
"""
).splitlines(),
id="generate_toml_config_with_install_deps",
),
],
)
def test_cmdline_args_in_combination_with_config_file(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cmdline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"""
)
venvs = [str(project_with_no_issues / ".venv")]
other = ["--generate-toml-file", "--version"]
other = ["--generate-toml-config", "--version", "--install-deps"]


# Options below contain paths specific for an input project
Expand Down
2 changes: 1 addition & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
code={Path(".")},
deps={Path(".")},
pyenvs=set(),
custom_mapping_file=set(),
custom_mapping=None,
output_format=OutputFormat.HUMAN_SUMMARY,
ignore_undeclared=set(),
ignore_unused=set(),
deps_parser_choice=None,
install_deps=False,
verbosity=0,
custom_mapping_file=set(),
)


Expand Down

0 comments on commit 4644fcf

Please sign in to comment.