Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/importlib/_abc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Subset of importlib.abc used to reduce importlib.util imports."""
from . import _bootstrap
import abc
from typing import Protocol, runtime_checkable


class Loader(metaclass=abc.ABCMeta):
@runtime_checkable
class Loader(Protocol):

"""Abstract base class for import loaders."""

Expand Down
6 changes: 4 additions & 2 deletions Lib/importlib/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def _register(abstract_cls, *classes):
abstract_cls.register(frozen_cls)


class Finder(metaclass=abc.ABCMeta):
@runtime_checkable
class Finder(Protocol):

"""Legacy abstract base class for import finders.

Expand Down Expand Up @@ -297,7 +298,8 @@ def set_data(self, path, data):
_register(SourceLoader, machinery.SourceFileLoader)


class ResourceReader(metaclass=abc.ABCMeta):
@runtime_checkable
class ResourceReader(Protocol):

"""Abstract base class to provide resource-reading support.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use :class:`typing.Protocol` in the :mod:`importlib.abc` module.