Skip to content

Commit eccc2c7

Browse files
[pre-commit.ci] pre-commit autoupdate (#1563)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bernát Gábor <bgabor8@bloomberg.net>
1 parent cc856c3 commit eccc2c7

File tree

8 files changed

+39
-25
lines changed

8 files changed

+39
-25
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ repos:
77
- id: trailing-whitespace
88
- id: check-yaml
99
- repo: https://github.com/tox-dev/pyproject-fmt
10-
rev: v2.7.0
10+
rev: v2.19.0
1111
hooks:
1212
- id: pyproject-fmt
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.11.8
14+
rev: v0.15.6
1515
hooks:
1616
- id: ruff
1717
args: [ "--fix", "--unsafe-fixes", "--show-fixes", "--exit-non-zero-on-fix"]

pyproject.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ classifiers = [
3131
"Programming Language :: Python :: 3.11",
3232
"Programming Language :: Python :: 3.12",
3333
"Programming Language :: Python :: 3.13",
34+
"Programming Language :: Python :: 3.14",
3435
]
3536
dynamic = [
3637
"version",
@@ -43,11 +44,11 @@ dependencies = [
4344
"tomli; python_version<'3.11'",
4445
"userpath>=1.6,!=1.9",
4546
]
46-
urls.Documentation = "https://pipx.pypa.io"
47-
urls.Homepage = "https://pipx.pypa.io"
4847
urls."Issue Tracker" = "https://github.com/pypa/pipx/issues"
4948
urls."Release Notes" = "https://pipx.pypa.io/latest/changelog/"
5049
urls."Source Code" = "https://github.com/pypa/pipx"
50+
urls.Documentation = "https://pipx.pypa.io"
51+
urls.Homepage = "https://pipx.pypa.io"
5152
scripts.pipx = "pipx.main:cli"
5253

5354
[tool.hatch]
@@ -99,19 +100,24 @@ lint.mccabe.max-complexity = 15
99100

100101
[tool.codespell]
101102
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
102-
skip = '.git,*.pdf,*.svg,.nox,testdata,.mypy_cache'
103+
skip = ".git,*.pdf,*.svg,.nox,testdata,.mypy_cache"
103104
check-hidden = true
104105
# case sensitive etc
105-
ignore-regex = '\b(UE|path/doesnt/exist)\b'
106+
ignore-regex = "\\b(UE|path/doesnt/exist)\\b"
106107

107-
[tool.pytest.ini_options]
108-
minversion = "8"
109-
log_cli_level = "INFO"
110-
markers = [
108+
[tool.mypy]
109+
overrides = [ { module = [
110+
"pycowsay.*",
111+
], ignore_missing_imports = true } ]
112+
113+
[tool.pytest]
114+
ini_options.minversion = "8"
115+
ini_options.log_cli_level = "INFO"
116+
ini_options.markers = [
111117
"all_packages: test install with maximum number of packages",
112118
]
113-
testpaths = [ "tests" ]
114-
addopts = [ "-ra", "--strict-config", "--strict-markers" ]
119+
ini_options.testpaths = [ "tests" ]
120+
ini_options.addopts = [ "-ra", "--strict-config", "--strict-markers" ]
115121

116122
[tool.towncrier]
117123
directory = "changelog.d"
@@ -125,9 +131,3 @@ underlines = [
125131
title_format = "## [{version}](https://github.com/pypa/pipx/tree/{version}) - {project_date}"
126132
issue_format = "[#{issue}](https://github.com/pypa/pipx/issues/{issue})"
127133
package = "pipx"
128-
129-
[[tool.mypy.overrides]]
130-
module = [
131-
"pycowsay.*",
132-
]
133-
ignore_missing_imports = true

src/pipx/commands/upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def upgrade_shared(
274274
pip_args: List[str],
275275
) -> ExitCode:
276276
"""Return pipx exit code."""
277-
from pipx.shared_libs import shared_libs
277+
from pipx.shared_libs import shared_libs # noqa: PLC0415
278278

279279
shared_libs.upgrade(verbose=verbose, pip_args=pip_args, raises=True)
280280

src/pipx/interpreter.py

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

1818
def has_venv() -> bool:
1919
try:
20-
import venv # noqa: F401
20+
import venv # noqa: F401, PLC0415
2121
except ImportError:
2222
return False
2323
return True

src/pipx/shared_libs.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import datetime
22
import logging
33
import time
4+
from contextlib import suppress
45
from pathlib import Path
56
from typing import Dict, List
67

8+
from packaging.requirements import InvalidRequirement, Requirement
9+
from packaging.specifiers import SpecifierSet
10+
711
from pipx import paths
812
from pipx.animate import animate
913
from pipx.constants import WINDOWS
@@ -122,6 +126,17 @@ def upgrade(self, *, pip_args: List[str], verbose: bool = False, raises: bool =
122126
_pip_args = [arg for arg in pip_args if arg not in ignored_args]
123127
if not verbose:
124128
_pip_args.append("-q")
129+
130+
user_pip_req = None
131+
for arg in _pip_args:
132+
with suppress(InvalidRequirement):
133+
if (req := Requirement(arg)).name == "pip":
134+
user_pip_req = req
135+
break
136+
137+
add_default = not user_pip_req or not (user_pip_req.specifier & SpecifierSet(">=23.1"))
138+
install_args = [*_pip_args, "pip >= 23.1"] if add_default else _pip_args
139+
125140
try:
126141
with animate("upgrading shared libraries", not verbose):
127142
upgrade_process = run_subprocess(
@@ -132,9 +147,8 @@ def upgrade(self, *, pip_args: List[str], verbose: bool = False, raises: bool =
132147
"--no-input",
133148
"--disable-pip-version-check",
134149
"install",
135-
*_pip_args,
136150
"--upgrade",
137-
"pip >= 23.1",
151+
*install_args,
138152
]
139153
)
140154
subprocess_post_check(upgrade_process)

testdata/empty_project/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[build-system]
22
build-backend = "setuptools.build_meta"
3-
43
requires = [
54
"setuptools",
65
]
@@ -20,6 +19,7 @@ classifiers = [
2019
"Programming Language :: Python :: 3.11",
2120
"Programming Language :: Python :: 3.12",
2221
"Programming Language :: Python :: 3.13",
22+
"Programming Language :: Python :: 3.14",
2323
]
2424
scripts.empty-project = "empty_project.main:cli"
2525
entry-points."pipx.run".empty-project = "empty_project.main:cli"

tests/test_package_specifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,6 @@ def test_parse_specifier_for_install(
272272
root,
273273
):
274274
monkeypatch.chdir(root)
275-
[package_or_url_out, pip_args_out] = parse_specifier_for_install(package_spec_in, pip_args_in)
275+
parse_specifier_for_install(package_spec_in, pip_args_in)
276276
if warning_str is not None:
277277
assert warning_str in caplog.text

tests/test_upgrade_shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@pytest.fixture
99
def shared_libs(pipx_ultra_temp_env):
1010
# local import to get the shared_libs object patched by fixtures
11-
from pipx.shared_libs import shared_libs as _shared_libs
11+
from pipx.shared_libs import shared_libs as _shared_libs # noqa: PLC0415
1212

1313
yield _shared_libs
1414

0 commit comments

Comments
 (0)