pip 25.1__py3-none-any.whl → 25.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. pip/__init__.py +3 -3
  2. pip/_internal/__init__.py +2 -2
  3. pip/_internal/build_env.py +118 -94
  4. pip/_internal/cache.py +16 -14
  5. pip/_internal/cli/autocompletion.py +13 -4
  6. pip/_internal/cli/base_command.py +18 -7
  7. pip/_internal/cli/cmdoptions.py +14 -9
  8. pip/_internal/cli/command_context.py +4 -3
  9. pip/_internal/cli/index_command.py +11 -9
  10. pip/_internal/cli/main.py +3 -2
  11. pip/_internal/cli/main_parser.py +4 -3
  12. pip/_internal/cli/parser.py +26 -22
  13. pip/_internal/cli/progress_bars.py +19 -12
  14. pip/_internal/cli/req_command.py +16 -12
  15. pip/_internal/cli/spinners.py +81 -5
  16. pip/_internal/commands/__init__.py +5 -3
  17. pip/_internal/commands/cache.py +18 -15
  18. pip/_internal/commands/check.py +1 -2
  19. pip/_internal/commands/completion.py +1 -2
  20. pip/_internal/commands/configuration.py +26 -18
  21. pip/_internal/commands/debug.py +8 -6
  22. pip/_internal/commands/download.py +2 -3
  23. pip/_internal/commands/freeze.py +2 -3
  24. pip/_internal/commands/hash.py +1 -2
  25. pip/_internal/commands/help.py +1 -2
  26. pip/_internal/commands/index.py +15 -9
  27. pip/_internal/commands/inspect.py +4 -4
  28. pip/_internal/commands/install.py +45 -40
  29. pip/_internal/commands/list.py +35 -26
  30. pip/_internal/commands/lock.py +1 -2
  31. pip/_internal/commands/search.py +14 -12
  32. pip/_internal/commands/show.py +14 -11
  33. pip/_internal/commands/uninstall.py +1 -2
  34. pip/_internal/commands/wheel.py +2 -3
  35. pip/_internal/configuration.py +39 -25
  36. pip/_internal/distributions/base.py +6 -4
  37. pip/_internal/distributions/installed.py +8 -4
  38. pip/_internal/distributions/sdist.py +20 -13
  39. pip/_internal/distributions/wheel.py +6 -4
  40. pip/_internal/exceptions.py +58 -39
  41. pip/_internal/index/collector.py +24 -29
  42. pip/_internal/index/package_finder.py +70 -61
  43. pip/_internal/index/sources.py +17 -14
  44. pip/_internal/locations/__init__.py +18 -16
  45. pip/_internal/locations/_distutils.py +12 -11
  46. pip/_internal/locations/_sysconfig.py +5 -4
  47. pip/_internal/locations/base.py +4 -3
  48. pip/_internal/main.py +2 -2
  49. pip/_internal/metadata/__init__.py +8 -6
  50. pip/_internal/metadata/_json.py +5 -4
  51. pip/_internal/metadata/base.py +22 -27
  52. pip/_internal/metadata/importlib/_compat.py +6 -4
  53. pip/_internal/metadata/importlib/_dists.py +12 -17
  54. pip/_internal/metadata/importlib/_envs.py +9 -6
  55. pip/_internal/metadata/pkg_resources.py +11 -14
  56. pip/_internal/models/direct_url.py +24 -21
  57. pip/_internal/models/format_control.py +5 -5
  58. pip/_internal/models/installation_report.py +4 -3
  59. pip/_internal/models/link.py +39 -34
  60. pip/_internal/models/pylock.py +27 -22
  61. pip/_internal/models/search_scope.py +6 -7
  62. pip/_internal/models/selection_prefs.py +3 -3
  63. pip/_internal/models/target_python.py +10 -9
  64. pip/_internal/models/wheel.py +7 -5
  65. pip/_internal/network/auth.py +20 -22
  66. pip/_internal/network/cache.py +22 -6
  67. pip/_internal/network/download.py +169 -141
  68. pip/_internal/network/lazy_wheel.py +10 -7
  69. pip/_internal/network/session.py +32 -27
  70. pip/_internal/network/utils.py +2 -2
  71. pip/_internal/network/xmlrpc.py +2 -2
  72. pip/_internal/operations/build/build_tracker.py +10 -8
  73. pip/_internal/operations/build/wheel.py +3 -2
  74. pip/_internal/operations/build/wheel_editable.py +3 -2
  75. pip/_internal/operations/build/wheel_legacy.py +9 -8
  76. pip/_internal/operations/check.py +21 -26
  77. pip/_internal/operations/freeze.py +12 -9
  78. pip/_internal/operations/install/editable_legacy.py +5 -3
  79. pip/_internal/operations/install/wheel.py +53 -44
  80. pip/_internal/operations/prepare.py +35 -30
  81. pip/_internal/pyproject.py +7 -10
  82. pip/_internal/req/__init__.py +12 -10
  83. pip/_internal/req/constructors.py +33 -31
  84. pip/_internal/req/req_dependency_group.py +9 -8
  85. pip/_internal/req/req_file.py +32 -35
  86. pip/_internal/req/req_install.py +37 -34
  87. pip/_internal/req/req_set.py +4 -5
  88. pip/_internal/req/req_uninstall.py +20 -17
  89. pip/_internal/resolution/base.py +3 -3
  90. pip/_internal/resolution/legacy/resolver.py +21 -20
  91. pip/_internal/resolution/resolvelib/base.py +16 -13
  92. pip/_internal/resolution/resolvelib/candidates.py +29 -26
  93. pip/_internal/resolution/resolvelib/factory.py +41 -50
  94. pip/_internal/resolution/resolvelib/found_candidates.py +11 -9
  95. pip/_internal/resolution/resolvelib/provider.py +15 -20
  96. pip/_internal/resolution/resolvelib/reporter.py +5 -3
  97. pip/_internal/resolution/resolvelib/requirements.py +8 -6
  98. pip/_internal/resolution/resolvelib/resolver.py +39 -23
  99. pip/_internal/self_outdated_check.py +8 -6
  100. pip/_internal/utils/appdirs.py +1 -2
  101. pip/_internal/utils/compat.py +7 -1
  102. pip/_internal/utils/compatibility_tags.py +17 -16
  103. pip/_internal/utils/deprecation.py +11 -9
  104. pip/_internal/utils/direct_url_helpers.py +2 -2
  105. pip/_internal/utils/egg_link.py +6 -5
  106. pip/_internal/utils/entrypoints.py +3 -2
  107. pip/_internal/utils/filesystem.py +8 -5
  108. pip/_internal/utils/filetypes.py +4 -6
  109. pip/_internal/utils/glibc.py +6 -5
  110. pip/_internal/utils/hashes.py +9 -6
  111. pip/_internal/utils/logging.py +8 -5
  112. pip/_internal/utils/misc.py +54 -44
  113. pip/_internal/utils/packaging.py +3 -2
  114. pip/_internal/utils/retry.py +7 -4
  115. pip/_internal/utils/setuptools_build.py +12 -10
  116. pip/_internal/utils/subprocess.py +20 -17
  117. pip/_internal/utils/temp_dir.py +10 -12
  118. pip/_internal/utils/unpacking.py +6 -4
  119. pip/_internal/utils/urls.py +1 -1
  120. pip/_internal/utils/virtualenv.py +3 -2
  121. pip/_internal/utils/wheel.py +3 -4
  122. pip/_internal/vcs/bazaar.py +26 -8
  123. pip/_internal/vcs/git.py +59 -24
  124. pip/_internal/vcs/mercurial.py +34 -11
  125. pip/_internal/vcs/subversion.py +27 -16
  126. pip/_internal/vcs/versioncontrol.py +56 -51
  127. pip/_internal/wheel_builder.py +14 -12
  128. pip/_vendor/cachecontrol/__init__.py +1 -1
  129. pip/_vendor/certifi/__init__.py +1 -1
  130. pip/_vendor/certifi/cacert.pem +102 -221
  131. pip/_vendor/certifi/core.py +1 -32
  132. pip/_vendor/dependency_groups/_implementation.py +7 -11
  133. pip/_vendor/distlib/__init__.py +2 -2
  134. pip/_vendor/distlib/scripts.py +1 -1
  135. pip/_vendor/msgpack/__init__.py +2 -2
  136. pip/_vendor/pkg_resources/__init__.py +1 -1
  137. pip/_vendor/platformdirs/version.py +2 -2
  138. pip/_vendor/pygments/__init__.py +1 -1
  139. pip/_vendor/requests/__version__.py +2 -2
  140. pip/_vendor/requests/compat.py +12 -0
  141. pip/_vendor/requests/models.py +3 -1
  142. pip/_vendor/requests/utils.py +6 -16
  143. pip/_vendor/resolvelib/__init__.py +3 -3
  144. pip/_vendor/resolvelib/reporters.py +1 -1
  145. pip/_vendor/resolvelib/resolvers/__init__.py +4 -4
  146. pip/_vendor/resolvelib/resolvers/resolution.py +91 -10
  147. pip/_vendor/rich/__main__.py +12 -40
  148. pip/_vendor/rich/_inspect.py +1 -1
  149. pip/_vendor/rich/_ratio.py +1 -7
  150. pip/_vendor/rich/align.py +1 -7
  151. pip/_vendor/rich/box.py +1 -7
  152. pip/_vendor/rich/console.py +25 -20
  153. pip/_vendor/rich/control.py +1 -7
  154. pip/_vendor/rich/diagnose.py +1 -0
  155. pip/_vendor/rich/emoji.py +1 -6
  156. pip/_vendor/rich/live.py +32 -7
  157. pip/_vendor/rich/live_render.py +1 -7
  158. pip/_vendor/rich/logging.py +1 -1
  159. pip/_vendor/rich/panel.py +3 -4
  160. pip/_vendor/rich/progress.py +15 -15
  161. pip/_vendor/rich/spinner.py +7 -13
  162. pip/_vendor/rich/syntax.py +24 -5
  163. pip/_vendor/rich/traceback.py +32 -17
  164. pip/_vendor/truststore/_api.py +1 -1
  165. pip/_vendor/vendor.txt +10 -11
  166. {pip-25.1.dist-info → pip-25.2.dist-info}/METADATA +26 -4
  167. {pip-25.1.dist-info → pip-25.2.dist-info}/RECORD +194 -181
  168. {pip-25.1.dist-info → pip-25.2.dist-info}/WHEEL +1 -1
  169. {pip-25.1.dist-info → pip-25.2.dist-info}/licenses/AUTHORS.txt +12 -0
  170. pip-25.2.dist-info/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  171. pip-25.2.dist-info/licenses/src/pip/_vendor/certifi/LICENSE +20 -0
  172. pip-25.2.dist-info/licenses/src/pip/_vendor/dependency_groups/LICENSE.txt +9 -0
  173. pip-25.2.dist-info/licenses/src/pip/_vendor/distlib/LICENSE.txt +284 -0
  174. pip-25.2.dist-info/licenses/src/pip/_vendor/distro/LICENSE +202 -0
  175. pip-25.2.dist-info/licenses/src/pip/_vendor/idna/LICENSE.md +31 -0
  176. pip-25.2.dist-info/licenses/src/pip/_vendor/msgpack/COPYING +14 -0
  177. pip-25.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE +3 -0
  178. pip-25.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.APACHE +177 -0
  179. pip-25.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.BSD +23 -0
  180. pip-25.2.dist-info/licenses/src/pip/_vendor/pkg_resources/LICENSE +17 -0
  181. pip-25.2.dist-info/licenses/src/pip/_vendor/platformdirs/LICENSE +21 -0
  182. pip-25.2.dist-info/licenses/src/pip/_vendor/pygments/LICENSE +25 -0
  183. pip-25.2.dist-info/licenses/src/pip/_vendor/pyproject_hooks/LICENSE +21 -0
  184. pip-25.2.dist-info/licenses/src/pip/_vendor/requests/LICENSE +175 -0
  185. pip-25.2.dist-info/licenses/src/pip/_vendor/resolvelib/LICENSE +13 -0
  186. pip-25.2.dist-info/licenses/src/pip/_vendor/rich/LICENSE +19 -0
  187. pip-25.2.dist-info/licenses/src/pip/_vendor/tomli/LICENSE +21 -0
  188. pip-25.2.dist-info/licenses/src/pip/_vendor/tomli/LICENSE-HEADER +3 -0
  189. pip-25.2.dist-info/licenses/src/pip/_vendor/tomli_w/LICENSE +21 -0
  190. pip-25.2.dist-info/licenses/src/pip/_vendor/truststore/LICENSE +21 -0
  191. pip-25.2.dist-info/licenses/src/pip/_vendor/urllib3/LICENSE.txt +21 -0
  192. pip/_vendor/distlib/database.py +0 -1329
  193. pip/_vendor/distlib/index.py +0 -508
  194. pip/_vendor/distlib/locators.py +0 -1295
  195. pip/_vendor/distlib/manifest.py +0 -384
  196. pip/_vendor/distlib/markers.py +0 -162
  197. pip/_vendor/distlib/metadata.py +0 -1031
  198. pip/_vendor/distlib/version.py +0 -750
  199. pip/_vendor/distlib/wheel.py +0 -1100
  200. pip/_vendor/typing_extensions.py +0 -4584
  201. {pip-25.1.dist-info → pip-25.2.dist-info}/entry_points.txt +0 -0
  202. {pip-25.1.dist-info → pip-25.2.dist-info}/licenses/LICENSE.txt +0 -0
  203. {pip-25.1.dist-info → pip-25.2.dist-info}/top_level.txt +0 -0
@@ -8,7 +8,6 @@ and eventually drop this after all usages are changed.
8
8
 
9
9
  import os
10
10
  import sys
11
- from typing import List
12
11
 
13
12
  from pip._vendor import platformdirs as _appdirs
14
13
 
@@ -40,7 +39,7 @@ def user_config_dir(appname: str, roaming: bool = True) -> str:
40
39
 
41
40
  # for the discussion regarding site_config_dir locations
42
41
  # see <https://github.com/pypa/pip/issues/1733>
43
- def site_config_dirs(appname: str) -> List[str]:
42
+ def site_config_dirs(appname: str) -> list[str]:
44
43
  if sys.platform == "darwin":
45
44
  dirval = _appdirs.site_data_dir(appname, appauthor=False, multipath=True)
46
45
  return dirval.split(os.pathsep)
@@ -7,7 +7,7 @@ import os
7
7
  import sys
8
8
  from typing import IO
9
9
 
10
- __all__ = ["get_path_uid", "stdlib_pkgs", "WINDOWS"]
10
+ __all__ = ["get_path_uid", "stdlib_pkgs", "tomllib", "WINDOWS"]
11
11
 
12
12
 
13
13
  logger = logging.getLogger(__name__)
@@ -67,6 +67,12 @@ else:
67
67
  )
68
68
 
69
69
 
70
+ if sys.version_info >= (3, 11):
71
+ import tomllib
72
+ else:
73
+ from pip._vendor import tomli as tomllib
74
+
75
+
70
76
  # packages in the stdlib that may have installation metadata, but should not be
71
77
  # considered 'installed'. this theoretically could be determined based on
72
78
  # dist.location (py27:`sysconfig.get_paths()['stdlib']`,
@@ -1,7 +1,8 @@
1
1
  """Generate and work with PEP 425 Compatibility Tags."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  import re
4
- from typing import List, Optional, Tuple
5
6
 
6
7
  from pip._vendor.packaging.tags import (
7
8
  PythonVersion,
@@ -19,12 +20,12 @@ from pip._vendor.packaging.tags import (
19
20
  _apple_arch_pat = re.compile(r"(.+)_(\d+)_(\d+)_(.+)")
20
21
 
21
22
 
22
- def version_info_to_nodot(version_info: Tuple[int, ...]) -> str:
23
+ def version_info_to_nodot(version_info: tuple[int, ...]) -> str:
23
24
  # Only use up to the first two numbers.
24
25
  return "".join(map(str, version_info[:2]))
25
26
 
26
27
 
27
- def _mac_platforms(arch: str) -> List[str]:
28
+ def _mac_platforms(arch: str) -> list[str]:
28
29
  match = _apple_arch_pat.match(arch)
29
30
  if match:
30
31
  name, major, minor, actual_arch = match.groups()
@@ -44,7 +45,7 @@ def _mac_platforms(arch: str) -> List[str]:
44
45
  return arches
45
46
 
46
47
 
47
- def _ios_platforms(arch: str) -> List[str]:
48
+ def _ios_platforms(arch: str) -> list[str]:
48
49
  match = _apple_arch_pat.match(arch)
49
50
  if match:
50
51
  name, major, minor, actual_multiarch = match.groups()
@@ -64,7 +65,7 @@ def _ios_platforms(arch: str) -> List[str]:
64
65
  return arches
65
66
 
66
67
 
67
- def _android_platforms(arch: str) -> List[str]:
68
+ def _android_platforms(arch: str) -> list[str]:
68
69
  match = re.fullmatch(r"android_(\d+)_(.+)", arch)
69
70
  if match:
70
71
  api_level, abi = match.groups()
@@ -74,7 +75,7 @@ def _android_platforms(arch: str) -> List[str]:
74
75
  return [arch]
75
76
 
76
77
 
77
- def _custom_manylinux_platforms(arch: str) -> List[str]:
78
+ def _custom_manylinux_platforms(arch: str) -> list[str]:
78
79
  arches = [arch]
79
80
  arch_prefix, arch_sep, arch_suffix = arch.partition("_")
80
81
  if arch_prefix == "manylinux2014":
@@ -95,7 +96,7 @@ def _custom_manylinux_platforms(arch: str) -> List[str]:
95
96
  return arches
96
97
 
97
98
 
98
- def _get_custom_platforms(arch: str) -> List[str]:
99
+ def _get_custom_platforms(arch: str) -> list[str]:
99
100
  arch_prefix, arch_sep, arch_suffix = arch.partition("_")
100
101
  if arch.startswith("macosx"):
101
102
  arches = _mac_platforms(arch)
@@ -110,7 +111,7 @@ def _get_custom_platforms(arch: str) -> List[str]:
110
111
  return arches
111
112
 
112
113
 
113
- def _expand_allowed_platforms(platforms: Optional[List[str]]) -> Optional[List[str]]:
114
+ def _expand_allowed_platforms(platforms: list[str] | None) -> list[str] | None:
114
115
  if not platforms:
115
116
  return None
116
117
 
@@ -135,7 +136,7 @@ def _get_python_version(version: str) -> PythonVersion:
135
136
 
136
137
 
137
138
  def _get_custom_interpreter(
138
- implementation: Optional[str] = None, version: Optional[str] = None
139
+ implementation: str | None = None, version: str | None = None
139
140
  ) -> str:
140
141
  if implementation is None:
141
142
  implementation = interpreter_name()
@@ -145,11 +146,11 @@ def _get_custom_interpreter(
145
146
 
146
147
 
147
148
  def get_supported(
148
- version: Optional[str] = None,
149
- platforms: Optional[List[str]] = None,
150
- impl: Optional[str] = None,
151
- abis: Optional[List[str]] = None,
152
- ) -> List[Tag]:
149
+ version: str | None = None,
150
+ platforms: list[str] | None = None,
151
+ impl: str | None = None,
152
+ abis: list[str] | None = None,
153
+ ) -> list[Tag]:
153
154
  """Return a list of supported tags for each version specified in
154
155
  `versions`.
155
156
 
@@ -162,9 +163,9 @@ def get_supported(
162
163
  :param abis: specify a list of abis you want valid
163
164
  tags for, or None. If None, use the local interpreter abi.
164
165
  """
165
- supported: List[Tag] = []
166
+ supported: list[Tag] = []
166
167
 
167
- python_version: Optional[PythonVersion] = None
168
+ python_version: PythonVersion | None = None
168
169
  if version is not None:
169
170
  python_version = _get_python_version(version)
170
171
 
@@ -2,9 +2,11 @@
2
2
  A module that implements tooling to enable easy warnings about deprecations.
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  import logging
6
8
  import warnings
7
- from typing import Any, Optional, TextIO, Type, Union
9
+ from typing import Any, TextIO
8
10
 
9
11
  from pip._vendor.packaging.version import parse
10
12
 
@@ -22,12 +24,12 @@ _original_showwarning: Any = None
22
24
 
23
25
  # Warnings <-> Logging Integration
24
26
  def _showwarning(
25
- message: Union[Warning, str],
26
- category: Type[Warning],
27
+ message: Warning | str,
28
+ category: type[Warning],
27
29
  filename: str,
28
30
  lineno: int,
29
- file: Optional[TextIO] = None,
30
- line: Optional[str] = None,
31
+ file: TextIO | None = None,
32
+ line: str | None = None,
31
33
  ) -> None:
32
34
  if file is not None:
33
35
  if _original_showwarning is not None:
@@ -55,10 +57,10 @@ def install_warning_logger() -> None:
55
57
  def deprecated(
56
58
  *,
57
59
  reason: str,
58
- replacement: Optional[str],
59
- gone_in: Optional[str],
60
- feature_flag: Optional[str] = None,
61
- issue: Optional[int] = None,
60
+ replacement: str | None,
61
+ gone_in: str | None,
62
+ feature_flag: str | None = None,
63
+ issue: int | None = None,
62
64
  ) -> None:
63
65
  """Helper to deprecate existing functionality.
64
66
 
@@ -1,4 +1,4 @@
1
- from typing import Optional
1
+ from __future__ import annotations
2
2
 
3
3
  from pip._internal.models.direct_url import ArchiveInfo, DirectUrl, DirInfo, VcsInfo
4
4
  from pip._internal.models.link import Link
@@ -37,7 +37,7 @@ def direct_url_for_editable(source_dir: str) -> DirectUrl:
37
37
 
38
38
 
39
39
  def direct_url_from_link(
40
- link: Link, source_dir: Optional[str] = None, link_is_in_wheel_cache: bool = False
40
+ link: Link, source_dir: str | None = None, link_is_in_wheel_cache: bool = False
41
41
  ) -> DirectUrl:
42
42
  if link.is_vcs:
43
43
  vcs_backend = vcs.get_backend_for_scheme(link.scheme)
@@ -1,7 +1,8 @@
1
+ from __future__ import annotations
2
+
1
3
  import os
2
4
  import re
3
5
  import sys
4
- from typing import List, Optional
5
6
 
6
7
  from pip._internal.locations import site_packages, user_site
7
8
  from pip._internal.utils.virtualenv import (
@@ -15,7 +16,7 @@ __all__ = [
15
16
  ]
16
17
 
17
18
 
18
- def _egg_link_names(raw_name: str) -> List[str]:
19
+ def _egg_link_names(raw_name: str) -> list[str]:
19
20
  """
20
21
  Convert a Name metadata value to a .egg-link name, by applying
21
22
  the same substitution as pkg_resources's safe_name function.
@@ -30,7 +31,7 @@ def _egg_link_names(raw_name: str) -> List[str]:
30
31
  ]
31
32
 
32
33
 
33
- def egg_link_path_from_sys_path(raw_name: str) -> Optional[str]:
34
+ def egg_link_path_from_sys_path(raw_name: str) -> str | None:
34
35
  """
35
36
  Look for a .egg-link file for project name, by walking sys.path.
36
37
  """
@@ -43,7 +44,7 @@ def egg_link_path_from_sys_path(raw_name: str) -> Optional[str]:
43
44
  return None
44
45
 
45
46
 
46
- def egg_link_path_from_location(raw_name: str) -> Optional[str]:
47
+ def egg_link_path_from_location(raw_name: str) -> str | None:
47
48
  """
48
49
  Return the path for the .egg-link file if it exists, otherwise, None.
49
50
 
@@ -61,7 +62,7 @@ def egg_link_path_from_location(raw_name: str) -> Optional[str]:
61
62
 
62
63
  This method will just return the first one found.
63
64
  """
64
- sites: List[str] = []
65
+ sites: list[str] = []
65
66
  if running_under_virtualenv():
66
67
  sites.append(site_packages)
67
68
  if not virtualenv_no_global() and user_site:
@@ -1,8 +1,9 @@
1
+ from __future__ import annotations
2
+
1
3
  import itertools
2
4
  import os
3
5
  import shutil
4
6
  import sys
5
- from typing import List, Optional
6
7
 
7
8
  from pip._internal.cli.main import main
8
9
  from pip._internal.utils.compat import WINDOWS
@@ -20,7 +21,7 @@ if WINDOWS:
20
21
  ]
21
22
 
22
23
 
23
- def _wrapper(args: Optional[List[str]] = None) -> int:
24
+ def _wrapper(args: list[str] | None = None) -> int:
24
25
  """Central wrapper for all old entrypoints.
25
26
 
26
27
  Historically pip has had several entrypoints defined. Because of issues
@@ -1,11 +1,14 @@
1
+ from __future__ import annotations
2
+
1
3
  import fnmatch
2
4
  import os
3
5
  import os.path
4
6
  import random
5
7
  import sys
8
+ from collections.abc import Generator
6
9
  from contextlib import contextmanager
7
10
  from tempfile import NamedTemporaryFile
8
- from typing import Any, BinaryIO, Generator, List, Union, cast
11
+ from typing import Any, BinaryIO, cast
9
12
 
10
13
  from pip._internal.utils.compat import get_path_uid
11
14
  from pip._internal.utils.misc import format_size
@@ -115,17 +118,17 @@ def _test_writable_dir_win(path: str) -> bool:
115
118
  raise OSError("Unexpected condition testing for writable directory")
116
119
 
117
120
 
118
- def find_files(path: str, pattern: str) -> List[str]:
121
+ def find_files(path: str, pattern: str) -> list[str]:
119
122
  """Returns a list of absolute paths of files beneath path, recursively,
120
123
  with filenames which match the UNIX-style shell glob pattern."""
121
- result: List[str] = []
124
+ result: list[str] = []
122
125
  for root, _, files in os.walk(path):
123
126
  matches = fnmatch.filter(files, pattern)
124
127
  result.extend(os.path.join(root, f) for f in matches)
125
128
  return result
126
129
 
127
130
 
128
- def file_size(path: str) -> Union[int, float]:
131
+ def file_size(path: str) -> int | float:
129
132
  # If it's a symlink, return 0.
130
133
  if os.path.islink(path):
131
134
  return 0
@@ -136,7 +139,7 @@ def format_file_size(path: str) -> str:
136
139
  return format_size(file_size(path))
137
140
 
138
141
 
139
- def directory_size(path: str) -> Union[int, float]:
142
+ def directory_size(path: str) -> int | float:
140
143
  size = 0.0
141
144
  for root, _dirs, files in os.walk(path):
142
145
  for filename in files:
@@ -1,20 +1,18 @@
1
1
  """Filetype information."""
2
2
 
3
- from typing import Tuple
4
-
5
3
  from pip._internal.utils.misc import splitext
6
4
 
7
5
  WHEEL_EXTENSION = ".whl"
8
- BZ2_EXTENSIONS: Tuple[str, ...] = (".tar.bz2", ".tbz")
9
- XZ_EXTENSIONS: Tuple[str, ...] = (
6
+ BZ2_EXTENSIONS: tuple[str, ...] = (".tar.bz2", ".tbz")
7
+ XZ_EXTENSIONS: tuple[str, ...] = (
10
8
  ".tar.xz",
11
9
  ".txz",
12
10
  ".tlz",
13
11
  ".tar.lz",
14
12
  ".tar.lzma",
15
13
  )
16
- ZIP_EXTENSIONS: Tuple[str, ...] = (".zip", WHEEL_EXTENSION)
17
- TAR_EXTENSIONS: Tuple[str, ...] = (".tar.gz", ".tgz", ".tar")
14
+ ZIP_EXTENSIONS: tuple[str, ...] = (".zip", WHEEL_EXTENSION)
15
+ TAR_EXTENSIONS: tuple[str, ...] = (".tar.gz", ".tgz", ".tar")
18
16
  ARCHIVE_EXTENSIONS = ZIP_EXTENSIONS + BZ2_EXTENSIONS + TAR_EXTENSIONS + XZ_EXTENSIONS
19
17
 
20
18
 
@@ -1,14 +1,15 @@
1
+ from __future__ import annotations
2
+
1
3
  import os
2
4
  import sys
3
- from typing import Optional, Tuple
4
5
 
5
6
 
6
- def glibc_version_string() -> Optional[str]:
7
+ def glibc_version_string() -> str | None:
7
8
  "Returns glibc version string, or None if not using glibc."
8
9
  return glibc_version_string_confstr() or glibc_version_string_ctypes()
9
10
 
10
11
 
11
- def glibc_version_string_confstr() -> Optional[str]:
12
+ def glibc_version_string_confstr() -> str | None:
12
13
  "Primary implementation of glibc_version_string using os.confstr."
13
14
  # os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
14
15
  # to be broken or missing. This strategy is used in the standard library
@@ -28,7 +29,7 @@ def glibc_version_string_confstr() -> Optional[str]:
28
29
  return version
29
30
 
30
31
 
31
- def glibc_version_string_ctypes() -> Optional[str]:
32
+ def glibc_version_string_ctypes() -> str | None:
32
33
  "Fallback implementation of glibc_version_string using ctypes."
33
34
 
34
35
  try:
@@ -88,7 +89,7 @@ def glibc_version_string_ctypes() -> Optional[str]:
88
89
  # versions that was generated by pip 8.1.2 and earlier is useless and
89
90
  # misleading. Solution: instead of using platform, use our code that actually
90
91
  # works.
91
- def libc_ver() -> Tuple[str, str]:
92
+ def libc_ver() -> tuple[str, str]:
92
93
  """Try to determine the glibc version
93
94
 
94
95
  Returns a tuple of strings (lib, version) which default to empty strings
@@ -1,5 +1,8 @@
1
+ from __future__ import annotations
2
+
1
3
  import hashlib
2
- from typing import TYPE_CHECKING, BinaryIO, Dict, Iterable, List, NoReturn, Optional
4
+ from collections.abc import Iterable
5
+ from typing import TYPE_CHECKING, BinaryIO, NoReturn
3
6
 
4
7
  from pip._internal.exceptions import HashMismatch, HashMissing, InstallationError
5
8
  from pip._internal.utils.misc import read_chunks
@@ -24,7 +27,7 @@ class Hashes:
24
27
 
25
28
  """
26
29
 
27
- def __init__(self, hashes: Optional[Dict[str, List[str]]] = None) -> None:
30
+ def __init__(self, hashes: dict[str, list[str]] | None = None) -> None:
28
31
  """
29
32
  :param hashes: A dict of algorithm names pointing to lists of allowed
30
33
  hex digests
@@ -36,7 +39,7 @@ class Hashes:
36
39
  allowed[alg] = [k.lower() for k in sorted(keys)]
37
40
  self._allowed = allowed
38
41
 
39
- def __and__(self, other: "Hashes") -> "Hashes":
42
+ def __and__(self, other: Hashes) -> Hashes:
40
43
  if not isinstance(other, Hashes):
41
44
  return NotImplemented
42
45
 
@@ -86,7 +89,7 @@ class Hashes:
86
89
  return
87
90
  self._raise(gots)
88
91
 
89
- def _raise(self, gots: Dict[str, "_Hash"]) -> "NoReturn":
92
+ def _raise(self, gots: dict[str, _Hash]) -> NoReturn:
90
93
  raise HashMismatch(self._allowed, gots)
91
94
 
92
95
  def check_against_file(self, file: BinaryIO) -> None:
@@ -101,7 +104,7 @@ class Hashes:
101
104
  with open(path, "rb") as file:
102
105
  return self.check_against_file(file)
103
106
 
104
- def has_one_of(self, hashes: Dict[str, str]) -> bool:
107
+ def has_one_of(self, hashes: dict[str, str]) -> bool:
105
108
  """Return whether any of the given hashes are allowed."""
106
109
  for hash_name, hex_digest in hashes.items():
107
110
  if self.is_hash_allowed(hash_name, hex_digest):
@@ -143,5 +146,5 @@ class MissingHashes(Hashes):
143
146
  # empty list, it will never match, so an error will always raise.
144
147
  super().__init__(hashes={FAVORITE_HASH: []})
145
148
 
146
- def _raise(self, gots: Dict[str, "_Hash"]) -> "NoReturn":
149
+ def _raise(self, gots: dict[str, _Hash]) -> NoReturn:
147
150
  raise HashMissing(gots[FAVORITE_HASH].hexdigest())
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import contextlib
2
4
  import errno
3
5
  import logging
@@ -5,10 +7,11 @@ import logging.handlers
5
7
  import os
6
8
  import sys
7
9
  import threading
10
+ from collections.abc import Generator
8
11
  from dataclasses import dataclass
9
12
  from io import TextIOWrapper
10
13
  from logging import Filter
11
- from typing import Any, ClassVar, Generator, List, Optional, Type
14
+ from typing import Any, ClassVar
12
15
 
13
16
  from pip._vendor.rich.console import (
14
17
  Console,
@@ -40,7 +43,7 @@ class BrokenStdoutLoggingError(Exception):
40
43
  """
41
44
 
42
45
 
43
- def _is_broken_pipe_error(exc_class: Type[BaseException], exc: BaseException) -> bool:
46
+ def _is_broken_pipe_error(exc_class: type[BaseException], exc: BaseException) -> bool:
44
47
  if exc_class is BrokenPipeError:
45
48
  return True
46
49
 
@@ -156,7 +159,7 @@ def get_console(*, stderr: bool = False) -> Console:
156
159
 
157
160
 
158
161
  class RichPipStreamHandler(RichHandler):
159
- KEYWORDS: ClassVar[Optional[List[str]]] = []
162
+ KEYWORDS: ClassVar[list[str] | None] = []
160
163
 
161
164
  def __init__(self, console: Console) -> None:
162
165
  super().__init__(
@@ -169,7 +172,7 @@ class RichPipStreamHandler(RichHandler):
169
172
 
170
173
  # Our custom override on Rich's logger, to make things work as we need them to.
171
174
  def emit(self, record: logging.LogRecord) -> None:
172
- style: Optional[Style] = None
175
+ style: Style | None = None
173
176
 
174
177
  # If we are given a diagnostic error to present, present it with indentation.
175
178
  if getattr(record, "rich", False):
@@ -240,7 +243,7 @@ class ExcludeLoggerFilter(Filter):
240
243
  return not super().filter(record)
241
244
 
242
245
 
243
- def setup_logging(verbosity: int, no_color: bool, user_log_file: Optional[str]) -> int:
246
+ def setup_logging(verbosity: int, no_color: bool, user_log_file: str | None) -> int:
244
247
  """Configures and sets up all of the logging
245
248
 
246
249
  Returns the requested logging level, as its integer value.