Skip to content

Commit 3064f71

Browse files
jdufresnexavfernandez
authored andcommitted
Upgrade vendored distro to use new typing and API
The most recent version of distro, 1.6.0, include type information. This allows pip to remove some workarounds. See upstream commit: python-distro/distro@20cb68d The new version also deprecated the top level function distro.linux_distribution(). Switch to the new preferred API. See upstream commit: python-distro/distro@f947776
1 parent 402bbcb commit 3064f71

File tree

6 files changed

+335
-189
lines changed

6 files changed

+335
-189
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade distro to 1.6.0.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ drop = [
5151
[tool.vendoring.typing-stubs]
5252
six = ["six.__init__", "six.moves.__init__", "six.moves.configparser"]
5353
appdirs = []
54+
distro = []
5455

5556
[tool.vendoring.license.directories]
5657
setuptools = "pkg_resources"

src/pip/_internal/network/session.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
network request configuration and behavior.
33
"""
44

5-
# When mypy runs on Windows the call to distro.linux_distribution() is skipped
6-
# resulting in the failure:
7-
#
8-
# error: unused 'type: ignore' comment
9-
#
10-
# If the upstream module adds typing, this comment should be removed. See
11-
# https://github.com/nir0s/distro/pull/269
12-
#
13-
# mypy: warn-unused-ignores=False
14-
155
import email.utils
166
import ipaddress
177
import json
@@ -128,9 +118,8 @@ def user_agent() -> str:
128118
if sys.platform.startswith("linux"):
129119
from pip._vendor import distro
130120

131-
# https://github.com/nir0s/distro/pull/269
132-
linux_distribution = distro.linux_distribution() # type: ignore
133-
distro_infos = dict(
121+
linux_distribution = distro.name(), distro.version(), distro.codename()
122+
distro_infos: Dict[str, Any] = dict(
134123
filter(
135124
lambda x: x[1],
136125
zip(["name", "version", "id"], linux_distribution),

0 commit comments

Comments
 (0)