Skip to content

Commit

Permalink
Restore support for EntryPoint access by item. Fixes #348.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 29, 2021
1 parent fa620f1 commit 205a9bc
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,30 @@ def valid(line):
return line and not line.startswith('#')


class EntryPoint:
class DeprecatedTuple:
"""
>>> recwarn = getfixture('recwarn')
>>> ep = EntryPoint(name='name', value='value', group='group')
>>> ep[:]
('name', 'value', 'group')
>>> ep[0]
'name'
>>> len(recwarn)
1
"""
_warn = functools.partial(
warnings.warn,
"EntryPoint tuple interface is deprecated. Access members by name.",
DeprecationWarning,
stacklevel=pypy_partial(2),
)

def __getitem__(self, item):
self._warn()
return self._key()[item]


class EntryPoint(DeprecatedTuple):
"""An entry point as defined by Python packaging conventions.
See `the packaging docs on entry points
Expand Down

0 comments on commit 205a9bc

Please sign in to comment.