Skip to content

Commit 84dfa4a

Browse files
authored
Fix FileLoader.get_resource_reader signature (#12946)
Move stubtest allowlist entries to "can't be fixed" section
1 parent 1a4631f commit 84dfa4a

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ _collections_abc.ItemsView.__reversed__
1313
_collections_abc.KeysView.__reversed__
1414
_collections_abc.ValuesView.__reversed__
1515
_ctypes.CFuncPtr # stubtest erroneously thinks it can't be subclassed
16-
_frozen_importlib_external.ExtensionFileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
17-
_frozen_importlib_external.FileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
18-
_frozen_importlib_external.FileLoader.get_resource_reader # Wrapped with _check_name decorator which changes runtime signature
19-
_frozen_importlib_external.FileLoader.load_module # Wrapped with _check_name decorator which changes runtime signature
2016
_threading_local.local.__new__
2117
ast.Bytes.__new__
2218
ast.Ellipsis.__new__
@@ -49,16 +45,9 @@ hmac.new # Stub is a white lie; see comments in the stub
4945
http.HTTPStatus.description # set in __new__
5046
http.HTTPStatus.phrase # set in __new__
5147
http.client.HTTPConnection.response_class # the actual type at runtime is abc.ABCMeta
52-
importlib._bootstrap_external.ExtensionFileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
53-
importlib._bootstrap_external.FileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
54-
importlib._bootstrap_external.FileLoader.get_resource_reader # Wrapped with _check_name decorator which changes runtime signature
55-
importlib._bootstrap_external.FileLoader.load_module # Wrapped with _check_name decorator which changes runtime signature
56-
importlib.abc.FileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
57-
importlib.abc.FileLoader.load_module # Wrapped with _check_name decorator which changes runtime signature
5848
importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility
5949
importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist.
6050
importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist.
61-
importlib.machinery.ExtensionFileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
6251
ipaddress._BaseAddress.is_global
6352
ipaddress._BaseAddress.is_link_local
6453
ipaddress._BaseAddress.is_loopback
@@ -692,3 +681,17 @@ typing(_extensions)?\.IO\.__iter__ # See https://github.com/python/typeshed/com
692681
enum.auto.__or__
693682
enum.auto.__and__
694683
enum.auto.__xor__
684+
685+
# wrapped with _check_name decorator which adds *args, **kwargs
686+
# we have more accurate signatures in the stubs
687+
_frozen_importlib_external.ExtensionFileLoader.get_filename
688+
_frozen_importlib_external.FileLoader.get_filename
689+
_frozen_importlib_external.FileLoader.get_resource_reader
690+
_frozen_importlib_external.FileLoader.load_module
691+
importlib._bootstrap_external.ExtensionFileLoader.get_filename
692+
importlib._bootstrap_external.FileLoader.get_filename
693+
importlib._bootstrap_external.FileLoader.get_resource_reader
694+
importlib._bootstrap_external.FileLoader.load_module
695+
importlib.abc.FileLoader.get_filename
696+
importlib.abc.FileLoader.load_module
697+
importlib.machinery.ExtensionFileLoader.get_filename

stdlib/_frozen_importlib_external.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ class FileLoader:
107107
def get_filename(self, name: str | None = None) -> str: ...
108108
def load_module(self, name: str | None = None) -> types.ModuleType: ...
109109
if sys.version_info >= (3, 10):
110-
def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.FileReader: ...
110+
def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ...
111111
else:
112-
def get_resource_reader(self, module: types.ModuleType) -> Self | None: ...
112+
def get_resource_reader(self, name: str | None = None) -> Self | None: ...
113113
def open_resource(self, resource: str) -> _io.FileIO: ...
114114
def resource_path(self, resource: str) -> str: ...
115115
def is_resource(self, name: str) -> bool: ...

0 commit comments

Comments
 (0)