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

fix: Correct error message when pypi-token.pypi has incorrect number of arguments. #8502

Merged
merged 3 commits into from
Oct 6, 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 src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def handle(self) -> int:

# show the value if no value is provided
if not self.argument("value") and not self.option("unset"):
if setting_key.split(".")[0] in self.LIST_PROHIBITED_SETTINGS:
raise ValueError(f"Expected a value for {setting_key} setting.")

m = re.match(r"^repos?(?:itories)?(?:\.(.+))?", self.argument("key"))
value: str | dict[str, Any]
if m:
Expand Down
9 changes: 9 additions & 0 deletions tests/console/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ def test_set_pypi_token_unsuccessful_multiple_values(
assert str(e.value) == "Expected only one argument (token), got 2"


def test_set_pypi_token_no_values(
tester: CommandTester,
) -> None:
with pytest.raises(ValueError) as e:
tester.execute("pypi-token.pypi")

assert str(e.value) == "Expected a value for pypi-token.pypi setting."


def test_set_client_cert(
tester: CommandTester,
auth_config_source: DictConfigSource,
Expand Down