Skip to content

Commit 2f4bc46

Browse files
committed
Restore Entry Point behavior.
1 parent 63c4a77 commit 2f4bc46

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Lib/importlib/metadata/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,28 +206,34 @@ class EntryPoint:
206206

207207
def __init__(self, name: str, value: str, group: str) -> None:
208208
vars(self).update(name=name, value=value, group=group)
209-
self.module
210209

211210
def load(self) -> Any:
212211
"""Load the entry point from its definition. If only a module
213212
is indicated by the value, return that module. Otherwise,
214213
return the named object.
215214
"""
216-
module = import_module(self.module)
217-
attrs = filter(None, (self.attr or '').split('.'))
215+
match = self.pattern.match(self.value)
216+
module = import_module(match.group('module'))
217+
attrs = filter(None, (match.group('attr') or '').split('.'))
218218
return functools.reduce(getattr, attrs, module)
219219

220220
@property
221221
def module(self) -> str:
222-
return self._match.module
222+
match = self.pattern.match(self.value)
223+
assert match is not None
224+
return match.group('module')
223225

224226
@property
225227
def attr(self) -> str:
226-
return self._match.attr
228+
match = self.pattern.match(self.value)
229+
assert match is not None
230+
return match.group('attr')
227231

228232
@property
229233
def extras(self) -> list[str]:
230-
return re.findall(r'\w+', self._match.extras or '')
234+
match = self.pattern.match(self.value)
235+
assert match is not None
236+
return re.findall(r'\w+', match.group('extras') or '')
231237

232238
@property
233239
def _match(self) -> _EntryPointMatch:

0 commit comments

Comments
 (0)