From 35faee2f30d2050c4b14172073c3252d150896b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lum=C3=ADr=20Balhar?= Date: Thu, 18 Jun 2026 12:00:18 +0000 Subject: [PATCH 1/2] fix: replace deprecated posixpath.commonprefix() with startswith() os.path.commonprefix() is deprecated in Python 3.15 and emits a DeprecationWarning. Replace all three usages with str.startswith() checks, which are also semantically more correct (commonprefix does character-level matching and can produce false positives for paths sharing a string prefix but not a directory boundary). --- src/installer/_core.py | 2 +- src/installer/sources.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/installer/_core.py b/src/installer/_core.py index e23f06e..24ed294 100644 --- a/src/installer/_core.py +++ b/src/installer/_core.py @@ -42,7 +42,7 @@ def _determine_scheme( data_dir = source.data_dir # If it's in not `{distribution}-{version}.data`, then it's in root_scheme. - if posixpath.commonprefix([data_dir, path]) != data_dir: + if not path.startswith(data_dir + "/"): return root_scheme, path # Figure out which scheme this goes to. diff --git a/src/installer/sources.py b/src/installer/sources.py index 839934f..f76177b 100644 --- a/src/installer/sources.py +++ b/src/installer/sources.py @@ -220,7 +220,7 @@ def dist_info_filenames(self) -> list[str]: name[len(base) + 1 :] for name in self._zipfile.namelist() if name[-1:] != "/" - if base == posixpath.commonprefix([name, base]) + if name.startswith(base + "/") ] def read_dist_info(self, filename: str) -> str: @@ -259,9 +259,7 @@ def validate_record(self, *, validate_contents: bool = True) -> None: record_args = record_mapping.pop(item.filename, None) - if self.dist_info_dir == posixpath.commonprefix( - [self.dist_info_dir, item.filename] - ) and item.filename.split("/")[-1] in ("RECORD.p7s", "RECORD.jws"): + if item.filename.startswith(self.dist_info_dir + "/") and item.filename.split("/")[-1] in ("RECORD.p7s", "RECORD.jws"): # both are for digital signatures, and not mentioned in RECORD if record_args is not None: # Incorrectly contained From 7671087481739236ff40788b9045c4b8a62f98fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jun 2026 19:03:32 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/installer/sources.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/installer/sources.py b/src/installer/sources.py index f76177b..cd6291a 100644 --- a/src/installer/sources.py +++ b/src/installer/sources.py @@ -259,7 +259,9 @@ def validate_record(self, *, validate_contents: bool = True) -> None: record_args = record_mapping.pop(item.filename, None) - if item.filename.startswith(self.dist_info_dir + "/") and item.filename.split("/")[-1] in ("RECORD.p7s", "RECORD.jws"): + if item.filename.startswith( + self.dist_info_dir + "/" + ) and item.filename.split("/")[-1] in ("RECORD.p7s", "RECORD.jws"): # both are for digital signatures, and not mentioned in RECORD if record_args is not None: # Incorrectly contained