Skip to content

Commit d2bb8eb

Browse files
jaracosbidoulichard26
authored
Add non-functional WheelDistribution.locate_file() method (#11685)
importlib.metadata.Distribution was always meant to be a proper ABC with API enforcement, but this enforcement was never added (probably due to Python 2.7 compatibility concerns). Upstream would like to fix this wart, so let's define a locate_file() method that simply raises NotImplementedError as permitted. Co-authored-by: Stéphane Bidoul <[email protected]> Co-authored-by: Richard Si <[email protected]>
1 parent 394e032 commit d2bb8eb

File tree

1 file changed

+6
-0
lines changed
  • src/pip/_internal/metadata/importlib

1 file changed

+6
-0
lines changed

src/pip/_internal/metadata/importlib/_dists.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import importlib.metadata
33
import pathlib
44
import zipfile
5+
from os import PathLike
56
from typing import (
67
Collection,
78
Dict,
@@ -95,6 +96,11 @@ def read_text(self, filename: str) -> Optional[str]:
9596
raise UnsupportedWheel(error)
9697
return text
9798

99+
def locate_file(self, path: str | PathLike[str]) -> pathlib.Path:
100+
# This method doesn't make sense for our in-memory wheel, but the API
101+
# requires us to define it.
102+
raise NotImplementedError
103+
98104

99105
class Distribution(BaseDistribution):
100106
def __init__(

0 commit comments

Comments
 (0)