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

Allow comma-separated arguments for --extra #1493

Merged
merged 2 commits into from Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions piptools/scripts/compile.py
@@ -1,3 +1,4 @@
import itertools
import os
import shlex
import sys
Expand Down Expand Up @@ -420,6 +421,8 @@ def cli(
)
)

extras = tuple(itertools.chain.from_iterable(ex.split(",") for ex in extras))

if extras and not setup_file_found:
msg = "--extra has effect only with setup.py and PEP-517 input formats"
raise click.BadParameter(msg)
Expand Down
14 changes: 9 additions & 5 deletions tests/test_cli_compile.py
Expand Up @@ -1933,9 +1933,16 @@ def test_one_extra(fake_dists, runner, make_module, fname, content):


@pytest.mark.network
@pytest.mark.parametrize(
"extra_opts",
(
pytest.param(("--extra", "dev", "--extra", "test"), id="singular"),
pytest.param(("--extra", "dev,test"), id="comma-separated"),
),
)
@pytest.mark.parametrize(("fname", "content"), METADATA_TEST_CASES)
@pytest.mark.xfail(is_pypy, reason="https://github.com/jazzband/pip-tools/issues/1375")
def test_multiple_extras(fake_dists, runner, make_module, fname, content):
def test_multiple_extras(fake_dists, runner, make_module, fname, content, extra_opts):
"""
Test passing multiple `--extra` params.
"""
Expand All @@ -1944,10 +1951,7 @@ def test_multiple_extras(fake_dists, runner, make_module, fname, content):
cli,
[
"-n",
"--extra",
"dev",
"--extra",
"test",
*extra_opts,
"--find-links",
fake_dists,
meta_path,
Expand Down