From e932a07ff070e43004aa096b38fc63da61fff8cc Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Tue, 28 May 2024 09:31:07 +0000 Subject: [PATCH 1/5] ast, configparser, glob: Python3.13 updates --- stdlib/@tests/stubtest_allowlists/py313.txt | 12 ------ stdlib/_ast.pyi | 1 + stdlib/_json.pyi | 2 +- stdlib/configparser.pyi | 47 +++++++++++++++++++-- stdlib/glob.pyi | 8 +++- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 4729ae764eb9..654ffc3e32de 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -3,7 +3,6 @@ # ========================= # TODO: triage these new errors -_ast.PyCF_OPTIMIZED_AST _collections_abc.dict_items.isdisjoint _collections_abc.dict_keys.isdisjoint _ctypes.POINTER @@ -11,7 +10,6 @@ _ctypes.addressof _ctypes.alignment _ctypes.pointer _ctypes.sizeof -_json.encode_basestring_ascii _thread.interrupt_main _thread.lock _thread.stack_size @@ -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 @@ -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 @@ -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 diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index 51791b4099d5..3e83c9c5e1eb 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -6,6 +6,7 @@ from typing_extensions import Unpack PyCF_ONLY_AST: Literal[1024] PyCF_TYPE_COMMENTS: Literal[4096] PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192] +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 diff --git a/stdlib/_json.pyi b/stdlib/_json.pyi index a6a62be184d8..069fb6eac4bf 100644 --- a/stdlib/_json.pyi +++ b/stdlib/_json.pyi @@ -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]: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 07b57b17d56d..ccaf24e0d579 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -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 @@ -101,6 +126,7 @@ class RawConfigParser(_Parser): default_section: str = "DEFAULT", interpolation: Interpolation | None = ..., converters: _ConvertersMap = ..., + allow_unnamed_section: bool = False, ) -> None: ... @overload def __init__( @@ -117,6 +143,7 @@ class RawConfigParser(_Parser): default_section: str = "DEFAULT", interpolation: Interpolation | None = ..., converters: _ConvertersMap = ..., + allow_unnamed_section: bool = False, ) -> None: ... @overload def __init__( @@ -133,6 +160,7 @@ class RawConfigParser(_Parser): default_section: str = "DEFAULT", interpolation: Interpolation | None = ..., converters: _ConvertersMap = ..., + allow_unnamed_section: bool = False, ) -> None: ... def __len__(self) -> int: ... def __getitem__(self, key: str) -> SectionProxy: ... @@ -300,7 +328,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: Sequence[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 +342,11 @@ 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: ... diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index 914ccc12ef1e..a8497c1cb70f 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -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]: ... @@ -40,3 +43,6 @@ else: def escape(pathname: AnyStr) -> AnyStr: ... def has_magic(s: str | bytes) -> bool: ... # undocumented + +if sys.version_info >= (3, 13): + def translate(pat: AnyStr, *, recursive: bool = False, include_hidden: bool = False, seps: Sequence[str] | None = None) -> AnyStr: ... From c42ae89fd34f9d4a7d4c28830909fc05d986fb1e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 09:44:03 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/_ast.pyi | 4 +- stdlib/configparser.pyi | 153 ++++++++++++++++++++++++++-------------- stdlib/glob.pyi | 4 +- 3 files changed, 108 insertions(+), 53 deletions(-) diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index 3e83c9c5e1eb..4d4ffbbd08a8 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -6,7 +6,9 @@ from typing_extensions import Unpack PyCF_ONLY_AST: Literal[1024] PyCF_TYPE_COMMENTS: Literal[4096] PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192] -PyCF_OPTIMIZED_AST: Literal[33792] + +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 diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index ccaf24e0d579..3fc40c4f9d43 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -111,57 +111,107 @@ 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 = ..., - 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: ... + 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: ... @@ -346,6 +396,7 @@ class MissingSectionHeaderError(ParsingError): if sys.version_info >= (3, 13): class _UNNAMED_SECTION: ... UNNAMED_SECTION: _UNNAMED_SECTION + class MultilineContinuationError(ParsingError): lineno: int line: str diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index a8497c1cb70f..d39850b2b8c9 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -45,4 +45,6 @@ def escape(pathname: AnyStr) -> AnyStr: ... def has_magic(s: str | bytes) -> bool: ... # undocumented if sys.version_info >= (3, 13): - def translate(pat: AnyStr, *, recursive: bool = False, include_hidden: bool = False, seps: Sequence[str] | None = None) -> AnyStr: ... + def translate( + pat: AnyStr, *, recursive: bool = False, include_hidden: bool = False, seps: Sequence[str] | None = None + ) -> AnyStr: ... From 063a55f79cdec2441d7d66bfbd727efecba32bad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 09:53:50 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/configparser.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 3fc40c4f9d43..fa688b715783 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -212,6 +212,7 @@ class RawConfigParser(_Parser): interpolation: Interpolation | None = ..., converters: _ConvertersMap = ..., ) -> None: ... + def __len__(self) -> int: ... def __getitem__(self, key: str) -> SectionProxy: ... def __setitem__(self, key: str, value: _Section) -> None: ... From 9bdb8e57fc68faec17fbe7d500473b341b3563b6 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Sat, 1 Jun 2024 13:44:37 +0200 Subject: [PATCH 4/5] Update stdlib/configparser.pyi Co-authored-by: Jelle Zijlstra --- stdlib/configparser.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index fa688b715783..f38bb1de674d 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -381,7 +381,7 @@ class ParsingError(Error): errors: list[tuple[int, str]] if sys.version_info >= (3, 13): def __init__(self, source: str, *args: object) -> None: ... - def combine(self, others: Sequence[ParsingError]) -> ParsingError: ... + def combine(self, others: Iterable[ParsingError]) -> ParsingError: ... elif sys.version_info >= (3, 12): def __init__(self, source: str) -> None: ... else: From b0164d0ba1609a8a7b045d4e141dc643a8ee44e8 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Sat, 1 Jun 2024 13:44:43 +0200 Subject: [PATCH 5/5] Update stdlib/glob.pyi Co-authored-by: Jelle Zijlstra --- stdlib/glob.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index d39850b2b8c9..03cb5418e256 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -46,5 +46,5 @@ def has_magic(s: str | bytes) -> bool: ... # undocumented if sys.version_info >= (3, 13): def translate( - pat: AnyStr, *, recursive: bool = False, include_hidden: bool = False, seps: Sequence[str] | None = None - ) -> AnyStr: ... + pat: str, *, recursive: bool = False, include_hidden: bool = False, seps: Sequence[str] | None = None + ) -> str: ...