ast, configparser, glob: Python 3.13 updates (#12050)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Amin Alaee
2024-06-01 16:13:10 +02:00
committed by GitHub
parent 4269f992f1
commit 124d02034d
5 changed files with 156 additions and 66 deletions

View File

@@ -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",
)
elif sys.version_info >= (3, 12):
__all__ = (
"NoSectionError",
"DuplicateOptionError",
@@ -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
@@ -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: ...
@@ -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: ...
@@ -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: ...