mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-23 04:11:28 +08:00
Many importlib removals in py312 (#10644)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
from collections.abc import Mapping, Sequence
|
||||
from importlib.abc import Loader
|
||||
from types import ModuleType
|
||||
@@ -15,6 +16,9 @@ def __import__(
|
||||
|
||||
# `importlib.import_module` return type should be kept the same as `builtins.__import__`
|
||||
def import_module(name: str, package: str | None = None) -> ModuleType: ...
|
||||
def find_loader(name: str, path: str | None = None) -> Loader | None: ...
|
||||
|
||||
if sys.version_info < (3, 12):
|
||||
def find_loader(name: str, path: str | None = None) -> Loader | None: ...
|
||||
|
||||
def invalidate_caches() -> None: ...
|
||||
def reload(module: ModuleType) -> ModuleType: ...
|
||||
|
||||
@@ -20,7 +20,6 @@ from typing_extensions import Literal
|
||||
if sys.version_info >= (3, 11):
|
||||
__all__ = [
|
||||
"Loader",
|
||||
"Finder",
|
||||
"MetaPathFinder",
|
||||
"PathEntryFinder",
|
||||
"ResourceLoader",
|
||||
@@ -28,16 +27,19 @@ if sys.version_info >= (3, 11):
|
||||
"ExecutionLoader",
|
||||
"FileLoader",
|
||||
"SourceLoader",
|
||||
"ResourceReader",
|
||||
"Traversable",
|
||||
"TraversableResources",
|
||||
]
|
||||
|
||||
class Finder(metaclass=ABCMeta): ...
|
||||
if sys.version_info < (3, 12):
|
||||
__all__ += ["Finder", "ResourceReader", "Traversable", "TraversableResources"]
|
||||
|
||||
if sys.version_info < (3, 12):
|
||||
class Finder(metaclass=ABCMeta): ...
|
||||
|
||||
class Loader(metaclass=ABCMeta):
|
||||
def load_module(self, fullname: str) -> types.ModuleType: ...
|
||||
def module_repr(self, module: types.ModuleType) -> str: ...
|
||||
if sys.version_info < (3, 12):
|
||||
def module_repr(self, module: types.ModuleType) -> str: ...
|
||||
|
||||
def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ...
|
||||
# Not defined on the actual class for backwards-compatibility reasons,
|
||||
# but expected in new code.
|
||||
@@ -68,21 +70,37 @@ class SourceLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta):
|
||||
def get_source(self, fullname: str) -> str | None: ...
|
||||
def path_stats(self, path: str) -> Mapping[str, Any]: ...
|
||||
|
||||
# Please keep in sync with sys._MetaPathFinder
|
||||
class MetaPathFinder(Finder):
|
||||
def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ...
|
||||
def invalidate_caches(self) -> None: ...
|
||||
# Not defined on the actual class, but expected to exist.
|
||||
def find_spec(
|
||||
self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ...
|
||||
) -> ModuleSpec | None: ...
|
||||
# The base classes differ on 3.12:
|
||||
if sys.version_info >= (3, 12):
|
||||
# Please keep in sync with sys._MetaPathFinder
|
||||
class MetaPathFinder(metaclass=ABCMeta):
|
||||
def invalidate_caches(self) -> None: ...
|
||||
# Not defined on the actual class, but expected to exist.
|
||||
def find_spec(
|
||||
self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ...
|
||||
) -> ModuleSpec | None: ...
|
||||
|
||||
class PathEntryFinder(Finder):
|
||||
def find_module(self, fullname: str) -> Loader | None: ...
|
||||
def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ...
|
||||
def invalidate_caches(self) -> None: ...
|
||||
# Not defined on the actual class, but expected to exist.
|
||||
def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ...
|
||||
class PathEntryFinder(metaclass=ABCMeta):
|
||||
def invalidate_caches(self) -> None: ...
|
||||
# Not defined on the actual class, but expected to exist.
|
||||
def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ...
|
||||
|
||||
else:
|
||||
# Please keep in sync with sys._MetaPathFinder
|
||||
class MetaPathFinder(Finder):
|
||||
def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ...
|
||||
def invalidate_caches(self) -> None: ...
|
||||
# Not defined on the actual class, but expected to exist.
|
||||
def find_spec(
|
||||
self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ...
|
||||
) -> ModuleSpec | None: ...
|
||||
|
||||
class PathEntryFinder(Finder):
|
||||
def find_module(self, fullname: str) -> Loader | None: ...
|
||||
def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ...
|
||||
def invalidate_caches(self) -> None: ...
|
||||
# Not defined on the actual class, but expected to exist.
|
||||
def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ...
|
||||
|
||||
class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta):
|
||||
name: str
|
||||
|
||||
@@ -31,8 +31,10 @@ class ModuleSpec:
|
||||
|
||||
class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
# MetaPathFinder
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
if sys.version_info < (3, 12):
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
|
||||
@classmethod
|
||||
def find_spec(
|
||||
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
|
||||
@@ -47,8 +49,9 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
|
||||
@classmethod
|
||||
def get_source(cls, fullname: str) -> None: ...
|
||||
# Loader
|
||||
@staticmethod
|
||||
def module_repr(module: types.ModuleType) -> str: ...
|
||||
if sys.version_info < (3, 12):
|
||||
@staticmethod
|
||||
def module_repr(module: types.ModuleType) -> str: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
@staticmethod
|
||||
def create_module(spec: ModuleSpec) -> types.ModuleType | None: ...
|
||||
@@ -62,8 +65,10 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
|
||||
|
||||
class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
# MetaPathFinder
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
if sys.version_info < (3, 12):
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
|
||||
@classmethod
|
||||
def find_spec(
|
||||
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
|
||||
@@ -78,8 +83,9 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
@classmethod
|
||||
def get_source(cls, fullname: str) -> None: ...
|
||||
# Loader
|
||||
@staticmethod
|
||||
def module_repr(m: types.ModuleType) -> str: ...
|
||||
if sys.version_info < (3, 12):
|
||||
@staticmethod
|
||||
def module_repr(m: types.ModuleType) -> str: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
@staticmethod
|
||||
def create_module(spec: ModuleSpec) -> types.ModuleType | None: ...
|
||||
@@ -91,8 +97,10 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
def exec_module(module: types.ModuleType) -> None: ...
|
||||
|
||||
class WindowsRegistryFinder(importlib.abc.MetaPathFinder):
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
if sys.version_info < (3, 12):
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
|
||||
@classmethod
|
||||
def find_spec(
|
||||
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
|
||||
@@ -116,8 +124,9 @@ class PathFinder:
|
||||
def find_spec(
|
||||
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
|
||||
) -> ModuleSpec | None: ...
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
if sys.version_info < (3, 12):
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
|
||||
|
||||
SOURCE_SUFFIXES: list[str]
|
||||
DEBUG_BYTECODE_SUFFIXES: list[str]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import importlib.abc
|
||||
import importlib.machinery
|
||||
import sys
|
||||
import types
|
||||
from _typeshed import ReadableBuffer, StrOrBytesPath
|
||||
from collections.abc import Callable
|
||||
@@ -8,9 +9,11 @@ from typing_extensions import ParamSpec
|
||||
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
def module_for_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
|
||||
def set_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
|
||||
def set_package(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
|
||||
if sys.version_info < (3, 12):
|
||||
def module_for_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
|
||||
def set_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
|
||||
def set_package(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
|
||||
|
||||
def resolve_name(name: str, package: str | None) -> str: ...
|
||||
|
||||
MAGIC_NUMBER: bytes
|
||||
|
||||
@@ -11,28 +11,12 @@ enum.EnumType.__call__
|
||||
enum.property.member
|
||||
http.client.HTTPConnection.get_proxy_response_headers
|
||||
imaplib.IMAP4_SSL.__init__
|
||||
importlib.abc.Finder
|
||||
importlib.abc.Loader.module_repr
|
||||
importlib.abc.MetaPathFinder.find_module
|
||||
importlib.abc.PathEntryFinder.find_loader
|
||||
importlib.abc.PathEntryFinder.find_module
|
||||
importlib.abc.__all__
|
||||
importlib.find_loader
|
||||
importlib.machinery.BuiltinImporter.find_module
|
||||
importlib.machinery.BuiltinImporter.module_repr
|
||||
importlib.machinery.FrozenImporter.find_module
|
||||
importlib.machinery.FrozenImporter.module_repr
|
||||
importlib.machinery.PathFinder.find_module
|
||||
importlib.machinery.WindowsRegistryFinder.find_module
|
||||
importlib.metadata.PackageMetadata.get
|
||||
importlib.metadata.SelectableGroups
|
||||
importlib.metadata._meta.PackageMetadata.get
|
||||
importlib.metadata._meta.SimplePath.__truediv__
|
||||
importlib.metadata._meta.SimplePath.parent
|
||||
importlib.resources.files
|
||||
importlib.util.module_for_loader
|
||||
importlib.util.set_loader
|
||||
importlib.util.set_package
|
||||
pathlib.Path.__init__
|
||||
pathlib.PurePath.__init__
|
||||
pathlib.PurePath.is_relative_to
|
||||
|
||||
Reference in New Issue
Block a user