Skip to content

[configparser] Add several deprecated attributes #14487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions stdlib/configparser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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, type_check_only
from typing_extensions import TypeAlias
from typing_extensions import TypeAlias, deprecated

if sys.version_info >= (3, 14):
__all__ = (
Expand Down Expand Up @@ -271,6 +271,7 @@ class RawConfigParser(_Parser):
def read_string(self, string: str, source: str = "<string>") -> None: ...
def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = "<dict>") -> 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
Expand Down Expand Up @@ -331,7 +332,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: ...
Expand Down Expand Up @@ -443,10 +445,22 @@ 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, 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: ...

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
Expand Down
Loading