11"""
22Compatibility layer with Python 3.8/3.9
33"""
4- from typing import TYPE_CHECKING , Any , Optional , Tuple
4+ from typing import TYPE_CHECKING , Any , Optional
55
66if TYPE_CHECKING : # pragma: no cover
77 # Prevent circular imports on runtime.
@@ -22,27 +22,14 @@ def normalized_name(dist: Distribution) -> Optional[str]:
2222 return Prepared .normalize (getattr (dist , "name" , None ) or dist .metadata ['Name' ])
2323
2424
25- def ep_matches (ep : EntryPoint , ** params ) -> Tuple [ EntryPoint , bool ] :
25+ def ep_matches (ep : EntryPoint , ** params ) -> bool :
2626 """
2727 Workaround for ``EntryPoint`` objects without the ``matches`` method.
28- For the sake of convenience, a tuple is returned containing not only the
29- boolean value corresponding to the predicate evalutation, but also a compatible
30- ``EntryPoint`` object that can be safely used at a later stage.
31-
32- For example, the following sequences of expressions should be compatible:
33-
34- # Sequence 1: using the compatibility layer
35- candidates = (_py39compat.ep_matches(ep, **params) for ep in entry_points)
36- [ep for ep, predicate in candidates if predicate]
37-
38- # Sequence 2: using Python 3.9+
39- [ep for ep in entry_points if ep.matches(**params)]
4028 """
4129 try :
42- return ep , ep .matches (** params )
30+ return ep .matches (** params )
4331 except AttributeError :
4432 from . import EntryPoint # -> delay to prevent circular imports.
4533
4634 # Reconstruct the EntryPoint object to make sure it is compatible.
47- _ep = EntryPoint (ep .name , ep .value , ep .group )
48- return _ep , _ep .matches (** params )
35+ return EntryPoint (ep .name , ep .value , ep .group ).matches (** params )
0 commit comments