Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
# =========================

# TODO: triage these new errors
_ast.PyCF_OPTIMIZED_AST
_collections_abc.dict_items.isdisjoint
_collections_abc.dict_keys.isdisjoint
_ctypes.POINTER
_ctypes.addressof
_ctypes.alignment
_ctypes.pointer
_ctypes.sizeof
_json.encode_basestring_ascii
_thread.interrupt_main
_thread.lock
_thread.stack_size
Expand All @@ -20,7 +18,6 @@ _thread.start_new_thread
_tkinter.TkappType.gettrace
_tkinter.TkappType.settrace
_tkinter.create
ast.PyCF_OPTIMIZED_AST
asyncio.AbstractEventLoop.create_server
asyncio.AbstractServer.abort_clients
asyncio.AbstractServer.close_clients
Expand Down Expand Up @@ -53,13 +50,6 @@ codecs.namereplace_errors
codecs.replace_errors
codecs.strict_errors
codecs.xmlcharrefreplace_errors
configparser.LegacyInterpolation
configparser.MultilineContinuationError
configparser.ParsingError.__init__
configparser.ParsingError.combine
configparser.RawConfigParser.__init__
configparser.UNNAMED_SECTION
configparser.__all__
ctypes.POINTER
ctypes._endian.DEFAULT_MODE
ctypes._endian.RTLD_GLOBAL
Expand Down Expand Up @@ -101,8 +91,6 @@ enum.EnumDict
enum._EnumDict.member_names
enum.__all__
filecmp.dircmp.__init__
glob.__all__
glob.translate
importlib.metadata.DeprecatedTuple
importlib.metadata.Distribution.origin
importlib.metadata._meta.SimplePath.exists
Expand Down
3 changes: 3 additions & 0 deletions stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ PyCF_ONLY_AST: Literal[1024]
PyCF_TYPE_COMMENTS: Literal[4096]
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]

if sys.version_info >= (3, 13):
PyCF_OPTIMIZED_AST: Literal[33792]

# Used for node end positions in constructor keyword arguments
_EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None) # noqa: Y023

Expand Down
2 changes: 1 addition & 1 deletion stdlib/_json.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ class make_scanner:
def __init__(self, context: make_scanner) -> None: ...
def __call__(self, string: str, index: int) -> tuple[Any, int]: ...

def encode_basestring_ascii(s: str) -> str: ...
def encode_basestring_ascii(s: str, /) -> str: ...
def scanstring(string: str, end: int, strict: bool = ...) -> tuple[str, int]: ...
195 changes: 143 additions & 52 deletions stdlib/configparser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,31 @@ from re import Pattern
from typing import Any, ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeAlias

if sys.version_info >= (3, 12):
if sys.version_info >= (3, 13):
__all__ = (
"NoSectionError",
"DuplicateOptionError",
"DuplicateSectionError",
"NoOptionError",
"InterpolationError",
"InterpolationDepthError",
"InterpolationMissingOptionError",
"InterpolationSyntaxError",
"ParsingError",
"MissingSectionHeaderError",
"ConfigParser",
"RawConfigParser",
"Interpolation",
"BasicInterpolation",
"ExtendedInterpolation",
"SectionProxy",
"ConverterMapping",
"DEFAULTSECT",
"MAX_INTERPOLATION_DEPTH",
"UNNAMED_SECTION",
"MultilineContinuationError",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could shorten this by adding something like if sys.version_info >= (3, 13): __all__ += ["MultilineContinuationError"]. We can also get rid of the existing duplication of __all__ this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible to get rid of the existing duplication without stubtest complaining because it's a tuple in one branch but a list in the other branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah after 3.12 this is a tuple now, and in 3.13 there are a few additions and removals which makes editing it not simple

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do something like this to make it more concise, but I personally think the nested sys.version_info branches are a bit confusing:

--- a/stdlib/configparser.pyi
+++ b/stdlib/configparser.pyi
@@ -5,32 +5,8 @@ from re import Pattern
 from typing import Any, ClassVar, Literal, TypeVar, overload
 from typing_extensions import TypeAlias
 
-if sys.version_info >= (3, 13):
-    __all__ = (
-        "NoSectionError",
-        "DuplicateOptionError",
-        "DuplicateSectionError",
-        "NoOptionError",
-        "InterpolationError",
-        "InterpolationDepthError",
-        "InterpolationMissingOptionError",
-        "InterpolationSyntaxError",
-        "ParsingError",
-        "MissingSectionHeaderError",
-        "ConfigParser",
-        "RawConfigParser",
-        "Interpolation",
-        "BasicInterpolation",
-        "ExtendedInterpolation",
-        "SectionProxy",
-        "ConverterMapping",
-        "DEFAULTSECT",
-        "MAX_INTERPOLATION_DEPTH",
-        "UNNAMED_SECTION",
-        "MultilineContinuationError",
-    )
-elif sys.version_info >= (3, 12):
-    __all__ = (
+if sys.version_info >= (3, 12):
+    __all__: tuple[str, ...] = (
         "NoSectionError",
         "DuplicateOptionError",
         "DuplicateSectionError",
@@ -46,12 +22,15 @@ elif sys.version_info >= (3, 12):
         "Interpolation",
         "BasicInterpolation",
         "ExtendedInterpolation",
-        "LegacyInterpolation",
         "SectionProxy",
         "ConverterMapping",
         "DEFAULTSECT",
         "MAX_INTERPOLATION_DEPTH",
     )
+    if sys.version_info >= (3, 13):
+        __all__ += ("UNNAMED_SECTION", "MultilineContinuationError")
+    else:
+        __all__ += ("LegacyInterpolation",)
 else:
     __all__ = [

Though it's verbose, I'd go with what this PR currently has for this module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't notice the list/tuple difference. It's OK to go with what we currently have then.

)
elif sys.version_info >= (3, 12):
__all__ = (
"NoSectionError",
"DuplicateOptionError",
Expand Down Expand Up @@ -71,8 +95,9 @@ class Interpolation:
class BasicInterpolation(Interpolation): ...
class ExtendedInterpolation(Interpolation): ...

class LegacyInterpolation(Interpolation):
def before_get(self, parser: _Parser, section: str, option: str, value: str, vars: _Section) -> str: ...
if sys.version_info < (3, 13):
class LegacyInterpolation(Interpolation):
def before_get(self, parser: _Parser, section: str, option: str, value: str, vars: _Section) -> str: ...

class RawConfigParser(_Parser):
_SECT_TMPL: ClassVar[str] # undocumented
Expand All @@ -86,54 +111,108 @@ class RawConfigParser(_Parser):

BOOLEAN_STATES: ClassVar[Mapping[str, bool]] # undocumented
default_section: str
@overload
def __init__(
self,
defaults: Mapping[str, str | None] | None = None,
dict_type: type[Mapping[str, str]] = ...,
*,
allow_no_value: Literal[True],
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
) -> None: ...
@overload
def __init__(
self,
defaults: Mapping[str, str | None] | None,
dict_type: type[Mapping[str, str]],
allow_no_value: Literal[True],
*,
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
) -> None: ...
@overload
def __init__(
self,
defaults: _Section | None = None,
dict_type: type[Mapping[str, str]] = ...,
allow_no_value: bool = False,
*,
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
) -> None: ...
if sys.version_info >= (3, 13):
@overload
def __init__(
self,
defaults: Mapping[str, str | None] | None = None,
dict_type: type[Mapping[str, str]] = ...,
*,
allow_no_value: Literal[True],
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
allow_unnamed_section: bool = False,
) -> None: ...
@overload
def __init__(
self,
defaults: Mapping[str, str | None] | None,
dict_type: type[Mapping[str, str]],
allow_no_value: Literal[True],
*,
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
allow_unnamed_section: bool = False,
) -> None: ...
@overload
def __init__(
self,
defaults: _Section | None = None,
dict_type: type[Mapping[str, str]] = ...,
allow_no_value: bool = False,
*,
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
allow_unnamed_section: bool = False,
) -> None: ...
else:
@overload
def __init__(
self,
defaults: Mapping[str, str | None] | None = None,
dict_type: type[Mapping[str, str]] = ...,
*,
allow_no_value: Literal[True],
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
) -> None: ...
@overload
def __init__(
self,
defaults: Mapping[str, str | None] | None,
dict_type: type[Mapping[str, str]],
allow_no_value: Literal[True],
*,
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
) -> None: ...
@overload
def __init__(
self,
defaults: _Section | None = None,
dict_type: type[Mapping[str, str]] = ...,
allow_no_value: bool = False,
*,
delimiters: Sequence[str] = ("=", ":"),
comment_prefixes: Sequence[str] = ("#", ";"),
inline_comment_prefixes: Sequence[str] | None = None,
strict: bool = True,
empty_lines_in_values: bool = True,
default_section: str = "DEFAULT",
interpolation: Interpolation | None = ...,
converters: _ConvertersMap = ...,
) -> None: ...

def __len__(self) -> int: ...
def __getitem__(self, key: str) -> SectionProxy: ...
def __setitem__(self, key: str, value: _Section) -> None: ...
Expand Down Expand Up @@ -300,7 +379,10 @@ class InterpolationSyntaxError(InterpolationError): ...
class ParsingError(Error):
source: str
errors: list[tuple[int, str]]
if sys.version_info >= (3, 12):
if sys.version_info >= (3, 13):
def __init__(self, source: str, *args: object) -> None: ...
def combine(self, others: Iterable[ParsingError]) -> ParsingError: ...
elif sys.version_info >= (3, 12):
def __init__(self, source: str) -> None: ...
else:
def __init__(self, source: str | None = None, filename: str | None = None) -> None: ...
Expand All @@ -311,3 +393,12 @@ class MissingSectionHeaderError(ParsingError):
lineno: int
line: str
def __init__(self, filename: str, lineno: int, line: str) -> None: ...

if sys.version_info >= (3, 13):
class _UNNAMED_SECTION: ...
UNNAMED_SECTION: _UNNAMED_SECTION

class MultilineContinuationError(ParsingError):
lineno: int
line: str
def __init__(self, filename: str, lineno: int, line: str) -> None: ...
10 changes: 9 additions & 1 deletion stdlib/glob.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import sys
from _typeshed import StrOrBytesPath
from collections.abc import Iterator
from collections.abc import Iterator, Sequence
from typing import AnyStr

__all__ = ["escape", "glob", "iglob"]

if sys.version_info >= (3, 13):
__all__ += ["translate"]

def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...

Expand Down Expand Up @@ -40,3 +43,8 @@ else:

def escape(pathname: AnyStr) -> AnyStr: ...
def has_magic(s: str | bytes) -> bool: ... # undocumented

if sys.version_info >= (3, 13):
def translate(
pat: str, *, recursive: bool = False, include_hidden: bool = False, seps: Sequence[str] | None = None
) -> str: ...