Skip to content

Commit cfa025d

Browse files
committed
DistributionFinders are now expected to be instances since MetaPathFinders are expected to be instances (due to non-class methods).
1 parent e239c9b commit cfa025d

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

importlib_metadata/_hooks.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def install(cls):
2525
"""Class decorator for installation on sys.meta_path."""
26-
sys.meta_path.append(cls)
26+
sys.meta_path.append(cls())
2727
return cls
2828

2929

@@ -54,8 +54,7 @@ class MetadataPathFinder(NullFinder):
5454
"""
5555
search_template = r'{pattern}(-.*)?\.(dist|egg)-info'
5656

57-
@classmethod
58-
def find_distributions(cls, name=None, path=None):
57+
def find_distributions(self, name=None, path=None):
5958
"""Return an iterable of all Distribution instances capable of
6059
loading the metadata for packages matching the name
6160
(or all names if not supplied) along the paths in the list
@@ -64,7 +63,7 @@ def find_distributions(cls, name=None, path=None):
6463
if path is None:
6564
path = sys.path
6665
pattern = '.*' if name is None else re.escape(name)
67-
found = cls._search_paths(pattern, path)
66+
found = self._search_paths(pattern, path)
6867
return map(PathDistribution, found)
6968

7069
@classmethod
@@ -119,8 +118,7 @@ class WheelMetadataFinder(NullFinder):
119118
"""
120119
search_template = r'{pattern}(-.*)?\.whl'
121120

122-
@classmethod
123-
def find_distributions(cls, name=None, path=None):
121+
def find_distributions(self, name=None, path=None):
124122
"""Return an iterable of all Distribution instances capable of
125123
loading the metadata for packages matching the name
126124
(or all names if not supplied) along the paths in the list
@@ -129,7 +127,7 @@ def find_distributions(cls, name=None, path=None):
129127
if path is None:
130128
path = sys.path
131129
pattern = '.*' if name is None else re.escape(name)
132-
found = cls._search_paths(pattern, path)
130+
found = self._search_paths(pattern, path)
133131
return map(WheelDistribution, found)
134132

135133
@classmethod

importlib_metadata/abc.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,17 @@
66

77
if sys.version_info >= (3,): # pragma: nocover
88
from importlib.abc import MetaPathFinder
9-
10-
def abstractclassmethod(func):
11-
return classmethod(abc.abstractmethod(func))
129
else: # pragma: nocover
1310
from abc import ABCMeta as MetaPathFinder
1411

15-
class abstractclassmethod(classmethod):
16-
__isabstractmethod__ = True
17-
18-
def __init__(self, callable):
19-
callable.__isabstractmethod__ = True
20-
super(abstractclassmethod, self).__init__(callable)
21-
2212

2313
class DistributionFinder(MetaPathFinder):
2414
"""
2515
A MetaPathFinder capable of discovering installed distributions.
2616
"""
2717

28-
@abstractclassmethod
29-
def find_distributions(cls, name=None, path=None):
18+
@abc.abstractmethod
19+
def find_distributions(self, name=None, path=None):
3020
"""
3121
Return an iterable of all Distribution instances capable of
3222
loading the metadata for packages matching the name

0 commit comments

Comments
 (0)