@@ -188,27 +188,38 @@ def _from_text_for(cls, text, dist):
188188
189189
190190class LegacyGroupedEntryPoints (EntryPoints ):
191+ """
192+ Compatibility wrapper around EntryPoints to provide
193+ much of the 'dict' interface previously returned by
194+ entry_points.
195+ """
196+
191197 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
197206
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 )
201208
202209 def get (self , group , default = None ):
203210 """
204- For backward compatibility, supply .get
211+ For backward compatibility, supply .get.
205212 """
206213 is_flake8 = any ('flake8' in str (frame ) for frame in inspect .stack ())
207214 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 )
209216 return self .select (group = group ) or default
210217
211218 def select (self , ** params ):
219+ """
220+ Prevent transform to EntryPoints during call to entry_points if
221+ no selection parameters were passed.
222+ """
212223 if not params :
213224 return self
214225 return super ().select (** params )
0 commit comments