2727 ModuleNotFoundError ,
2828 MetaPathFinder ,
2929 email_message_from_string ,
30- ensure_is_path ,
3130 )
3231from importlib import import_module
3332from itertools import starmap
@@ -184,8 +183,7 @@ def from_name(cls, name):
184183 metadata cannot be found.
185184 """
186185 for resolver in cls ._discover_resolvers ():
187- context = DistributionFinder .Context (name = name )
188- dists = cls ._maybe_bind (resolver , context )
186+ dists = resolver (DistributionFinder .Context (name = name ))
189187 dist = next (dists , None )
190188 if dist is not None :
191189 return dist
@@ -207,32 +205,18 @@ def discover(cls, **kwargs):
207205 raise ValueError ("cannot accept context and kwargs" )
208206 context = context or DistributionFinder .Context (** kwargs )
209207 return itertools .chain .from_iterable (
210- cls . _maybe_bind ( resolver , context )
208+ resolver ( context )
211209 for resolver in cls ._discover_resolvers ()
212210 )
213211
214- @staticmethod
215- def _maybe_bind (resolver , context ):
216- """
217- Only bind the context to the resolver if as a callable,
218- the resolver accepts the context parameter.
219-
220- Workaround for
221- https://gitlab.com/python-devs/importlib_metadata/issues/86
222- """
223- try : # pragma: nocover
224- return resolver (context )
225- except TypeError : # pragma: nocover
226- return resolver (name = context .name , path = context .path )
227-
228212 @staticmethod
229213 def at (path ):
230214 """Return a Distribution for the indicated metadata path
231215
232216 :param path: a string or path-like object
233217 :return: a concrete Distribution instance for the path
234218 """
235- return PathDistribution (ensure_is_path (path ))
219+ return PathDistribution (pathlib . Path (path ))
236220
237221 @staticmethod
238222 def _discover_resolvers ():
0 commit comments