Skip to content

Commit

Permalink
Run stubtest for Python 3.12 (python#10253)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja authored Jun 4, 2023
1 parent 03f1577 commit 7df870f
Show file tree
Hide file tree
Showing 28 changed files with 711 additions and 212 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/stubtest_stdlib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
matrix:
# tkinter doesn't import on macOS 12
os: ["ubuntu-latest", "windows-latest", "macos-11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
fail-fast: false

steps:
Expand Down
6 changes: 3 additions & 3 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ from typing import ( # noqa: Y022
overload,
type_check_only,
)
from typing_extensions import (
from typing_extensions import ( # type: ignore
Concatenate,
Literal,
LiteralString,
Expand Down Expand Up @@ -465,7 +465,7 @@ class str(Sequence[str]):
@overload
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
@overload
def format(self, *args: object, **kwargs: object) -> str: ...
def format(self, *args: object, **kwargs: object) -> str: ... # type: ignore
def format_map(self, map: _FormatMapMapping) -> str: ...
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
def isalnum(self) -> bool: ...
Expand Down Expand Up @@ -595,7 +595,7 @@ class str(Sequence[str]):
@overload
def __mod__(self: LiteralString, __value: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
@overload
def __mod__(self, __value: Any) -> str: ...
def __mod__(self, __value: Any) -> str: ... # type: ignore
@overload
def __mul__(self: LiteralString, __value: SupportsIndex) -> LiteralString: ...
@overload
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/darwin-py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ _?curses.color_pair
# ==========
# Allowlist entries that cannot or should not be fixed
# ==========

distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
49 changes: 49 additions & 0 deletions tests/stubtest_allowlists/darwin-py312.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
_?curses.color_pair
_curses.unget_wch
_curses.window.get_wch
_posixsubprocess.fork_exec
_socket.ETHERTYPE_ARP
_socket.ETHERTYPE_IP
_socket.ETHERTYPE_IPV6
_socket.ETHERTYPE_VLAN
_socket.IP_ADD_SOURCE_MEMBERSHIP
_socket.IP_BLOCK_SOURCE
_socket.IP_DROP_SOURCE_MEMBERSHIP
_socket.IP_PKTINFO
_socket.IP_UNBLOCK_SOURCE
curses.unget_wch
curses.window.get_wch
os.PRIO_DARWIN_BG
os.PRIO_DARWIN_NONUI
os.PRIO_DARWIN_PROCESS
os.PRIO_DARWIN_THREAD
posix.DirEntry.is_junction
posix.PRIO_DARWIN_BG
posix.PRIO_DARWIN_NONUI
posix.PRIO_DARWIN_PROCESS
posix.PRIO_DARWIN_THREAD
socket.ETHERTYPE_ARP
socket.ETHERTYPE_IP
socket.ETHERTYPE_IPV6
socket.ETHERTYPE_VLAN
socket.IP_ADD_SOURCE_MEMBERSHIP
socket.IP_BLOCK_SOURCE
socket.IP_DROP_SOURCE_MEMBERSHIP
socket.IP_PKTINFO
socket.IP_UNBLOCK_SOURCE
socket.TCP_CONNECTION_INFO
syslog.LOG_MASK
syslog.LOG_UPTO
syslog.setlogmask
tty.__all__
tty.cfmakecbreak
tty.cfmakeraw
xxlimited.Xxo.x_exports

(dbm.gnu)?
(locale.bind_textdomain_codeset)?
(locale.bindtextdomain)?
(locale.dcgettext)
(locale.dgettext)?
(locale.gettext)?
(locale.textdomain)?
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/darwin-py37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ pwd.getpwnam
# Allowlist entries that cannot or should not be fixed
# ==========

distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
5 changes: 0 additions & 5 deletions tests/stubtest_allowlists/darwin-py38.txt

This file was deleted.

5 changes: 0 additions & 5 deletions tests/stubtest_allowlists/darwin-py39.txt

This file was deleted.

3 changes: 0 additions & 3 deletions tests/stubtest_allowlists/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ select.POLLMSG # system dependent
(termios.[A-Z0-9_]+)?

# Exists at runtime, but missing from stubs
distutils.msvccompiler.MSVCCompiler.get_msvc_paths
distutils.msvccompiler.MSVCCompiler.set_path_env_var
distutils.msvccompiler.MacroExpander
mimetypes.MimeTypes.read_windows_registry
selectors.DefaultSelector.fileno
socket.PF_SYSTEM
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/linux-py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ signal.sigwaitinfo
# ==========
# Allowlist entries that cannot or should not be fixed
# ==========

distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
46 changes: 46 additions & 0 deletions tests/stubtest_allowlists/linux-py312.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
_?curses.color_pair
_posixsubprocess.fork_exec
(os|posix).CLONE_FILES
(os|posix).CLONE_FS
(os|posix).CLONE_NEWCGROUP
(os|posix).CLONE_NEWIPC
(os|posix).CLONE_NEWNET
(os|posix).CLONE_NEWNS
(os|posix).CLONE_NEWPID
(os|posix).CLONE_NEWUSER
(os|posix).CLONE_NEWUTS
(os|posix).CLONE_SIGHAND
(os|posix).CLONE_SYSVSEM
(os|posix).CLONE_THREAD
(os|posix).CLONE_VM
(os|posix).DirEntry.is_junction
(os|posix).EFD_CLOEXEC
(os|posix).EFD_NONBLOCK
(os|posix).EFD_SEMAPHORE
(os|posix).eventfd
(os|posix).eventfd_read
(os|posix).eventfd_write
(os|posix).sendfile
(os|posix).setns
(os|posix).setresgid
(os|posix).setresuid
(os|posix).splice
(os|posix).SPLICE_F_MORE
(os|posix).SPLICE_F_MOVE
(os|posix).SPLICE_F_NONBLOCK
(os|posix).unshare
fcntl.FICLONE
fcntl.FICLONERANGE
mmap.MAP_STACK
resource.prlimit
signal.sigtimedwait
signal.sigwaitinfo
ssl.OP_ENABLE_KTLS
ssl.Options.OP_ENABLE_KTLS
syslog.LOG_MASK
syslog.LOG_UPTO
syslog.setlogmask
tty.__all__
tty.cfmakecbreak
tty.cfmakeraw
xxlimited.Xxo.x_exports
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/linux-py37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ pwd.getpwnam
# Allowlist entries that cannot or should not be fixed
# ==========

distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/linux-py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ select.epoll.register
# ==========
# Allowlist entries that cannot or should not be fixed
# ==========

distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/linux-py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ select.epoll.register
# ==========
# Allowlist entries that cannot or should not be fixed
# ==========

distutils.command.bdist_msi # Only available on Windows and Python 3.10 and below
3 changes: 0 additions & 3 deletions tests/stubtest_allowlists/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ socket.[A-Z0-9_]+
errno.[A-Z0-9]+

# Exists at runtime, but missing from stubs
distutils.msvccompiler.MSVCCompiler.get_msvc_paths
distutils.msvccompiler.MSVCCompiler.set_path_env_var
distutils.msvccompiler.MacroExpander
mimetypes.MimeTypes.read_windows_registry
selectors.DefaultSelector.fileno
spwd.struct_spwd.sp_nam
Expand Down
25 changes: 25 additions & 0 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ asyncio.Future.__init__ # Usually initialized from c object
asyncio.futures.Future.__init__ # Usually initialized from c object
builtins.float.__setformat__ # Internal method for CPython test suite
builtins.property.__set_name__ # Doesn't actually exist
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
configparser.ParsingError.filename
contextlib.AbstractAsyncContextManager.__class_getitem__
contextlib.AbstractContextManager.__class_getitem__
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
functools.cached_property.__set__ # Stub is a white lie; see comments in the stub
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
gettext.install
gettext.translation
hmac.new # Stub is a white lie; see comments in the stub
importlib.abc.Finder.find_module
importlib.metadata._meta.SimplePath.__truediv__ # See comments in the stub
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
Expand Down Expand Up @@ -50,6 +54,13 @@ typing._TypedDict.update
typing._TypedDict.values
weakref.ProxyType.__reversed__ # Doesn't really exist
weakref.WeakValueDictionary.update
typing_extensions\.get_original_bases

# Exist at runtime for internal reasons, no need to put them in the stub
typing_extensions\.TypeAliasType\.__call__
typing_extensions\.TypeAliasType\.__init_subclass__
# We call them read-only properties, runtime implementation is slightly different
typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__

# Runtime has *args, **kwargs, but will error if any are supplied
unittest.TestCase.__init_subclass__
Expand Down Expand Up @@ -183,3 +194,17 @@ typing.NewType.__call__
typing_extensions\.Final
typing\.NamedTuple
typing\.Annotated

# We lie about the existence of these methods
.*.__buffer__
.*.__release_buffer__

# Removed in 3.12
distutils\..*
asyncore.dispatcher.addr
asyncore.dispatcher.handle_accepted
asynchat.async_chat.encoding
asynchat.async_chat.use_encoding
asynchat.find_prefix_at_end
pkgutil.ImpImporter\..*
pkgutil.ImpLoader\..*
25 changes: 25 additions & 0 deletions tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ _collections_abc.ValuesView.__reversed__
_csv.Reader
_csv.Writer
argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
configparser.LegacyInterpolation.__init__
configparser.ParsingError.filename
enum.Enum._generate_next_value_
enum.Enum.__init__
# TODO: The stub for enum.auto is nothing like the implementation
enum.auto.__init__
Expand All @@ -22,6 +25,7 @@ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolv
ftplib.FTP.trust_server_pasv_ipv4_address
functools.cached_property.__set__ # Stub is a white lie; see comments in the stub
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
importlib.abc.Finder.find_module
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
ipaddress._BaseNetwork.broadcast_address
Expand All @@ -43,11 +47,18 @@ tkinter._VersionInfoType.__doc__
typing.NewType.__call__
typing.NewType.__mro_entries__
weakref.WeakValueDictionary.update
typing_extensions\.get_original_bases

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

# Exist at runtime for internal reasons, no need to put them in the stub
typing_extensions\.TypeAliasType\.__call__
typing_extensions\.TypeAliasType\.__init_subclass__
# We call them read-only properties, runtime implementation is slightly different
typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__

# ==========
# Related to positional-only arguments
# ==========
Expand Down Expand Up @@ -149,3 +160,17 @@ dataclasses.KW_ONLY
typing.ParamSpec(Args|Kwargs).__origin__
typing\.TypeVar\.__.*__
typing\.ParamSpec\.__.*__

# We lie about the existence of these methods
.*.__buffer__
.*.__release_buffer__

# Removed in 3.12
distutils\..*
asyncore.dispatcher.addr
asyncore.dispatcher.handle_accepted
asynchat.async_chat.encoding
asynchat.async_chat.use_encoding
asynchat.find_prefix_at_end
pkgutil.ImpImporter\..*
pkgutil.ImpLoader\..*
Loading

0 comments on commit 7df870f

Please sign in to comment.