Skip to content

Commit

Permalink
Add compatibility handler for accessing EntryPoints by index. Fixes #300
Browse files Browse the repository at this point in the history
.
  • Loading branch information
jaraco committed May 30, 2021
1 parent b65679d commit 589003f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ def __getitem__(self, name): # -> EntryPoint:
"""
Get the EntryPoint in self matching name.
"""
if isinstance(name, int):
warnings.warn(
"Accessing entry points by index is deprecated. "
"Cast to tuple if needed.",
DeprecationWarning,
stacklevel=2,
)
return super().__getitem__(name)
try:
return next(iter(self.select(name=name)))
except StopIteration:
Expand Down

0 comments on commit 589003f

Please sign in to comment.