Skip to content

chore(cli): deprecate default source priority #10134

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

Merged
merged 1 commit into from
Feb 1, 2025
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
4 changes: 2 additions & 2 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ The `source add` command adds source configuration to the project.
For example, to add the `pypi-test` source, you can run:

```bash
poetry source add pypi-test https://test.pypi.org/simple/
poetry source add --priority supplemental pypi-test https://test.pypi.org/simple/
```

You cannot use the name `pypi` for a custom repository as it is reserved for use by
Expand All @@ -1015,7 +1015,7 @@ poetry source add --priority=explicit pypi

#### Options

* `--priority`: Set the priority of this source. Accepted values are: [`supplemental`]({{< relref "repositories#supplemental-package-sources" >}}), and [`explicit`]({{< relref "repositories#explicit-package-sources" >}}). Refer to the dedicated sections in [Repositories]({{< relref "repositories" >}}) for more information.
* `--priority`: Set the priority of this source. Accepted values are: [`primary`]({{< relref "repositories#primary-package-sources" >}}), [`supplemental`]({{< relref "repositories#supplemental-package-sources" >}}), and [`explicit`]({{< relref "repositories#explicit-package-sources" >}}). Refer to the dedicated sections in [Repositories]({{< relref "repositories" >}}) for more information.

### source show

Expand Down
7 changes: 6 additions & 1 deletion src/poetry/console/commands/source/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class SourceAddCommand(Command):
"p",
"Set the priority of this source. One of:"
f" {', '.join(p.name.lower() for p in Priority)}. Defaults to"
f" {Priority.PRIMARY.name.lower()}.",
f" {Priority.PRIMARY.name.lower()}, but will switch to "
f"{Priority.SUPPLEMENTAL.name.lower()} in a later release.",
flag=False,
),
]
Expand All @@ -70,6 +71,10 @@ def handle(self) -> int:
return 1

if priority_str is None:
self.io.write_error_line(
f"<warning>The default priority will change to <b>{Priority.SUPPLEMENTAL.name.lower()}</> "
f"in a future release.</>"
)
priority = Priority.PRIMARY
else:
priority = Priority[priority_str.upper()]
Expand Down
13 changes: 8 additions & 5 deletions tests/console/commands/source/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ def assert_source_added(
added_source: Source,
existing_sources: Iterable[Source] = (),
) -> None:
assert tester.io.fetch_error().strip() == ""
assert (
tester.io.fetch_output().strip()
== f"Adding source with name {added_source.name}."
)
expected_error = ""
if tester.io.input.option("priority") is None:
expected_error = f"The default priority will change to supplemental in a future release.\n{expected_error}"
assert tester.io.fetch_error().strip() == expected_error.strip()

expected_output = f"Adding source with name {added_source.name}."
assert tester.io.fetch_output().strip() == expected_output

poetry.pyproject.reload()
sources = poetry.get_sources()
assert sources == [*existing_sources, added_source]
Expand Down