Skip to content

Commit ae697fd

Browse files
cthoythenryiii
authored andcommitted
Use explicit _GLibCVersion tuple
This addresses some type mismatches between `_GLibCVersion` and `tuple[int, int]`
1 parent be71767 commit ae697fd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/packaging/_manylinux.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _glibc_version_string() -> str | None:
150150
return _glibc_version_string_confstr() or _glibc_version_string_ctypes()
151151

152152

153-
def _parse_glibc_version(version_str: str) -> tuple[int, int]:
153+
def _parse_glibc_version(version_str: str) -> _GLibCVersion:
154154
"""Parse glibc version.
155155
156156
We use a regexp instead of str.split because we want to discard any
@@ -165,15 +165,15 @@ def _parse_glibc_version(version_str: str) -> tuple[int, int]:
165165
RuntimeWarning,
166166
stacklevel=2,
167167
)
168-
return -1, -1
169-
return int(m.group("major")), int(m.group("minor"))
168+
return _GLibCVersion(-1, -1)
169+
return _GLibCVersion(int(m.group("major")), int(m.group("minor")))
170170

171171

172172
@functools.lru_cache
173-
def _get_glibc_version() -> tuple[int, int]:
173+
def _get_glibc_version() -> _GLibCVersion:
174174
version_str = _glibc_version_string()
175175
if version_str is None:
176-
return (-1, -1)
176+
return _GLibCVersion(-1, -1)
177177
return _parse_glibc_version(version_str)
178178

179179

@@ -204,13 +204,13 @@ def _is_compatible(arch: str, version: _GLibCVersion) -> bool:
204204
return True
205205

206206

207-
_LEGACY_MANYLINUX_MAP = {
207+
_LEGACY_MANYLINUX_MAP: dict[_GLibCVersion, str] = {
208208
# CentOS 7 w/ glibc 2.17 (PEP 599)
209-
(2, 17): "manylinux2014",
209+
_GLibCVersion(2, 17): "manylinux2014",
210210
# CentOS 6 w/ glibc 2.12 (PEP 571)
211-
(2, 12): "manylinux2010",
211+
_GLibCVersion(2, 12): "manylinux2010",
212212
# CentOS 5 w/ glibc 2.5 (PEP 513)
213-
(2, 5): "manylinux1",
213+
_GLibCVersion(2, 5): "manylinux1",
214214
}
215215

216216

0 commit comments

Comments
 (0)