Skip to content

Commit 124d020

Browse files
ast, configparser, glob: Python 3.13 updates (#12050)
Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 4269f99 commit 124d020

File tree

5 files changed

+156
-66
lines changed

5 files changed

+156
-66
lines changed

stdlib/@tests/stubtest_allowlists/py313.txt

-12
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
# =========================
44

55
# TODO: triage these new errors
6-
_ast.PyCF_OPTIMIZED_AST
76
_collections_abc.dict_items.isdisjoint
87
_collections_abc.dict_keys.isdisjoint
98
_ctypes.POINTER
109
_ctypes.addressof
1110
_ctypes.alignment
1211
_ctypes.pointer
1312
_ctypes.sizeof
14-
_json.encode_basestring_ascii
1513
_thread.interrupt_main
1614
_thread.lock
1715
_thread.stack_size
@@ -20,7 +18,6 @@ _thread.start_new_thread
2018
_tkinter.TkappType.gettrace
2119
_tkinter.TkappType.settrace
2220
_tkinter.create
23-
ast.PyCF_OPTIMIZED_AST
2421
asyncio.AbstractEventLoop.create_server
2522
asyncio.AbstractServer.abort_clients
2623
asyncio.AbstractServer.close_clients
@@ -53,13 +50,6 @@ codecs.namereplace_errors
5350
codecs.replace_errors
5451
codecs.strict_errors
5552
codecs.xmlcharrefreplace_errors
56-
configparser.LegacyInterpolation
57-
configparser.MultilineContinuationError
58-
configparser.ParsingError.__init__
59-
configparser.ParsingError.combine
60-
configparser.RawConfigParser.__init__
61-
configparser.UNNAMED_SECTION
62-
configparser.__all__
6353
ctypes.POINTER
6454
ctypes._endian.DEFAULT_MODE
6555
ctypes._endian.RTLD_GLOBAL
@@ -98,8 +88,6 @@ doctest.TestResults.__new__
9888
email.utils.getaddresses
9989
email.utils.parseaddr
10090
filecmp.dircmp.__init__
101-
glob.__all__
102-
glob.translate
10391
importlib.metadata.DeprecatedTuple
10492
importlib.metadata.Distribution.origin
10593
importlib.metadata._meta.SimplePath.exists

stdlib/_ast.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ PyCF_ONLY_AST: Literal[1024]
77
PyCF_TYPE_COMMENTS: Literal[4096]
88
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
99

10+
if sys.version_info >= (3, 13):
11+
PyCF_OPTIMIZED_AST: Literal[33792]
12+
1013
# Used for node end positions in constructor keyword arguments
1114
_EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None) # noqa: Y023
1215

stdlib/_json.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ class make_scanner:
4545
def __init__(self, context: make_scanner) -> None: ...
4646
def __call__(self, string: str, index: int) -> tuple[Any, int]: ...
4747

48-
def encode_basestring_ascii(s: str) -> str: ...
48+
def encode_basestring_ascii(s: str, /) -> str: ...
4949
def scanstring(string: str, end: int, strict: bool = ...) -> tuple[str, int]: ...

stdlib/configparser.pyi

+143-52
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,31 @@ from re import Pattern
55
from typing import Any, ClassVar, Literal, TypeVar, overload
66
from typing_extensions import TypeAlias
77

8-
if sys.version_info >= (3, 12):
8+
if sys.version_info >= (3, 13):
9+
__all__ = (
10+
"NoSectionError",
11+
"DuplicateOptionError",
12+
"DuplicateSectionError",
13+
"NoOptionError",
14+
"InterpolationError",
15+
"InterpolationDepthError",
16+
"InterpolationMissingOptionError",
17+
"InterpolationSyntaxError",
18+
"ParsingError",
19+
"MissingSectionHeaderError",
20+
"ConfigParser",
21+
"RawConfigParser",
22+
"Interpolation",
23+
"BasicInterpolation",
24+
"ExtendedInterpolation",
25+
"SectionProxy",
26+
"ConverterMapping",
27+
"DEFAULTSECT",
28+
"MAX_INTERPOLATION_DEPTH",
29+
"UNNAMED_SECTION",
30+
"MultilineContinuationError",
31+
)
32+
elif sys.version_info >= (3, 12):
933
__all__ = (
1034
"NoSectionError",
1135
"DuplicateOptionError",
@@ -71,8 +95,9 @@ class Interpolation:
7195
class BasicInterpolation(Interpolation): ...
7296
class ExtendedInterpolation(Interpolation): ...
7397

74-
class LegacyInterpolation(Interpolation):
75-
def before_get(self, parser: _Parser, section: str, option: str, value: str, vars: _Section) -> str: ...
98+
if sys.version_info < (3, 13):
99+
class LegacyInterpolation(Interpolation):
100+
def before_get(self, parser: _Parser, section: str, option: str, value: str, vars: _Section) -> str: ...
76101

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

87112
BOOLEAN_STATES: ClassVar[Mapping[str, bool]] # undocumented
88113
default_section: str
89-
@overload
90-
def __init__(
91-
self,
92-
defaults: Mapping[str, str | None] | None = None,
93-
dict_type: type[Mapping[str, str]] = ...,
94-
*,
95-
allow_no_value: Literal[True],
96-
delimiters: Sequence[str] = ("=", ":"),
97-
comment_prefixes: Sequence[str] = ("#", ";"),
98-
inline_comment_prefixes: Sequence[str] | None = None,
99-
strict: bool = True,
100-
empty_lines_in_values: bool = True,
101-
default_section: str = "DEFAULT",
102-
interpolation: Interpolation | None = ...,
103-
converters: _ConvertersMap = ...,
104-
) -> None: ...
105-
@overload
106-
def __init__(
107-
self,
108-
defaults: Mapping[str, str | None] | None,
109-
dict_type: type[Mapping[str, str]],
110-
allow_no_value: Literal[True],
111-
*,
112-
delimiters: Sequence[str] = ("=", ":"),
113-
comment_prefixes: Sequence[str] = ("#", ";"),
114-
inline_comment_prefixes: Sequence[str] | None = None,
115-
strict: bool = True,
116-
empty_lines_in_values: bool = True,
117-
default_section: str = "DEFAULT",
118-
interpolation: Interpolation | None = ...,
119-
converters: _ConvertersMap = ...,
120-
) -> None: ...
121-
@overload
122-
def __init__(
123-
self,
124-
defaults: _Section | None = None,
125-
dict_type: type[Mapping[str, str]] = ...,
126-
allow_no_value: bool = False,
127-
*,
128-
delimiters: Sequence[str] = ("=", ":"),
129-
comment_prefixes: Sequence[str] = ("#", ";"),
130-
inline_comment_prefixes: Sequence[str] | None = None,
131-
strict: bool = True,
132-
empty_lines_in_values: bool = True,
133-
default_section: str = "DEFAULT",
134-
interpolation: Interpolation | None = ...,
135-
converters: _ConvertersMap = ...,
136-
) -> None: ...
114+
if sys.version_info >= (3, 13):
115+
@overload
116+
def __init__(
117+
self,
118+
defaults: Mapping[str, str | None] | None = None,
119+
dict_type: type[Mapping[str, str]] = ...,
120+
*,
121+
allow_no_value: Literal[True],
122+
delimiters: Sequence[str] = ("=", ":"),
123+
comment_prefixes: Sequence[str] = ("#", ";"),
124+
inline_comment_prefixes: Sequence[str] | None = None,
125+
strict: bool = True,
126+
empty_lines_in_values: bool = True,
127+
default_section: str = "DEFAULT",
128+
interpolation: Interpolation | None = ...,
129+
converters: _ConvertersMap = ...,
130+
allow_unnamed_section: bool = False,
131+
) -> None: ...
132+
@overload
133+
def __init__(
134+
self,
135+
defaults: Mapping[str, str | None] | None,
136+
dict_type: type[Mapping[str, str]],
137+
allow_no_value: Literal[True],
138+
*,
139+
delimiters: Sequence[str] = ("=", ":"),
140+
comment_prefixes: Sequence[str] = ("#", ";"),
141+
inline_comment_prefixes: Sequence[str] | None = None,
142+
strict: bool = True,
143+
empty_lines_in_values: bool = True,
144+
default_section: str = "DEFAULT",
145+
interpolation: Interpolation | None = ...,
146+
converters: _ConvertersMap = ...,
147+
allow_unnamed_section: bool = False,
148+
) -> None: ...
149+
@overload
150+
def __init__(
151+
self,
152+
defaults: _Section | None = None,
153+
dict_type: type[Mapping[str, str]] = ...,
154+
allow_no_value: bool = False,
155+
*,
156+
delimiters: Sequence[str] = ("=", ":"),
157+
comment_prefixes: Sequence[str] = ("#", ";"),
158+
inline_comment_prefixes: Sequence[str] | None = None,
159+
strict: bool = True,
160+
empty_lines_in_values: bool = True,
161+
default_section: str = "DEFAULT",
162+
interpolation: Interpolation | None = ...,
163+
converters: _ConvertersMap = ...,
164+
allow_unnamed_section: bool = False,
165+
) -> None: ...
166+
else:
167+
@overload
168+
def __init__(
169+
self,
170+
defaults: Mapping[str, str | None] | None = None,
171+
dict_type: type[Mapping[str, str]] = ...,
172+
*,
173+
allow_no_value: Literal[True],
174+
delimiters: Sequence[str] = ("=", ":"),
175+
comment_prefixes: Sequence[str] = ("#", ";"),
176+
inline_comment_prefixes: Sequence[str] | None = None,
177+
strict: bool = True,
178+
empty_lines_in_values: bool = True,
179+
default_section: str = "DEFAULT",
180+
interpolation: Interpolation | None = ...,
181+
converters: _ConvertersMap = ...,
182+
) -> None: ...
183+
@overload
184+
def __init__(
185+
self,
186+
defaults: Mapping[str, str | None] | None,
187+
dict_type: type[Mapping[str, str]],
188+
allow_no_value: Literal[True],
189+
*,
190+
delimiters: Sequence[str] = ("=", ":"),
191+
comment_prefixes: Sequence[str] = ("#", ";"),
192+
inline_comment_prefixes: Sequence[str] | None = None,
193+
strict: bool = True,
194+
empty_lines_in_values: bool = True,
195+
default_section: str = "DEFAULT",
196+
interpolation: Interpolation | None = ...,
197+
converters: _ConvertersMap = ...,
198+
) -> None: ...
199+
@overload
200+
def __init__(
201+
self,
202+
defaults: _Section | None = None,
203+
dict_type: type[Mapping[str, str]] = ...,
204+
allow_no_value: bool = False,
205+
*,
206+
delimiters: Sequence[str] = ("=", ":"),
207+
comment_prefixes: Sequence[str] = ("#", ";"),
208+
inline_comment_prefixes: Sequence[str] | None = None,
209+
strict: bool = True,
210+
empty_lines_in_values: bool = True,
211+
default_section: str = "DEFAULT",
212+
interpolation: Interpolation | None = ...,
213+
converters: _ConvertersMap = ...,
214+
) -> None: ...
215+
137216
def __len__(self) -> int: ...
138217
def __getitem__(self, key: str) -> SectionProxy: ...
139218
def __setitem__(self, key: str, value: _Section) -> None: ...
@@ -300,7 +379,10 @@ class InterpolationSyntaxError(InterpolationError): ...
300379
class ParsingError(Error):
301380
source: str
302381
errors: list[tuple[int, str]]
303-
if sys.version_info >= (3, 12):
382+
if sys.version_info >= (3, 13):
383+
def __init__(self, source: str, *args: object) -> None: ...
384+
def combine(self, others: Iterable[ParsingError]) -> ParsingError: ...
385+
elif sys.version_info >= (3, 12):
304386
def __init__(self, source: str) -> None: ...
305387
else:
306388
def __init__(self, source: str | None = None, filename: str | None = None) -> None: ...
@@ -311,3 +393,12 @@ class MissingSectionHeaderError(ParsingError):
311393
lineno: int
312394
line: str
313395
def __init__(self, filename: str, lineno: int, line: str) -> None: ...
396+
397+
if sys.version_info >= (3, 13):
398+
class _UNNAMED_SECTION: ...
399+
UNNAMED_SECTION: _UNNAMED_SECTION
400+
401+
class MultilineContinuationError(ParsingError):
402+
lineno: int
403+
line: str
404+
def __init__(self, filename: str, lineno: int, line: str) -> None: ...

stdlib/glob.pyi

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import sys
22
from _typeshed import StrOrBytesPath
3-
from collections.abc import Iterator
3+
from collections.abc import Iterator, Sequence
44
from typing import AnyStr
55

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

8+
if sys.version_info >= (3, 13):
9+
__all__ += ["translate"]
10+
811
def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
912
def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
1013

@@ -40,3 +43,8 @@ else:
4043

4144
def escape(pathname: AnyStr) -> AnyStr: ...
4245
def has_magic(s: str | bytes) -> bool: ... # undocumented
46+
47+
if sys.version_info >= (3, 13):
48+
def translate(
49+
pat: str, *, recursive: bool = False, include_hidden: bool = False, seps: Sequence[str] | None = None
50+
) -> str: ...

0 commit comments

Comments
 (0)