From aeaf19429065329ded81d845e266c5228cc24119 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 08:07:18 +0400 Subject: [PATCH 01/12] Bump `tomllib.TOMLDecodeError` to 3.14 --- stdlib/@tests/stubtest_allowlists/py314.txt | 1 - stdlib/tomllib.pyi | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py314.txt b/stdlib/@tests/stubtest_allowlists/py314.txt index 67a725257bbe..82e72dbf9333 100644 --- a/stdlib/@tests/stubtest_allowlists/py314.txt +++ b/stdlib/@tests/stubtest_allowlists/py314.txt @@ -176,7 +176,6 @@ tarfile.TarFile.zstopen threading.Thread.__init__ threading._RLock.locked tkinter.Event.__class_getitem__ -tomllib.TOMLDecodeError.__init__ turtle.__all__ turtle.RawTurtle.fill turtle.RawTurtle.poly diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index d559568b912b..c14bbdb49638 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -1,10 +1,26 @@ +import sys from _typeshed import SupportsRead from collections.abc import Callable -from typing import Any +from typing import Any, overload +from typing_extensions import deprecated __all__ = ("loads", "load", "TOMLDecodeError") -class TOMLDecodeError(ValueError): ... +if sys.version_info >= (3, 14): + class TOMLDecodeError(ValueError): + msg: str + doc: str + pos: int + lineno: int + colno: int + @overload + def __init__(self, msg: str, doc: str, pos: int) -> None: ... + @overload + @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") + def __init__(self, *args: Any) -> None: ... + +else: + class TOMLDecodeError(ValueError): ... def load(fp: SupportsRead[bytes], /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... def loads(s: str, /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... From 7326b8949ec2551927429b8fe679c33aaa6bf004 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 08:26:10 +0400 Subject: [PATCH 02/12] Add default values --- stdlib/tomllib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index c14bbdb49638..8be129ebc776 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -14,7 +14,7 @@ if sys.version_info >= (3, 14): lineno: int colno: int @overload - def __init__(self, msg: str, doc: str, pos: int) -> None: ... + def __init__(self, msg: str = ..., doc: str = ..., pos: int = ...) -> None: ... @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") def __init__(self, *args: Any) -> None: ... From 06c0036757b4f9327354a6024b1602e6587bcfb3 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 08:48:59 +0400 Subject: [PATCH 03/12] Add ignore comment --- stdlib/tomllib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 8be129ebc776..ccffc05f884b 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -14,7 +14,7 @@ if sys.version_info >= (3, 14): lineno: int colno: int @overload - def __init__(self, msg: str = ..., doc: str = ..., pos: int = ...) -> None: ... + def __init__(self, msg: str = ..., doc: str = ..., pos: int = ...) -> None: ... # type: ignore[assignment] @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") def __init__(self, *args: Any) -> None: ... From 9a4c053b9d6c0184671e35cd8a34021863f60f3d Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:16:39 +0400 Subject: [PATCH 04/12] Add ignore comment --- stdlib/tomllib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index ccffc05f884b..62a5572344ce 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -14,7 +14,7 @@ if sys.version_info >= (3, 14): lineno: int colno: int @overload - def __init__(self, msg: str = ..., doc: str = ..., pos: int = ...) -> None: ... # type: ignore[assignment] + def __init__(self, msg: str, doc: str, pos: int) -> None: ... # type: ignore[override] @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") def __init__(self, *args: Any) -> None: ... From cfe031380402c956181476f7c0739e7d124413c7 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:23:36 +0400 Subject: [PATCH 05/12] try another comment --- stdlib/tomllib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 62a5572344ce..8716ed301ab9 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -14,7 +14,7 @@ if sys.version_info >= (3, 14): lineno: int colno: int @overload - def __init__(self, msg: str, doc: str, pos: int) -> None: ... # type: ignore[override] + def __init__(self, msg: str, doc: str, pos: int) -> None: ... # type: ignore[overload-overlap] @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") def __init__(self, *args: Any) -> None: ... From 9143cba779673bf8192a9042ebb3908c6693e3e5 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:28:24 +0400 Subject: [PATCH 06/12] Add default value --- stdlib/tomllib.pyi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 8716ed301ab9..1463e48ef1ca 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -7,6 +7,8 @@ from typing_extensions import deprecated __all__ = ("loads", "load", "TOMLDecodeError") if sys.version_info >= (3, 14): + class DEPRECATED_DEFAULT: ... + class TOMLDecodeError(ValueError): msg: str doc: str @@ -14,10 +16,16 @@ if sys.version_info >= (3, 14): lineno: int colno: int @overload - def __init__(self, msg: str, doc: str, pos: int) -> None: ... # type: ignore[overload-overlap] + def __init__(self, msg: str, doc: str, pos: int) -> None: ... @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") - def __init__(self, *args: Any) -> None: ... + def __init__( + self, + msg: str | type[DEPRECATED_DEFAULT] = ..., + doc: str | type[DEPRECATED_DEFAULT] = ..., + pos: int | type[DEPRECATED_DEFAULT] = ..., + *args: Any, + ) -> None: ... else: class TOMLDecodeError(ValueError): ... From 8cf5d2e1127e9823adcfc355c4e4769efe388037 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:37:42 +0400 Subject: [PATCH 07/12] Remove deprecated class --- stdlib/tomllib.pyi | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 1463e48ef1ca..bb108a8a5f9e 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -7,8 +7,6 @@ from typing_extensions import deprecated __all__ = ("loads", "load", "TOMLDecodeError") if sys.version_info >= (3, 14): - class DEPRECATED_DEFAULT: ... - class TOMLDecodeError(ValueError): msg: str doc: str @@ -21,9 +19,9 @@ if sys.version_info >= (3, 14): @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") def __init__( self, - msg: str | type[DEPRECATED_DEFAULT] = ..., - doc: str | type[DEPRECATED_DEFAULT] = ..., - pos: int | type[DEPRECATED_DEFAULT] = ..., + msg: str = ..., # type: ignore[assignment] + doc: str = ..., # type: ignore[assignment] + pos: int = ..., # type: ignore[assignment] *args: Any, ) -> None: ... From 33a4df91bf44b38f1f25e9a1f6865cf1db21e170 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:42:59 +0400 Subject: [PATCH 08/12] Back to original ignore comment --- stdlib/tomllib.pyi | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index bb108a8a5f9e..62a5572344ce 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -14,16 +14,10 @@ if sys.version_info >= (3, 14): lineno: int colno: int @overload - def __init__(self, msg: str, doc: str, pos: int) -> None: ... + def __init__(self, msg: str, doc: str, pos: int) -> None: ... # type: ignore[override] @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") - def __init__( - self, - msg: str = ..., # type: ignore[assignment] - doc: str = ..., # type: ignore[assignment] - pos: int = ..., # type: ignore[assignment] - *args: Any, - ) -> None: ... + def __init__(self, *args: Any) -> None: ... else: class TOMLDecodeError(ValueError): ... From d8d68c575b2f646e11a803d5b0e355e159953cbb Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:45:31 +0400 Subject: [PATCH 09/12] Add another overload --- stdlib/tomllib.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 62a5572344ce..c50f018d6438 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -17,6 +17,9 @@ if sys.version_info >= (3, 14): def __init__(self, msg: str, doc: str, pos: int) -> None: ... # type: ignore[override] @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") + def __init__(self, msg: str = ..., doc: str = ..., pos: int = ...) -> None: ... + @overload + @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") def __init__(self, *args: Any) -> None: ... else: From b6e0c9aa3fc99ce22feff901f6cd544b53101fbd Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:48:59 +0400 Subject: [PATCH 10/12] Update --- stdlib/tomllib.pyi | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index c50f018d6438..5643de3092dd 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -14,13 +14,10 @@ if sys.version_info >= (3, 14): lineno: int colno: int @overload - def __init__(self, msg: str, doc: str, pos: int) -> None: ... # type: ignore[override] + def __init__(self, msg: str, doc: str, pos: int) -> None: ... @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") - def __init__(self, msg: str = ..., doc: str = ..., pos: int = ...) -> None: ... - @overload - @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") - def __init__(self, *args: Any) -> None: ... + def __init__(self, msg: Any, doc: Any, post: Any, *args: Any) -> None: ... else: class TOMLDecodeError(ValueError): ... From 39703ea1452378b631151eb3363b9dcec489b455 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:51:37 +0400 Subject: [PATCH 11/12] Update --- stdlib/tomllib.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 5643de3092dd..9210f6d4ca38 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -17,7 +17,8 @@ if sys.version_info >= (3, 14): def __init__(self, msg: str, doc: str, pos: int) -> None: ... @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") - def __init__(self, msg: Any, doc: Any, post: Any, *args: Any) -> None: ... + def __init__(self, *args: Any) -> None: ... + def __init__(self, msg: str | type = ..., doc: str | type = ..., pos: int | type = ..., *args: Any) -> None: ... else: class TOMLDecodeError(ValueError): ... From c4af0ded8aaa2a115fc9ddfa46861425f903c2fb Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 12 May 2025 12:55:28 +0400 Subject: [PATCH 12/12] Update again --- stdlib/tomllib.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 9210f6d4ca38..c160ffc38bfd 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -17,7 +17,6 @@ if sys.version_info >= (3, 14): def __init__(self, msg: str, doc: str, pos: int) -> None: ... @overload @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.") - def __init__(self, *args: Any) -> None: ... def __init__(self, msg: str | type = ..., doc: str | type = ..., pos: int | type = ..., *args: Any) -> None: ... else: