mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Fix importlib stubtest exceptions (#5148)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
@@ -58,7 +58,8 @@ class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta):
|
||||
path: _Path
|
||||
def __init__(self, fullname: str, path: _Path) -> None: ...
|
||||
def get_data(self, path: _Path) -> bytes: ...
|
||||
def get_filename(self, fullname: str) -> _Path: ...
|
||||
def get_filename(self, name: Optional[str] = ...) -> _Path: ...
|
||||
def load_module(self, name: Optional[str] = ...) -> types.ModuleType: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
_PathLike = Union[bytes, str, os.PathLike[Any]]
|
||||
|
||||
@@ -9,10 +9,12 @@ from _importlib_modulespec import Loader, ModuleSpec as ModuleSpec # Exported
|
||||
class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
# MetaPathFinder
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]]) -> Optional[importlib.abc.Loader]: ...
|
||||
def find_module(
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ...
|
||||
) -> Optional[importlib.abc.Loader]: ...
|
||||
@classmethod
|
||||
def find_spec(
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]], target: Optional[types.ModuleType] = ...
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ..., target: Optional[types.ModuleType] = ...
|
||||
) -> Optional[ModuleSpec]: ...
|
||||
# InspectLoader
|
||||
@classmethod
|
||||
@@ -34,10 +36,12 @@ 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: Optional[Sequence[importlib.abc._Path]]) -> Optional[importlib.abc.Loader]: ...
|
||||
def find_module(
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ...
|
||||
) -> Optional[importlib.abc.Loader]: ...
|
||||
@classmethod
|
||||
def find_spec(
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]], target: Optional[types.ModuleType] = ...
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ..., target: Optional[types.ModuleType] = ...
|
||||
) -> Optional[ModuleSpec]: ...
|
||||
# InspectLoader
|
||||
@classmethod
|
||||
@@ -50,7 +54,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
def get_source(cls, fullname: str) -> None: ...
|
||||
# Loader
|
||||
@staticmethod
|
||||
def module_repr(module: types.ModuleType) -> str: ...
|
||||
def module_repr(m: types.ModuleType) -> str: ...
|
||||
@classmethod
|
||||
def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: ...
|
||||
@staticmethod
|
||||
@@ -58,10 +62,12 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
|
||||
|
||||
class WindowsRegistryFinder(importlib.abc.MetaPathFinder):
|
||||
@classmethod
|
||||
def find_module(cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]]) -> Optional[importlib.abc.Loader]: ...
|
||||
def find_module(
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ...
|
||||
) -> Optional[importlib.abc.Loader]: ...
|
||||
@classmethod
|
||||
def find_spec(
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]], target: Optional[types.ModuleType] = ...
|
||||
cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ..., target: Optional[types.ModuleType] = ...
|
||||
) -> Optional[ModuleSpec]: ...
|
||||
|
||||
class PathFinder:
|
||||
@@ -90,9 +96,12 @@ class FileFinder(importlib.abc.PathEntryFinder):
|
||||
cls, *loader_details: Tuple[importlib.abc.Loader, List[str]]
|
||||
) -> Callable[[str], importlib.abc.PathEntryFinder]: ...
|
||||
|
||||
class SourceFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader): ...
|
||||
class SourceFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader):
|
||||
def set_data(self, path: importlib.abc._Path, data: bytes, *, _mode: int = ...) -> None: ...
|
||||
|
||||
class SourcelessFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader): ...
|
||||
|
||||
class ExtensionFileLoader(importlib.abc.ExecutionLoader):
|
||||
def get_filename(self, fullname: str) -> importlib.abc._Path: ...
|
||||
def __init__(self, name: str, path: importlib.abc._Path) -> None: ...
|
||||
def get_filename(self, name: Optional[str] = ...) -> importlib.abc._Path: ...
|
||||
def get_source(self, fullname: str) -> None: ...
|
||||
|
||||
@@ -9,11 +9,11 @@ from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Tuple, Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class PackageNotFoundError(ModuleNotFoundError): ...
|
||||
class EntryPointBase(NamedTuple):
|
||||
class _EntryPointBase(NamedTuple):
|
||||
name: str
|
||||
value: str
|
||||
group: str
|
||||
class EntryPoint(EntryPointBase):
|
||||
class EntryPoint(_EntryPointBase):
|
||||
def load(self) -> Any: ... # Callable[[], Any] or an importable module
|
||||
@property
|
||||
def extras(self) -> List[str]: ...
|
||||
@@ -62,8 +62,6 @@ if sys.version_info >= (3, 8):
|
||||
def __init__(self, *, name: Optional[str] = ..., path: List[str] = ..., **kwargs: Any) -> None: ...
|
||||
@property
|
||||
def path(self) -> List[str]: ...
|
||||
@property
|
||||
def pattern(self) -> str: ...
|
||||
@abc.abstractmethod
|
||||
def find_distributions(self, context: DistributionFinder.Context = ...) -> Iterable[Distribution]: ...
|
||||
class MetadataPathFinder(DistributionFinder):
|
||||
|
||||
@@ -20,12 +20,11 @@ def spec_from_loader(
|
||||
loader: Optional[importlib.abc.Loader],
|
||||
*,
|
||||
origin: Optional[str] = ...,
|
||||
loader_state: Optional[Any] = ...,
|
||||
is_package: Optional[bool] = ...,
|
||||
) -> importlib.machinery.ModuleSpec: ...
|
||||
def spec_from_file_location(
|
||||
name: str,
|
||||
location: Union[str, bytes, os.PathLike[str], os.PathLike[bytes]],
|
||||
location: Optional[Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]] = ...,
|
||||
*,
|
||||
loader: Optional[importlib.abc.Loader] = ...,
|
||||
submodule_search_locations: Optional[List[str]] = ...,
|
||||
|
||||
@@ -25,8 +25,8 @@ email.message.MIMEPart.as_string
|
||||
enum.Enum._generate_next_value_
|
||||
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
|
||||
hmac.HMAC.__init__
|
||||
importlib.metadata
|
||||
importlib.resources
|
||||
importlib.metadata # Added in 3.8
|
||||
importlib.resources # Added in 3.7
|
||||
io.StringIO.readline
|
||||
ipaddress._BaseNetwork.__init__
|
||||
itertools.accumulate
|
||||
|
||||
@@ -37,7 +37,7 @@ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolv
|
||||
hmac.HMAC.__init__
|
||||
http.client.HTTPSConnection.__init__
|
||||
http.server.SimpleHTTPRequestHandler.__init__
|
||||
importlib.metadata
|
||||
importlib.metadata # Added in 3.8
|
||||
ipaddress._BaseNetwork.__init__
|
||||
itertools.accumulate
|
||||
json.loads
|
||||
|
||||
@@ -56,8 +56,6 @@ hmac.new # Stub is a white lie; see comments in the stub
|
||||
http.client.HTTPSConnection.__init__
|
||||
http.cookiejar.DefaultCookiePolicy.__init__
|
||||
http.server.SimpleHTTPRequestHandler.__init__
|
||||
importlib.metadata.DistributionFinder.Context.pattern
|
||||
importlib.metadata.EntryPointBase
|
||||
ipaddress.IPv4Interface.hostmask
|
||||
ipaddress.IPv6Interface.hostmask
|
||||
ipaddress._BaseNetwork.broadcast_address
|
||||
|
||||
@@ -67,8 +67,6 @@ http.client.HTTPSConnection.__init__
|
||||
http.cookiejar.DefaultCookiePolicy.__init__
|
||||
http.server.SimpleHTTPRequestHandler.__init__
|
||||
importlib.abc.Traversable.__init__ # Inherits __init__ from typing.Protocol
|
||||
importlib.metadata.DistributionFinder.Context.pattern
|
||||
importlib.metadata.EntryPointBase
|
||||
ipaddress.IPv4Interface.hostmask
|
||||
ipaddress.IPv6Interface.hostmask
|
||||
ipaddress._BaseNetwork.broadcast_address
|
||||
|
||||
@@ -192,22 +192,12 @@ http.cookies.Morsel.setdefault
|
||||
http.cookies.Morsel.update
|
||||
http.server.HTTPServer.__init__
|
||||
imaplib.IMAP4_SSL.ssl
|
||||
importlib.abc.FileLoader.get_filename
|
||||
importlib.abc.Loader.exec_module
|
||||
importlib.abc.MetaPathFinder.find_spec
|
||||
importlib.abc.PathEntryFinder.find_spec
|
||||
importlib.machinery.BuiltinImporter.find_module
|
||||
importlib.machinery.BuiltinImporter.find_spec
|
||||
importlib.machinery.ExtensionFileLoader.__init__
|
||||
importlib.machinery.ExtensionFileLoader.get_filename
|
||||
importlib.machinery.FrozenImporter.find_module
|
||||
importlib.machinery.FrozenImporter.find_spec
|
||||
importlib.machinery.FrozenImporter.module_repr
|
||||
importlib.machinery.SourceFileLoader.set_data
|
||||
importlib.machinery.WindowsRegistryFinder.find_module
|
||||
importlib.machinery.WindowsRegistryFinder.find_spec
|
||||
importlib.util.spec_from_file_location
|
||||
importlib.util.spec_from_loader
|
||||
importlib.abc.FileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
|
||||
importlib.abc.FileLoader.load_module # Wrapped with _check_name decorator which changes runtime signature
|
||||
importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatability
|
||||
importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist.
|
||||
importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist.
|
||||
importlib.machinery.ExtensionFileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
|
||||
inspect.Parameter.KEYWORD_ONLY
|
||||
inspect.Parameter.POSITIONAL_ONLY
|
||||
inspect.Parameter.POSITIONAL_OR_KEYWORD
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
importlib.metadata.DistributionFinder.Context.pattern
|
||||
|
||||
Reference in New Issue
Block a user