Skip to content

Commit 7df870f

Browse files
authored
Run stubtest for Python 3.12 (#10253)
1 parent 03f1577 commit 7df870f

28 files changed

+711
-212
lines changed

.github/workflows/stubtest_stdlib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
matrix:
3333
# tkinter doesn't import on macOS 12
3434
os: ["ubuntu-latest", "windows-latest", "macos-11"]
35-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
35+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
3636
fail-fast: false
3737

3838
steps:

stdlib/builtins.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ from typing import ( # noqa: Y022
5353
overload,
5454
type_check_only,
5555
)
56-
from typing_extensions import (
56+
from typing_extensions import ( # type: ignore
5757
Concatenate,
5858
Literal,
5959
LiteralString,
@@ -465,7 +465,7 @@ class str(Sequence[str]):
465465
@overload
466466
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
467467
@overload
468-
def format(self, *args: object, **kwargs: object) -> str: ...
468+
def format(self, *args: object, **kwargs: object) -> str: ... # type: ignore
469469
def format_map(self, map: _FormatMapMapping) -> str: ...
470470
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
471471
def isalnum(self) -> bool: ...
@@ -595,7 +595,7 @@ class str(Sequence[str]):
595595
@overload
596596
def __mod__(self: LiteralString, __value: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
597597
@overload
598-
def __mod__(self, __value: Any) -> str: ...
598+
def __mod__(self, __value: Any) -> str: ... # type: ignore
599599
@overload
600600
def __mul__(self: LiteralString, __value: SupportsIndex) -> LiteralString: ...
601601
@overload

tests/stubtest_allowlists/darwin-py310.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ _?curses.color_pair
1111
# ==========
1212
# Allowlist entries that cannot or should not be fixed
1313
# ==========
14-
15-
distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
_?curses.color_pair
2+
_curses.unget_wch
3+
_curses.window.get_wch
4+
_posixsubprocess.fork_exec
5+
_socket.ETHERTYPE_ARP
6+
_socket.ETHERTYPE_IP
7+
_socket.ETHERTYPE_IPV6
8+
_socket.ETHERTYPE_VLAN
9+
_socket.IP_ADD_SOURCE_MEMBERSHIP
10+
_socket.IP_BLOCK_SOURCE
11+
_socket.IP_DROP_SOURCE_MEMBERSHIP
12+
_socket.IP_PKTINFO
13+
_socket.IP_UNBLOCK_SOURCE
14+
curses.unget_wch
15+
curses.window.get_wch
16+
os.PRIO_DARWIN_BG
17+
os.PRIO_DARWIN_NONUI
18+
os.PRIO_DARWIN_PROCESS
19+
os.PRIO_DARWIN_THREAD
20+
posix.DirEntry.is_junction
21+
posix.PRIO_DARWIN_BG
22+
posix.PRIO_DARWIN_NONUI
23+
posix.PRIO_DARWIN_PROCESS
24+
posix.PRIO_DARWIN_THREAD
25+
socket.ETHERTYPE_ARP
26+
socket.ETHERTYPE_IP
27+
socket.ETHERTYPE_IPV6
28+
socket.ETHERTYPE_VLAN
29+
socket.IP_ADD_SOURCE_MEMBERSHIP
30+
socket.IP_BLOCK_SOURCE
31+
socket.IP_DROP_SOURCE_MEMBERSHIP
32+
socket.IP_PKTINFO
33+
socket.IP_UNBLOCK_SOURCE
34+
socket.TCP_CONNECTION_INFO
35+
syslog.LOG_MASK
36+
syslog.LOG_UPTO
37+
syslog.setlogmask
38+
tty.__all__
39+
tty.cfmakecbreak
40+
tty.cfmakeraw
41+
xxlimited.Xxo.x_exports
42+
43+
(dbm.gnu)?
44+
(locale.bind_textdomain_codeset)?
45+
(locale.bindtextdomain)?
46+
(locale.dcgettext)
47+
(locale.dgettext)?
48+
(locale.gettext)?
49+
(locale.textdomain)?

tests/stubtest_allowlists/darwin-py37.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ pwd.getpwnam
55
# Allowlist entries that cannot or should not be fixed
66
# ==========
77

8-
distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
98
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154

tests/stubtest_allowlists/darwin-py38.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/stubtest_allowlists/darwin-py39.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/stubtest_allowlists/darwin.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ select.POLLMSG # system dependent
2727
(termios.[A-Z0-9_]+)?
2828

2929
# Exists at runtime, but missing from stubs
30-
distutils.msvccompiler.MSVCCompiler.get_msvc_paths
31-
distutils.msvccompiler.MSVCCompiler.set_path_env_var
32-
distutils.msvccompiler.MacroExpander
3330
mimetypes.MimeTypes.read_windows_registry
3431
selectors.DefaultSelector.fileno
3532
socket.PF_SYSTEM

tests/stubtest_allowlists/linux-py310.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,3 @@ signal.sigwaitinfo
1818
# ==========
1919
# Allowlist entries that cannot or should not be fixed
2020
# ==========
21-
22-
distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
_?curses.color_pair
2+
_posixsubprocess.fork_exec
3+
(os|posix).CLONE_FILES
4+
(os|posix).CLONE_FS
5+
(os|posix).CLONE_NEWCGROUP
6+
(os|posix).CLONE_NEWIPC
7+
(os|posix).CLONE_NEWNET
8+
(os|posix).CLONE_NEWNS
9+
(os|posix).CLONE_NEWPID
10+
(os|posix).CLONE_NEWUSER
11+
(os|posix).CLONE_NEWUTS
12+
(os|posix).CLONE_SIGHAND
13+
(os|posix).CLONE_SYSVSEM
14+
(os|posix).CLONE_THREAD
15+
(os|posix).CLONE_VM
16+
(os|posix).DirEntry.is_junction
17+
(os|posix).EFD_CLOEXEC
18+
(os|posix).EFD_NONBLOCK
19+
(os|posix).EFD_SEMAPHORE
20+
(os|posix).eventfd
21+
(os|posix).eventfd_read
22+
(os|posix).eventfd_write
23+
(os|posix).sendfile
24+
(os|posix).setns
25+
(os|posix).setresgid
26+
(os|posix).setresuid
27+
(os|posix).splice
28+
(os|posix).SPLICE_F_MORE
29+
(os|posix).SPLICE_F_MOVE
30+
(os|posix).SPLICE_F_NONBLOCK
31+
(os|posix).unshare
32+
fcntl.FICLONE
33+
fcntl.FICLONERANGE
34+
mmap.MAP_STACK
35+
resource.prlimit
36+
signal.sigtimedwait
37+
signal.sigwaitinfo
38+
ssl.OP_ENABLE_KTLS
39+
ssl.Options.OP_ENABLE_KTLS
40+
syslog.LOG_MASK
41+
syslog.LOG_UPTO
42+
syslog.setlogmask
43+
tty.__all__
44+
tty.cfmakecbreak
45+
tty.cfmakeraw
46+
xxlimited.Xxo.x_exports

tests/stubtest_allowlists/linux-py37.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ pwd.getpwnam
55
# Allowlist entries that cannot or should not be fixed
66
# ==========
77

8-
distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
98
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154

tests/stubtest_allowlists/linux-py38.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ select.epoll.register
33
# ==========
44
# Allowlist entries that cannot or should not be fixed
55
# ==========
6-
7-
distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below

tests/stubtest_allowlists/linux-py39.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ select.epoll.register
44
# ==========
55
# Allowlist entries that cannot or should not be fixed
66
# ==========
7-
8-
distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below

tests/stubtest_allowlists/linux.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ socket.[A-Z0-9_]+
1515
errno.[A-Z0-9]+
1616

1717
# Exists at runtime, but missing from stubs
18-
distutils.msvccompiler.MSVCCompiler.get_msvc_paths
19-
distutils.msvccompiler.MSVCCompiler.set_path_env_var
20-
distutils.msvccompiler.MacroExpander
2118
mimetypes.MimeTypes.read_windows_registry
2219
selectors.DefaultSelector.fileno
2320
spwd.struct_spwd.sp_nam

tests/stubtest_allowlists/py310.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ asyncio.Future.__init__ # Usually initialized from c object
1313
asyncio.futures.Future.__init__ # Usually initialized from c object
1414
builtins.float.__setformat__ # Internal method for CPython test suite
1515
builtins.property.__set_name__ # Doesn't actually exist
16+
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
17+
configparser.ParsingError.filename
1618
contextlib.AbstractAsyncContextManager.__class_getitem__
1719
contextlib.AbstractContextManager.__class_getitem__
20+
enum.Enum._generate_next_value_
1821
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
1922
functools.cached_property.__set__ # Stub is a white lie; see comments in the stub
2023
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
2124
gettext.install
2225
gettext.translation
2326
hmac.new # Stub is a white lie; see comments in the stub
27+
importlib.abc.Finder.find_module
2428
importlib.metadata._meta.SimplePath.__truediv__ # See comments in the stub
2529
ipaddress.IPv4Interface.hostmask
2630
ipaddress.IPv6Interface.hostmask
@@ -50,6 +54,13 @@ typing._TypedDict.update
5054
typing._TypedDict.values
5155
weakref.ProxyType.__reversed__ # Doesn't really exist
5256
weakref.WeakValueDictionary.update
57+
typing_extensions\.get_original_bases
58+
59+
# Exist at runtime for internal reasons, no need to put them in the stub
60+
typing_extensions\.TypeAliasType\.__call__
61+
typing_extensions\.TypeAliasType\.__init_subclass__
62+
# We call them read-only properties, runtime implementation is slightly different
63+
typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
5364

5465
# Runtime has *args, **kwargs, but will error if any are supplied
5566
unittest.TestCase.__init_subclass__
@@ -183,3 +194,17 @@ typing.NewType.__call__
183194
typing_extensions\.Final
184195
typing\.NamedTuple
185196
typing\.Annotated
197+
198+
# We lie about the existence of these methods
199+
.*.__buffer__
200+
.*.__release_buffer__
201+
202+
# Removed in 3.12
203+
distutils\..*
204+
asyncore.dispatcher.addr
205+
asyncore.dispatcher.handle_accepted
206+
asynchat.async_chat.encoding
207+
asynchat.async_chat.use_encoding
208+
asynchat.find_prefix_at_end
209+
pkgutil.ImpImporter\..*
210+
pkgutil.ImpLoader\..*

tests/stubtest_allowlists/py311.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ _collections_abc.ValuesView.__reversed__
1313
_csv.Reader
1414
_csv.Writer
1515
argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group
16+
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
1617
configparser.LegacyInterpolation.__init__
18+
configparser.ParsingError.filename
19+
enum.Enum._generate_next_value_
1720
enum.Enum.__init__
1821
# TODO: The stub for enum.auto is nothing like the implementation
1922
enum.auto.__init__
@@ -22,6 +25,7 @@ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolv
2225
ftplib.FTP.trust_server_pasv_ipv4_address
2326
functools.cached_property.__set__ # Stub is a white lie; see comments in the stub
2427
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
28+
importlib.abc.Finder.find_module
2529
ipaddress.IPv4Interface.hostmask
2630
ipaddress.IPv6Interface.hostmask
2731
ipaddress._BaseNetwork.broadcast_address
@@ -43,11 +47,18 @@ tkinter._VersionInfoType.__doc__
4347
typing.NewType.__call__
4448
typing.NewType.__mro_entries__
4549
weakref.WeakValueDictionary.update
50+
typing_extensions\.get_original_bases
4651

4752
# Runtime has *args, **kwargs, but will error if any are supplied
4853
unittest.TestCase.__init_subclass__
4954
unittest.case.TestCase.__init_subclass__
5055

56+
# Exist at runtime for internal reasons, no need to put them in the stub
57+
typing_extensions\.TypeAliasType\.__call__
58+
typing_extensions\.TypeAliasType\.__init_subclass__
59+
# We call them read-only properties, runtime implementation is slightly different
60+
typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
61+
5162
# ==========
5263
# Related to positional-only arguments
5364
# ==========
@@ -149,3 +160,17 @@ dataclasses.KW_ONLY
149160
typing.ParamSpec(Args|Kwargs).__origin__
150161
typing\.TypeVar\.__.*__
151162
typing\.ParamSpec\.__.*__
163+
164+
# We lie about the existence of these methods
165+
.*.__buffer__
166+
.*.__release_buffer__
167+
168+
# Removed in 3.12
169+
distutils\..*
170+
asyncore.dispatcher.addr
171+
asyncore.dispatcher.handle_accepted
172+
asynchat.async_chat.encoding
173+
asynchat.async_chat.use_encoding
174+
asynchat.find_prefix_at_end
175+
pkgutil.ImpImporter\..*
176+
pkgutil.ImpLoader\..*

0 commit comments

Comments
 (0)