diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index f79a437b..b3f90838 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -125,7 +125,32 @@ def valid(line): return line and not line.startswith('#') -class EntryPoint: +class DeprecatedTuple: + """ + Provide subscript item access for backward compatibility. + + >>> 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