From 70e4c69d4362140ca47e66714fe8ca936c26481e Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 28 Jul 2025 22:15:45 +0400 Subject: [PATCH 1/6] [configparser] Deprecate `SafeConfigParser` "Remove" PR for deprecation message: https://github.com/python/cpython/pull/92503 --- stdlib/configparser.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 121b8606a92a..2466fe45a41d 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -3,7 +3,7 @@ from _typeshed import MaybeNone, StrOrBytesPath, SupportsWrite from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence from re import Pattern from typing import Any, ClassVar, Final, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing_extensions import TypeAlias, deprecated if sys.version_info >= (3, 14): __all__ = ( @@ -329,7 +329,8 @@ class ConfigParser(RawConfigParser): ) -> str | _T: ... if sys.version_info < (3, 12): - class SafeConfigParser(ConfigParser): ... # deprecated alias + @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `ConfigParser` instead.") + class SafeConfigParser(ConfigParser): ... class SectionProxy(MutableMapping[str, str]): def __init__(self, parser: RawConfigParser, name: str) -> None: ... From 6ce442d7c60875fdc2543b02b6d17035aff7e74f Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 28 Jul 2025 23:48:50 +0400 Subject: [PATCH 2/6] Add overload to ParsingError --- stdlib/configparser.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 2466fe45a41d..16cf2934aa1e 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -442,7 +442,11 @@ class ParsingError(Error): 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: ... + @overload + def __init__(self, source: str) -> None: ... + @overload + @deprecated("The `filename` parameter removed in Python 3.12. Use `source` instead.") + def __init__(self, *, filename: str) -> None: ... def append(self, lineno: int, line: str) -> None: ... From 9fb93fdae028d82a74cb7042edf6fb002ae6cad6 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 28 Jul 2025 23:54:26 +0400 Subject: [PATCH 3/6] Fix --- stdlib/configparser.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 16cf2934aa1e..ea3f1089109c 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -446,7 +446,7 @@ class ParsingError(Error): def __init__(self, source: str) -> None: ... @overload @deprecated("The `filename` parameter removed in Python 3.12. Use `source` instead.") - def __init__(self, *, filename: str) -> None: ... + def __init__(self, source: None = None, filename: str = ...) -> None: ... def append(self, lineno: int, line: str) -> None: ... From fccd93f3fc1423d3fd42ce8482b8089e059470cb Mon Sep 17 00:00:00 2001 From: donBarbos Date: Mon, 28 Jul 2025 23:57:05 +0400 Subject: [PATCH 4/6] add filename to first overload --- stdlib/configparser.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index ea3f1089109c..7b543b5a0022 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -443,7 +443,7 @@ class ParsingError(Error): def __init__(self, source: str) -> None: ... else: @overload - def __init__(self, source: str) -> None: ... + def __init__(self, source: str, filename: None = None) -> None: ... @overload @deprecated("The `filename` parameter removed in Python 3.12. Use `source` instead.") def __init__(self, source: None = None, filename: str = ...) -> None: ... From 3262634fd91c8f3325239faff65c308dda55005f Mon Sep 17 00:00:00 2001 From: donBarbos Date: Tue, 29 Jul 2025 11:40:50 +0400 Subject: [PATCH 5/6] Add few deprecations --- stdlib/configparser.pyi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 7b543b5a0022..1c6b80b3bc7a 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -269,6 +269,7 @@ class RawConfigParser(_Parser): def read_string(self, string: str, source: str = "") -> None: ... def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = "") -> None: ... if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `parser.read_file()` instead.") def readfp(self, fp: Iterable[str], filename: str | None = None) -> None: ... # These get* methods are partially applied (with the same names) in # SectionProxy; the stubs should be kept updated together @@ -450,6 +451,14 @@ class ParsingError(Error): def append(self, lineno: int, line: str) -> None: ... + if sys.version_info < (3, 12): + @property + @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `source` instead.") + def filename(self) -> str: ... + @filename.setter + @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `source` instead.") + def filename(self, value: str) -> None: ... + class MissingSectionHeaderError(ParsingError): lineno: int line: str From 31c55e768d95fc62a5c08d6714a38d0fdf5432fe Mon Sep 17 00:00:00 2001 From: donBarbos Date: Tue, 29 Jul 2025 11:47:34 +0400 Subject: [PATCH 6/6] Remove entries from allowlist --- stdlib/@tests/stubtest_allowlists/py310.txt | 1 - stdlib/@tests/stubtest_allowlists/py311.txt | 1 - stdlib/@tests/stubtest_allowlists/py39.txt | 1 - 3 files changed, 3 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py310.txt b/stdlib/@tests/stubtest_allowlists/py310.txt index 556478e4d2c2..f63e06063a31 100644 --- a/stdlib/@tests/stubtest_allowlists/py310.txt +++ b/stdlib/@tests/stubtest_allowlists/py310.txt @@ -107,7 +107,6 @@ tkinter.Tk.split # Exists at runtime, but missing from stubs # ======= _?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set -configparser.ParsingError.filename enum.Enum._generate_next_value_ importlib.abc.Finder.find_module urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified diff --git a/stdlib/@tests/stubtest_allowlists/py311.txt b/stdlib/@tests/stubtest_allowlists/py311.txt index a99e1220bfc0..917b4c331ec4 100644 --- a/stdlib/@tests/stubtest_allowlists/py311.txt +++ b/stdlib/@tests/stubtest_allowlists/py311.txt @@ -70,7 +70,6 @@ importlib.metadata._meta.SimplePath.__truediv__ # Runtime definition of protoco # ======= _?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set -configparser.ParsingError.filename enum.Enum._generate_next_value_ importlib.abc.Finder.find_module urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified diff --git a/stdlib/@tests/stubtest_allowlists/py39.txt b/stdlib/@tests/stubtest_allowlists/py39.txt index 8c7de0f3a871..8bc88665e715 100644 --- a/stdlib/@tests/stubtest_allowlists/py39.txt +++ b/stdlib/@tests/stubtest_allowlists/py39.txt @@ -54,7 +54,6 @@ typing_extensions.Sentinel.__call__ # ======= _?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set -configparser.ParsingError.filename enum.Enum._generate_next_value_ importlib.abc.Finder.find_module urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified