Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 84dfa4a

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

2 files changed

+16-13Lines changed: 16 additions & 13 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎stdlib/@tests/stubtest_allowlists/common.txt‎

Copy file name to clipboardExpand all lines: stdlib/@tests/stubtest_allowlists/common.txt
+14-11Lines 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
Collapse file

‎stdlib/_frozen_importlib_external.pyi‎

Copy file name to clipboardExpand all lines: stdlib/_frozen_importlib_external.pyi
+2-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.