2929from importlib import import_module
3030from importlib .abc import MetaPathFinder
3131from itertools import starmap
32- from typing import List , Mapping , Optional , Union
32+ from typing import List , Mapping , Optional
3333
3434
3535__all__ = [
@@ -344,10 +344,6 @@ def names(self):
344344 def groups (self ):
345345 """
346346 Return the set of all groups of all entry points.
347-
348- For coverage while SelectableGroups is present.
349- >>> EntryPoints().groups
350- set()
351347 """
352348 return set (ep .group for ep in self )
353349
@@ -367,109 +363,6 @@ def _parse_groups(text):
367363 )
368364
369365
370- def flake8_bypass (func ):
371- # defer inspect import as performance optimization.
372- import inspect
373-
374- is_flake8 = any ('flake8' in str (frame .filename ) for frame in inspect .stack ()[:5 ])
375- return func if not is_flake8 else lambda : None
376-
377-
378- class Deprecated :
379- """
380- Compatibility add-in for mapping to indicate that
381- mapping behavior is deprecated.
382-
383- >>> recwarn = getfixture('recwarn')
384- >>> class DeprecatedDict(Deprecated, dict): pass
385- >>> dd = DeprecatedDict(foo='bar')
386- >>> dd.get('baz', None)
387- >>> dd['foo']
388- 'bar'
389- >>> list(dd)
390- ['foo']
391- >>> list(dd.keys())
392- ['foo']
393- >>> 'foo' in dd
394- True
395- >>> list(dd.values())
396- ['bar']
397- >>> len(recwarn)
398- 1
399- """
400-
401- _warn = functools .partial (
402- warnings .warn ,
403- "SelectableGroups dict interface is deprecated. Use select." ,
404- DeprecationWarning ,
405- stacklevel = 2 ,
406- )
407-
408- def __getitem__ (self , name ):
409- self ._warn ()
410- return super ().__getitem__ (name )
411-
412- def get (self , name , default = None ):
413- flake8_bypass (self ._warn )()
414- return super ().get (name , default )
415-
416- def __iter__ (self ):
417- self ._warn ()
418- return super ().__iter__ ()
419-
420- def __contains__ (self , * args ):
421- self ._warn ()
422- return super ().__contains__ (* args )
423-
424- def keys (self ):
425- self ._warn ()
426- return super ().keys ()
427-
428- def values (self ):
429- self ._warn ()
430- return super ().values ()
431-
432-
433- class SelectableGroups (Deprecated , dict ):
434- """
435- A backward- and forward-compatible result from
436- entry_points that fully implements the dict interface.
437- """
438-
439- @classmethod
440- def load (cls , eps ):
441- by_group = operator .attrgetter ('group' )
442- ordered = sorted (eps , key = by_group )
443- grouped = itertools .groupby (ordered , by_group )
444- return cls ((group , EntryPoints (eps )) for group , eps in grouped )
445-
446- @property
447- def _all (self ):
448- """
449- Reconstruct a list of all entrypoints from the groups.
450- """
451- groups = super (Deprecated , self ).values ()
452- return EntryPoints (itertools .chain .from_iterable (groups ))
453-
454- @property
455- def groups (self ):
456- return self ._all .groups
457-
458- @property
459- def names (self ):
460- """
461- for coverage:
462- >>> SelectableGroups().names
463- set()
464- """
465- return self ._all .names
466-
467- def select (self , ** params ):
468- if not params :
469- return self
470- return self ._all .select (** params )
471-
472-
473366class PackagePath (pathlib .PurePosixPath ):
474367 """A reference to a path in a package"""
475368
@@ -964,29 +857,21 @@ def version(distribution_name):
964857 return distribution (distribution_name ).version
965858
966859
967- def entry_points (** params ) -> Union [ EntryPoints , SelectableGroups ] :
860+ def entry_points (** params ) -> EntryPoints :
968861 """Return EntryPoint objects for all installed packages.
969862
970863 Pass selection parameters (group or name) to filter the
971864 result to entry points matching those properties (see
972865 EntryPoints.select()).
973866
974- For compatibility, returns ``SelectableGroups`` object unless
975- selection parameters are supplied. In the future, this function
976- will return ``EntryPoints`` instead of ``SelectableGroups``
977- even when no selection parameters are supplied.
978-
979- For maximum future compatibility, pass selection parameters
980- or invoke ``.select`` with parameters on the result.
981-
982- :return: EntryPoints or SelectableGroups for all installed packages.
867+ :return: EntryPoints for all installed packages.
983868 """
984869 norm_name = operator .attrgetter ('_normalized_name' )
985870 unique = functools .partial (unique_everseen , key = norm_name )
986871 eps = itertools .chain .from_iterable (
987872 dist .entry_points for dist in unique (distributions ())
988873 )
989- return SelectableGroups . load (eps ).select (** params )
874+ return EntryPoints (eps ).select (** params )
990875
991876
992877def files (distribution_name ):
0 commit comments