Skip to content

python 3.10 importlib stubtest fixes #6443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 29, 2021
Merged
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
8 changes: 6 additions & 2 deletions stdlib/importlib/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ if sys.version_info >= (3, 7):
def open_resource(self, resource: StrOrBytesPath) -> IO[bytes]: ...
@abstractmethod
def resource_path(self, resource: StrOrBytesPath) -> str: ...
@abstractmethod
def is_resource(self, name: str) -> bool: ...
if sys.version_info >= (3, 10):
@abstractmethod
def is_resource(self, path: str) -> bool: ...
else:
@abstractmethod
def is_resource(self, name: str) -> bool: ...
@abstractmethod
def contents(self) -> Iterator[str]: ...

Expand Down
31 changes: 23 additions & 8 deletions stdlib/importlib/machinery.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.abc
import sys
import types
from typing import Any, Callable, Sequence

Expand Down Expand Up @@ -41,10 +42,16 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
# Loader
@staticmethod
def module_repr(module: types.ModuleType) -> str: ...
@classmethod
def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ...
@classmethod
def exec_module(cls, module: types.ModuleType) -> None: ...
if sys.version_info >= (3, 10):
@staticmethod
def create_module(spec: ModuleSpec) -> types.ModuleType | None: ...
@staticmethod
def exec_module(module: types.ModuleType) -> None: ...
else:
@classmethod
def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ...
@classmethod
def exec_module(cls, module: types.ModuleType) -> None: ...

class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
# MetaPathFinder
Expand All @@ -66,8 +73,12 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
# Loader
@staticmethod
def module_repr(m: types.ModuleType) -> str: ...
@classmethod
def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ...
if sys.version_info >= (3, 10):
@staticmethod
def create_module(spec: ModuleSpec) -> types.ModuleType | None: ...
else:
@classmethod
def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ...
@staticmethod
def exec_module(module: types.ModuleType) -> None: ...

Expand All @@ -80,8 +91,12 @@ class WindowsRegistryFinder(importlib.abc.MetaPathFinder):
) -> ModuleSpec | None: ...

class PathFinder:
@classmethod
def invalidate_caches(cls) -> None: ...
if sys.version_info >= (3, 10):
@staticmethod
def invalidate_caches() -> None: ...
else:
@classmethod
def invalidate_caches(cls) -> None: ...
@classmethod
def find_spec(
cls, fullname: str, path: Sequence[bytes | str] | None = ..., target: types.ModuleType | None = ...
Expand Down
3 changes: 3 additions & 0 deletions stdlib/importlib/metadata.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ if sys.version_info >= (3, 8):
class MetadataPathFinder(DistributionFinder):
@classmethod
def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ...
if sys.version_info >= (3, 10):
# Yes, this is an instance method that has argumend named "cls"
def invalidate_caches(cls) -> None: ... # type: ignore
class PathDistribution(Distribution):
def __init__(self, path: Path) -> None: ...
def read_text(self, filename: StrPath) -> str: ...
Expand Down
6 changes: 0 additions & 6 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ tkinter.EventType.__new__
_markupbase.ParserBase.error
asyncio.proactor_events._ProactorReadPipeTransport.__init__
distutils.command.bdist_wininst
importlib.abc.ResourceReader.is_resource
importlib.machinery.BuiltinImporter.create_module
importlib.machinery.BuiltinImporter.exec_module
importlib.machinery.FrozenImporter.create_module
importlib.machinery.PathFinder.invalidate_caches
importlib.metadata.MetadataPathFinder.invalidate_caches
logging.Formatter.__init__
logging.LoggerAdapter.__init__
logging.PercentStyle.__init__
Expand Down