Skip to content

Commit 2146ab6

Browse files
fix #1610: Reorder upgrade option and arguments (#1625)
* fix: Change order of --upgrade and pip_args * Add unit test for upgrade --editable * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e6ae882 commit 2146ab6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

changelog.d/1610.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incorrect order of flags when using `pipx upgrade`.

src/pipx/venv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def has_package(self, package_name: str) -> bool:
441441
def upgrade_package_no_metadata(self, package_name: str, pip_args: List[str]) -> None:
442442
logger.info("Upgrading %s", package_descr := full_package_description(package_name, package_name))
443443
with animate(f"upgrading {package_descr}", self.do_animation):
444-
pip_process = self._run_pip(["--no-input", "install"] + pip_args + ["--upgrade", package_name])
444+
pip_process = self._run_pip(["--no-input", "install", "--upgrade"] + pip_args + [package_name])
445445
subprocess_post_check(pip_process)
446446

447447
def upgrade_package(
@@ -456,7 +456,7 @@ def upgrade_package(
456456
) -> None:
457457
logger.info("Upgrading %s", package_descr := full_package_description(package_name, package_or_url))
458458
with animate(f"upgrading {package_descr}", self.do_animation):
459-
pip_process = self._run_pip(["--no-input", "install"] + pip_args + ["--upgrade", package_or_url])
459+
pip_process = self._run_pip(["--no-input", "install", "--upgrade"] + pip_args + [package_or_url])
460460
subprocess_post_check(pip_process)
461461

462462
self.update_package_metadata(

tests/test_upgrade.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ def test_upgrade_specifier(pipx_temp_env, capsys):
7878
assert f"upgraded package {name} from {initial_version} to" in captured.out
7979

8080

81+
def test_upgrade_editable(pipx_temp_env, capsys, root):
82+
empty_project_path_as_string = (root / "testdata" / "empty_project").as_posix()
83+
assert not run_pipx_cli(["install", "--editable", empty_project_path_as_string, "--force"])
84+
assert not run_pipx_cli(["upgrade", "--editable", "empty_project"])
85+
captured = capsys.readouterr()
86+
assert "empty-project is already at latest version" in captured.out
87+
88+
8189
def test_upgrade_include_injected(pipx_temp_env, capsys):
8290
assert not run_pipx_cli(["install", PKG["pylint"]["spec"]])
8391
assert not run_pipx_cli(["inject", "pylint", PKG["black"]["spec"]])

0 commit comments

Comments
 (0)