Skip to content

Commit 8c4cff1

Browse files
committed
Convert LegacyGroupedEntryPoints into simpler dict interface deprecation.
1 parent aa9f799 commit 8c4cff1

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

importlib_metadata/__init__.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -228,42 +228,22 @@ def select(self, **params):
228228
return self._all.select(**params)
229229

230230

231-
class LegacyGroupedEntryPoints(EntryPoints): # pragma: nocover
231+
class DeprecatedDict(dict): # pragma: nocover
232232
"""
233-
Compatibility wrapper around EntryPoints to provide
234-
much of the 'dict' interface previously returned by
235-
entry_points.
233+
Compatibility wrapper around dict to indicate that
234+
Mapping behavior is deprecated.
236235
"""
237236

238-
def __getitem__(self, name) -> Union[EntryPoint, 'EntryPoints']:
239-
"""
240-
When accessed by name that matches a group, return the group.
241-
"""
242-
group = self.select(group=name)
243-
if group:
244-
msg = "GroupedEntryPoints.__getitem__ is deprecated for groups. Use select."
245-
warnings.warn(msg, DeprecationWarning, stacklevel=2)
246-
return group
247-
237+
def __getitem__(self, name):
238+
msg = "SelectableGroups.__getitem__ is deprecated. Use select."
239+
warnings.warn(msg, DeprecationWarning, stacklevel=2)
248240
return super().__getitem__(name)
249241

250-
def get(self, group, default=None):
251-
"""
252-
For backward compatibility, supply .get.
253-
"""
242+
def get(self, name, default=None):
254243
is_flake8 = any('flake8' in str(frame) for frame in inspect.stack())
255-
msg = "GroupedEntryPoints.get is deprecated. Use select."
244+
msg = "SelectableGroups.get is deprecated. Use select."
256245
is_flake8 or warnings.warn(msg, DeprecationWarning, stacklevel=2)
257-
return self.select(group=group) or default
258-
259-
def select(self, **params):
260-
"""
261-
Prevent transform to EntryPoints during call to entry_points if
262-
no selection parameters were passed.
263-
"""
264-
if not params:
265-
return self
266-
return super().select(**params)
246+
return super().get(name, default)
267247

268248

269249
class PackagePath(pathlib.PurePosixPath):

0 commit comments

Comments
 (0)