Skip to content

Commit 9130df2

Browse files
committed
Restore importlib.metadata to the version that worked.
1 parent 2f4bc46 commit 9130df2

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

Lib/importlib/metadata/__init__.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class _EntryPointMatch(types.SimpleNamespace):
136136
extras: str
137137

138138

139+
from typing import Optional, List, cast, Match
140+
139141
class EntryPoint:
140142
"""An entry point as defined by Python packaging conventions.
141143
@@ -202,7 +204,7 @@ class EntryPoint:
202204
value: str
203205
group: str
204206

205-
dist: Distribution | None = None
207+
dist: Optional[Distribution] = None
206208

207209
def __init__(self, name: str, value: str, group: str) -> None:
208210
vars(self).update(name=name, value=value, group=group)
@@ -212,7 +214,7 @@ def load(self) -> Any:
212214
is indicated by the value, return that module. Otherwise,
213215
return the named object.
214216
"""
215-
match = self.pattern.match(self.value)
217+
match = cast(Match, self.pattern.match(self.value))
216218
module = import_module(match.group('module'))
217219
attrs = filter(None, (match.group('attr') or '').split('.'))
218220
return functools.reduce(getattr, attrs, module)
@@ -230,23 +232,11 @@ def attr(self) -> str:
230232
return match.group('attr')
231233

232234
@property
233-
def extras(self) -> list[str]:
235+
def extras(self) -> List[str]:
234236
match = self.pattern.match(self.value)
235237
assert match is not None
236238
return re.findall(r'\w+', match.group('extras') or '')
237239

238-
@property
239-
def _match(self) -> _EntryPointMatch:
240-
match = self.pattern.match(self.value)
241-
if not match:
242-
raise ValueError(
243-
'Invalid object reference. '
244-
'See https://packaging.python.org'
245-
'/en/latest/specifications/entry-points/#data-model',
246-
self.value,
247-
)
248-
return _EntryPointMatch(**match.groupdict())
249-
250240
def _for(self, dist):
251241
vars(self).update(dist=dist)
252242
return self

0 commit comments

Comments
 (0)