From a59ffc6d5096ea7a22ebed48ff39880dbaf2c88d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2023 11:52:23 -0500 Subject: [PATCH 1/2] Supply Distribution.locate_file, honoring the abstract method. Fixes #11684. --- src/pip/_internal/metadata/importlib/_dists.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pip/_internal/metadata/importlib/_dists.py b/src/pip/_internal/metadata/importlib/_dists.py index 65c043c87ef..8fefeacebaa 100644 --- a/src/pip/_internal/metadata/importlib/_dists.py +++ b/src/pip/_internal/metadata/importlib/_dists.py @@ -92,6 +92,9 @@ def read_text(self, filename: str) -> Optional[str]: raise UnsupportedWheel(error) return text + def locate_file(self, path): + raise NotImplementedError() + class Distribution(BaseDistribution): def __init__( From 255312e1ed39d76ff6ab4055f4093add49543ac6 Mon Sep 17 00:00:00 2001 From: Richard Si Date: Sat, 11 Jan 2025 21:56:19 -0500 Subject: [PATCH 2/2] Add type annotations + comment --- src/pip/_internal/metadata/importlib/_dists.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/metadata/importlib/_dists.py b/src/pip/_internal/metadata/importlib/_dists.py index 4fd442fc429..cf8685439a9 100644 --- a/src/pip/_internal/metadata/importlib/_dists.py +++ b/src/pip/_internal/metadata/importlib/_dists.py @@ -2,6 +2,7 @@ import importlib.metadata import pathlib import zipfile +from os import PathLike from typing import ( Collection, Dict, @@ -95,8 +96,10 @@ def read_text(self, filename: str) -> Optional[str]: raise UnsupportedWheel(error) return text - def locate_file(self, path): - raise NotImplementedError() + def locate_file(self, path: str | PathLike[str]) -> pathlib.Path: + # This method doesn't make sense for our in-memory wheel, but the API + # requires us to define it. + raise NotImplementedError class Distribution(BaseDistribution):