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 8535856 commit a8c70ee
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions importlib_metadata/__init__.py
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 a8c70ee

Please sign in to comment.