@@ -188,27 +188,38 @@ def _from_text_for(cls, text, dist):
188
188
189
189
190
190
class LegacyGroupedEntryPoints (EntryPoints ):
191
+ """
192
+ Compatibility wrapper around EntryPoints to provide
193
+ much of the 'dict' interface previously returned by
194
+ entry_points.
195
+ """
196
+
191
197
def __getitem__ (self , name ) -> Union [EntryPoint , 'EntryPoints' ]:
192
- try :
193
- return super ().__getitem__ (name )
194
- except KeyError :
195
- if name not in self .groups :
196
- raise
198
+ """
199
+ When accessed by name that matches a group, return the group.
200
+ """
201
+ group = self .select (group = name )
202
+ if group :
203
+ msg = "GroupedEntryPoints.__getitem__ is deprecated for groups. Use select."
204
+ warnings .warn (msg , DeprecationWarning , stacklevel = 2 )
205
+ return group
197
206
198
- msg = "GroupedEntryPoints.__getitem__ is deprecated for groups. Use select."
199
- warnings .warn (msg , DeprecationWarning )
200
- return self .select (group = name )
207
+ return super ().__getitem__ (name )
201
208
202
209
def get (self , group , default = None ):
203
210
"""
204
- For backward compatibility, supply .get
211
+ For backward compatibility, supply .get.
205
212
"""
206
213
is_flake8 = any ('flake8' in str (frame ) for frame in inspect .stack ())
207
214
msg = "GroupedEntryPoints.get is deprecated. Use select."
208
- is_flake8 or warnings .warn (msg , DeprecationWarning )
215
+ is_flake8 or warnings .warn (msg , DeprecationWarning , stacklevel = 2 )
209
216
return self .select (group = group ) or default
210
217
211
218
def select (self , ** params ):
219
+ """
220
+ Prevent transform to EntryPoints during call to entry_points if
221
+ no selection parameters were passed.
222
+ """
212
223
if not params :
213
224
return self
214
225
return super ().select (** params )
0 commit comments