Skip to content

Commit

Permalink
fix: no message when no packages upgraded with upgrade-all (#1597)
Browse files Browse the repository at this point in the history
* fix: no message when no packages upgraded with upgrade-all

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update changelog.d/1565.bugfix.md

Co-authored-by: Chak-Kuen Lam <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chak-Kuen Lam <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2025
1 parent ec04aba commit 36d632d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/1565.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix no message displayed when no packages are upgraded with `upgrade-all`.
6 changes: 3 additions & 3 deletions src/pipx/commands/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def upgrade_all(
if venv_dir.name in skip or "--editable" in venv.pipx_metadata.main_package.pip_args:
continue
try:
_upgrade_venv(
versions_updated = _upgrade_venv(
venv_dir,
venv.pipx_metadata.main_package.pip_args,
verbose=verbose,
Expand All @@ -256,11 +256,11 @@ def upgrade_all(
force=force,
python_flag_passed=python_flag_passed,
)
if versions_updated > 0:
upgraded.append(venv_dir.name)
except PipxError as e:
print(e, file=sys.stderr)
failed.append(venv_dir.name)
else:
upgraded.append(venv_dir.name)
if len(upgraded) == 0:
print(f"No packages upgraded after running 'pipx upgrade-all' {sleep}")
if len(failed) > 0:
Expand Down
1 change: 1 addition & 0 deletions tests/test_upgrade_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def test_upgrade_all(pipx_temp_env, capsys):


def test_upgrade_all_none(pipx_temp_env, capsys):
assert not run_pipx_cli(["install", "pycowsay"])
assert not run_pipx_cli(["upgrade-all"])
captured = capsys.readouterr()
assert "No packages upgraded after running 'pipx upgrade-all'" in captured.out
Expand Down

0 comments on commit 36d632d

Please sign in to comment.