Skip to content

Commit 2f3de0a

Browse files
committed
Remove support for '::' spec for dependency groups
The `pip` parsing for `--group` already uses a single colon for this information. Rather than introducing a second format here, to match other `pip-compile` behaviors, stick to only one format for this information.
1 parent 425c14e commit 2f3de0a

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

piptools/_internal/_cli/_param_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class DependencyGroupParamType(click.ParamType):
99
def get_metavar(self, param: click.Parameter) -> str:
10-
return "[pyproject-path::]groupname"
10+
return "[pyproject-path:]groupname"
1111

1212
def convert(
1313
self, value: str, param: click.Parameter | None, ctx: click.Context | None

piptools/_internal/_cli/_parsed_param_types.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ class ParsedDependencyGroupParam:
1414
1515
``:`` cannot appear in dependency group names, so this is a safe and simple parse.
1616
17-
If the path portion ends in ":", then the ":" is removed, effectively resulting in
18-
a split on "::" when that is used.
19-
2017
The following conversions are expected::
2118
2219
'foo' -> ('pyproject.toml', 'foo')
2320
'foo/pyproject.toml:bar' -> ('foo/pyproject.toml', 'bar')
24-
'foo/pyproject.toml::bar' -> ('foo/pyproject.toml', 'bar')
2521
"""
2622

2723
def __init__(self, value: str) -> None:
@@ -31,9 +27,6 @@ def __init__(self, value: str) -> None:
3127
if not sep:
3228
path = "pyproject.toml"
3329
else:
34-
# strip a rightmost ":" if one was present
35-
if path.endswith(":"):
36-
path = path[:-1]
3730
# check for 'pyproject.toml' filenames using pathlib
3831
if pathlib.PurePath(path).name != "pyproject.toml":
3932
msg = "group paths use 'pyproject.toml' filenames"

tests/test_cli_compile.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,27 +1570,20 @@ def __exit__(self, *args, **kwargs):
15701570
""")
15711571

15721572

1573-
@pytest.mark.parametrize(
1574-
"groupspec",
1575-
("mygroup", "pyproject.toml:mygroup", "pyproject.toml::mygroup"),
1576-
)
1573+
@pytest.mark.parametrize("groupspec", ("mygroup", "pyproject.toml:mygroup"))
15771574
def test_dependency_group_resolution(pip_conf, runner, tmpdir_cwd, groupspec):
15781575
"""
15791576
Test compile requirements from pyproject.toml [dependency-groups].
15801577
"""
15811578
pyproj = tmpdir_cwd / "pyproject.toml"
1582-
pyproj.write_text(
1583-
dedent(
1584-
"""\
1579+
pyproj.write_text(dedent("""\
15851580
[project]
15861581
name = "foo"
15871582
version = "1.0"
15881583
15891584
[dependency-groups]
15901585
mygroup = ["small-fake-a==0.1"]
1591-
"""
1592-
)
1593-
)
1586+
"""))
15941587

15951588
out = runner.invoke(
15961589
cli,
@@ -1606,12 +1599,10 @@ def test_dependency_group_resolution(pip_conf, runner, tmpdir_cwd, groupspec):
16061599
)
16071600
assert out.exit_code == 0, out.stderr
16081601

1609-
assert out.stdout == dedent(
1610-
f"""\
1602+
assert out.stdout == dedent(f"""\
16111603
small-fake-a==0.1
16121604
# via --group '{groupspec}'
1613-
"""
1614-
)
1605+
""")
16151606

16161607

16171608
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)