Skip to content

Commit bc21d5f

Browse files
committed
Performance improvements
1 parent 2efac0d commit bc21d5f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

mypy/test/testpep561.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,19 @@ def virtualenv(python_executable: str = sys.executable) -> Iterator[tuple[str, s
4646
yield venv_dir, os.path.abspath(os.path.join(venv_dir, "bin", "python"))
4747

4848

49-
def upgrade_pip(python_executable: str, version_str: str) -> None:
50-
"""Install a newer pip version."""
51-
install_cmd = [python_executable, "-m", "pip", "install", f"pip{version_str}"]
49+
def upgrade_pip(python_executable: str) -> None:
50+
"""Install pip>=21.3.1. Required for editable installs with PEP 660."""
51+
if (
52+
sys.version_info >= (3, 11)
53+
or (3, 10, 3) <= sys.version_info < (3, 11)
54+
or (3, 9, 11) <= sys.version_info < (3, 10)
55+
or (3, 8, 13) <= sys.version_info < (3, 9)
56+
):
57+
# Skip for more recent Python release which come with pip>=21.3.1
58+
# out of the box - for performance reasons.
59+
return
60+
61+
install_cmd = [python_executable, "-m", "pip", "install", "pip>=21.3.1"]
5262
try:
5363
with filelock.FileLock(pip_lock, timeout=pip_timeout):
5464
proc = subprocess.run(install_cmd, capture_output=True, env=os.environ)
@@ -107,7 +117,7 @@ def test_pep561(testcase: DataDrivenTestCase) -> None:
107117
venv_dir, python_executable = venv
108118
if editable:
109119
# Editable installs with PEP 660 require pip>=21.3
110-
upgrade_pip(python_executable, ">=21.3.1")
120+
upgrade_pip(python_executable)
111121
for pkg in pkgs:
112122
install_package(pkg, python_executable, editable)
113123

0 commit comments

Comments
 (0)