◐ Shell
clean mode source ↗

GH-63062: Implement __subclasshook__() for Finders and Loaders in abc lib by furkanonder · Pull Request #102763 · python/cpython

Expand Up @@ -86,6 +86,14 @@ class ResourceLoader(Loader):
"""
@classmethod def __subclasshook__(cls, C): if cls is ResourceLoader: if (Loader.__subclasshook__(C) and any('get_data' in B.__dict__ for B in C.__mro__)): return True return NotImplemented
@abc.abstractmethod def get_data(self, path): """Abstract method which when implemented should return the bytes for Expand All @@ -102,11 +110,24 @@ class InspectLoader(Loader):
"""
@classmethod def __subclasshook__(cls, C): if cls is InspectLoader: if (Loader.__subclasshook__(C) and any('is_package' in B.__dict__ for B in C.__mro__) and any('get_code' in B.__dict__ for B in C.__mro__) and any('get_source' in B.__dict__ for B in C.__mro__) and any('source_to_code' in B.__dict__ for B in C.__mro__)): return True return NotImplemented
def is_package(self, fullname): """Optional method which when implemented should return whether the module is a package. The fullname is a str. Returns a bool. """(abstract) Return whether the module is a package.
The fullname is a str.
Raises ImportError if the module cannot be found.
""" raise ImportError
Expand Down