Skip to content

Commit 1d47c6f

Browse files
elazarggvanrossum
authored andcommitted
Directly import ABCMeta (and abstractmethod) from abc (#640)
This change is needed for mypy/#2365.
1 parent 7a623f2 commit 1d47c6f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

stdlib/3/_importlib_modulespec.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# - Loader in importlib.abc
66
# - ModuleSpec in importlib.machinery (3.4 and later only)
77

8-
import abc
8+
from abc import ABCMeta
99
import sys
1010
from typing import Any, Optional
1111

@@ -33,7 +33,7 @@ class ModuleType:
3333
__spec__ = ... # type: Optional[ModuleSpec]
3434
def __init__(self, name: str, doc: str) -> None: ...
3535

36-
class Loader(metaclass=abc.ABCMeta):
36+
class Loader(metaclass=ABCMeta):
3737
def load_module(self, fullname: str) -> ModuleType: ...
3838
if sys.version_info >= (3, 3):
3939
def module_repr(self, module: ModuleType) -> str: ...

stdlib/3/importlib/abc.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import abc
1+
from abc import ABCMeta, abstractmethod
22
if sys.version_info >= (3, 4):
33
from _importlib_modulespec import ModuleSpec
44
import sys
@@ -11,23 +11,23 @@ _Path = Union[bytes, str]
1111
# exists in its own stub file (with ModuleSpec and ModuleType).
1212
from _importlib_modulespec import Loader as Loader # Exported
1313

14-
class Finder(metaclass=abc.ABCMeta): ...
14+
class Finder(metaclass=ABCMeta): ...
1515
# Technically this class defines the following method, but its subclasses
1616
# in this module violate its signature. Since this class is deprecated, it's
1717
# easier to simply ignore that this method exists.
18-
#@abc.abstractmethod
18+
#@abstractmethod
1919
#def find_module(self, fullname: str,
2020
# path: Sequence[_Path] = None) -> Optional[Loader]: ...
2121

2222
class ResourceLoader(Loader):
23-
@abc.abstractmethod
23+
@abstractmethod
2424
def get_data(self, path: _Path) -> bytes: ...
2525

2626
class InspectLoader(Loader):
2727
def is_package(self, fullname: str) -> bool: ...
2828
def get_code(self, fullname: str) -> Optional[types.CodeType]: ...
2929
def load_module(self, fullname: str) -> types.ModuleType: ...
30-
@abc.abstractmethod
30+
@abstractmethod
3131
def get_source(self, fullname: str) -> Optional[str]: ...
3232
if sys.version_info >= (3, 4):
3333
def exec_module(self, module: types.ModuleType) -> None: ...
@@ -40,7 +40,7 @@ class InspectLoader(Loader):
4040
path: str = '<string>') -> types.CodeType: ...
4141

4242
class ExecutionLoader(InspectLoader):
43-
@abc.abstractmethod
43+
@abstractmethod
4444
def get_filename(self, fullname: str) -> _Path: ...
4545
def get_code(self, fullname: str) -> Optional[types.CodeType]: ...
4646

0 commit comments

Comments
 (0)