Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD CLI option for --install-deps #341

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ 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`: Automatically install Python dependencies gathered with
FawltyDeps into a temporary virtual environment. This will use `pip install`,
which downloads packages from PyPI by default.
- `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."
),
jherland marked this conversation as resolved.
Show resolved Hide resolved
)
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"]
jherland marked this conversation as resolved.
Show resolved Hide resolved


# 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 @@ -40,14 +40,14 @@
code={Path(".")},
deps={Path(".")},
pyenvs={Path(".")},
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
Loading