@@ -3,7 +3,7 @@ from _typeshed import MaybeNone, StrOrBytesPath, SupportsWrite
3
3
from collections .abc import Callable , ItemsView , Iterable , Iterator , Mapping , MutableMapping , Sequence
4
4
from re import Pattern
5
5
from typing import Any , ClassVar , Final , Literal , TypeVar , overload , type_check_only
6
- from typing_extensions import TypeAlias
6
+ from typing_extensions import TypeAlias , deprecated
7
7
8
8
if sys .version_info >= (3 , 14 ):
9
9
__all__ = (
@@ -271,6 +271,7 @@ class RawConfigParser(_Parser):
271
271
def read_string (self , string : str , source : str = "<string>" ) -> None : ...
272
272
def read_dict (self , dictionary : Mapping [str , Mapping [str , Any ]], source : str = "<dict>" ) -> None : ...
273
273
if sys .version_info < (3 , 12 ):
274
+ @deprecated ("Deprecated since Python 3.2; removed in Python 3.12. Use `parser.read_file()` instead." )
274
275
def readfp (self , fp : Iterable [str ], filename : str | None = None ) -> None : ...
275
276
# These get* methods are partially applied (with the same names) in
276
277
# SectionProxy; the stubs should be kept updated together
@@ -331,7 +332,8 @@ class ConfigParser(RawConfigParser):
331
332
) -> str | _T : ...
332
333
333
334
if sys .version_info < (3 , 12 ):
334
- class SafeConfigParser (ConfigParser ): ... # deprecated alias
335
+ @deprecated ("Deprecated since Python 3.2; removed in Python 3.12. Use `ConfigParser` instead." )
336
+ class SafeConfigParser (ConfigParser ): ...
335
337
336
338
class SectionProxy (MutableMapping [str , str ]):
337
339
def __init__ (self , parser : RawConfigParser , name : str ) -> None : ...
@@ -443,10 +445,22 @@ class ParsingError(Error):
443
445
elif sys .version_info >= (3 , 12 ):
444
446
def __init__ (self , source : str ) -> None : ...
445
447
else :
446
- def __init__ (self , source : str | None = None , filename : str | None = None ) -> None : ...
448
+ @overload
449
+ def __init__ (self , source : str , filename : None = None ) -> None : ...
450
+ @overload
451
+ @deprecated ("The `filename` parameter removed in Python 3.12. Use `source` instead." )
452
+ def __init__ (self , source : None = None , filename : str = ...) -> None : ...
447
453
448
454
def append (self , lineno : int , line : str ) -> None : ...
449
455
456
+ if sys .version_info < (3 , 12 ):
457
+ @property
458
+ @deprecated ("Deprecated since Python 3.2; removed in Python 3.12. Use `source` instead." )
459
+ def filename (self ) -> str : ...
460
+ @filename .setter
461
+ @deprecated ("Deprecated since Python 3.2; removed in Python 3.12. Use `source` instead." )
462
+ def filename (self , value : str ) -> None : ...
463
+
450
464
class MissingSectionHeaderError (ParsingError ):
451
465
lineno : int
452
466
line : str
0 commit comments