Visitar URL original
Restore support for EntryPoint access by item. Fixes #348. · python/importlib_metadata@205a9bc · GitHub
Skip to content

Commit 205a9bc

Browse files
committed
Restore support for EntryPoint access by item. Fixes #348.
1 parent fa620f1 commit 205a9bc

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

‎importlib_metadata/__init__.py‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,30 @@ def valid(line):
125125
return line and not line.startswith('#')
126126

127127

128-
class EntryPoint:
128+
class DeprecatedTuple:
129+
"""
130+
>>> recwarn = getfixture('recwarn')
131+
>>> ep = EntryPoint(name='name', value='value', group='group')
132+
>>> ep[:]
133+
('name', 'value', 'group')
134+
>>> ep[0]
135+
'name'
136+
>>> len(recwarn)
137+
1
138+
"""
139+
_warn = functools.partial(
140+
warnings.warn,
141+
"EntryPoint tuple interface is deprecated. Access members by name.",
142+
DeprecationWarning,
143+
stacklevel=pypy_partial(2),
144+
)
145+
146+
def __getitem__(self, item):
147+
self._warn()
148+
return self._key()[item]
149+
150+
151+
class EntryPoint(DeprecatedTuple):
129152
"""An entry point as defined by Python packaging conventions.
130153
131154
See `the packaging docs on entry points

0 commit comments

Comments
 (0)