Skip to content

Commit

Permalink
Fix stdlib stubtest for latest Python patch releases (#13464)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Feb 5, 2025
1 parent aac4394 commit 5caaf2e
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 5 deletions.
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ unittest.runner._WritelnDecorator.flush # Methods that come from __getattr__()
unittest.runner._WritelnDecorator.write # Methods that come from __getattr__() at runtime
urllib.response.addbase.write # Methods that come from __getattr__() at runtime
urllib.response.addbase.writelines # Methods that come from __getattr__() at runtime
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
unittest.mock.patch # function with attributes, which we approximate with a callable class

_?weakref\.CallableProxyType\.__getattr__ # Should have all attributes of proxy
Expand Down
1 change: 1 addition & 0 deletions stdlib/@tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ _?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C sign
configparser.ParsingError.filename
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub

Expand Down
1 change: 1 addition & 0 deletions stdlib/@tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ _?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C sign
configparser.ParsingError.filename
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub

Expand Down
1 change: 1 addition & 0 deletions stdlib/@tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ _?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C sign
configparser.ParsingError.filename
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub

Expand Down
2 changes: 1 addition & 1 deletion stdlib/_socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if sys.platform == "win32":
SO_EXCLUSIVEADDRUSE: int
if sys.platform != "win32":
SO_REUSEPORT: int
if sys.platform != "darwin" or sys.version_info >= (3, 13):
if sys.platform != "darwin":
SO_BINDTODEVICE: int

if sys.platform != "win32" and sys.platform != "darwin":
Expand Down
7 changes: 6 additions & 1 deletion stdlib/bdb.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from _typeshed import ExcInfo, TraceFunction, Unused
from collections.abc import Callable, Iterable, Mapping
from collections.abc import Callable, Iterable, Iterator, Mapping
from contextlib import contextmanager
from types import CodeType, FrameType, TracebackType
from typing import IO, Any, Final, SupportsInt, TypeVar
from typing_extensions import ParamSpec
Expand Down Expand Up @@ -30,6 +31,10 @@ class Bdb:
def __init__(self, skip: Iterable[str] | None = None) -> None: ...
def canonic(self, filename: str) -> str: ...
def reset(self) -> None: ...
if sys.version_info >= (3, 12):
@contextmanager
def set_enterframe(self, frame: FrameType) -> Iterator[None]: ...

def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> TraceFunction: ...
def dispatch_line(self, frame: FrameType) -> TraceFunction: ...
def dispatch_call(self, frame: FrameType, arg: None) -> TraceFunction: ...
Expand Down
4 changes: 4 additions & 0 deletions stdlib/email/_header_value_parser.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from collections.abc import Iterable, Iterator
from email.errors import HeaderParseError, MessageDefect
from email.policy import Policy
Expand All @@ -21,6 +22,9 @@ NLSET: Final[set[str]]
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
SPECIALSNL: Final[set[str]]

if sys.version_info >= (3, 12):
def make_quoted_pairs(value: Any) -> str: ...

def quote_string(value: Any) -> str: ...

rfc2047_matcher: Pattern[str]
Expand Down
6 changes: 5 additions & 1 deletion stdlib/enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ if sys.version_info >= (3, 11):
def __init__(self, value: _EnumMemberT) -> None: ...

class _EnumDict(dict[str, Any]):
def __init__(self) -> None: ...
if sys.version_info >= (3, 13):
def __init__(self, cls_name: str | None = None) -> None: ...
else:
def __init__(self) -> None: ...

def __setitem__(self, key: str, value: Any) -> None: ...
if sys.version_info >= (3, 11):
# See comment above `typing.MutableMapping.update`
Expand Down
4 changes: 4 additions & 0 deletions stdlib/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 12):
"CLONE_VM",
"setns",
"unshare",
"PIDFD_NONBLOCK",
]
if sys.platform == "linux" and sys.version_info >= (3, 10):
__all__ += [
Expand Down Expand Up @@ -1603,6 +1604,9 @@ if sys.version_info >= (3, 9):
if sys.platform == "linux":
def pidfd_open(pid: int, flags: int = ...) -> int: ...

if sys.version_info >= (3, 12) and sys.platform == "linux":
PIDFD_NONBLOCK: Final = 2048

if sys.version_info >= (3, 12) and sys.platform == "win32":
def listdrives() -> list[str]: ...
def listmounts(volume: str) -> list[str]: ...
Expand Down
1 change: 1 addition & 0 deletions stdlib/posix.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ if sys.platform != "win32":
CLONE_SYSVSEM as CLONE_SYSVSEM,
CLONE_THREAD as CLONE_THREAD,
CLONE_VM as CLONE_VM,
PIDFD_NONBLOCK as PIDFD_NONBLOCK,
setns as setns,
unshare as unshare,
)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ if sys.platform != "win32":
"IPV6_RTHDRDSTOPTS",
]

if sys.platform != "darwin" or sys.version_info >= (3, 13):
if sys.platform != "darwin":
from _socket import SO_BINDTODEVICE as SO_BINDTODEVICE

__all__ += ["SO_BINDTODEVICE"]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/tokenize.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class Untokenizer:
prev_col: int
encoding: str | None
def add_whitespace(self, start: _Position) -> None: ...
if sys.version_info >= (3, 13):
def add_backslash_continuation(self, start: _Position) -> None: ...

def untokenize(self, iterable: Iterable[_Token]) -> str: ...
def compat(self, token: Sequence[int | str], iterable: Iterable[_Token]) -> None: ...
if sys.version_info >= (3, 12):
Expand Down

0 comments on commit 5caaf2e

Please sign in to comment.