Skip to content

Commit 9707cb0

Browse files
AlexWaygoodAkulipre-commit-ci[bot]
authored
Python 3.11 removals in stdlib (#6374)
Co-authored-by: Akuli <akuviljanen17@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ab026bf commit 9707cb0

13 files changed

Lines changed: 159 additions & 88 deletions

File tree

stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ decimal: 2.7-
103103
difflib: 2.7-
104104
dis: 2.7-
105105
distutils: 2.7-
106+
distutils.command.bdist_msi: 2.7-3.10
106107
doctest: 2.7-
107108
dummy_threading: 2.7-
108109
email: 2.7-

stdlib/_tkinter.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any
23
from typing_extensions import Literal, final
34

@@ -68,7 +69,8 @@ class TkappType:
6869
quit: Any
6970
record: Any
7071
setvar: Any
71-
split: Any
72+
if sys.version_info < (3, 11):
73+
split: Any
7274
splitlist: Any
7375
unsetvar: Any
7476
wantobjects: Any

stdlib/asyncio/__init__.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from typing import Type
33

44
from .base_events import BaseEventLoop as BaseEventLoop
5-
from .coroutines import coroutine as coroutine, iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction
5+
from .coroutines import iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction
66
from .events import (
77
AbstractEventLoop as AbstractEventLoop,
88
AbstractEventLoopPolicy as AbstractEventLoopPolicy,
@@ -71,6 +71,8 @@ from .transports import (
7171
WriteTransport as WriteTransport,
7272
)
7373

74+
if sys.version_info < (3, 11):
75+
from .coroutines import coroutine as coroutine
7476
if sys.version_info >= (3, 7):
7577
from .events import get_running_loop as get_running_loop
7678
if sys.version_info >= (3, 8):

stdlib/asyncio/base_events.pyi

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,35 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
285285
async def connect_accepted_socket(
286286
self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...
287287
) -> _TransProtPair: ...
288-
async def create_datagram_endpoint(
289-
self,
290-
protocol_factory: _ProtocolFactory,
291-
local_addr: tuple[str, int] | None = ...,
292-
remote_addr: tuple[str, int] | None = ...,
293-
*,
294-
family: int = ...,
295-
proto: int = ...,
296-
flags: int = ...,
297-
reuse_address: bool | None = ...,
298-
reuse_port: bool | None = ...,
299-
allow_broadcast: bool | None = ...,
300-
sock: socket | None = ...,
301-
) -> _TransProtPair: ...
288+
if sys.version_info < (3, 11):
289+
async def create_datagram_endpoint(
290+
self,
291+
protocol_factory: _ProtocolFactory,
292+
local_addr: tuple[str, int] | None = ...,
293+
remote_addr: tuple[str, int] | None = ...,
294+
*,
295+
family: int = ...,
296+
proto: int = ...,
297+
flags: int = ...,
298+
reuse_address: bool | None = ...,
299+
reuse_port: bool | None = ...,
300+
allow_broadcast: bool | None = ...,
301+
sock: socket | None = ...,
302+
) -> _TransProtPair: ...
303+
else:
304+
async def create_datagram_endpoint(
305+
self,
306+
protocol_factory: _ProtocolFactory,
307+
local_addr: tuple[str, int] | None = ...,
308+
remote_addr: tuple[str, int] | None = ...,
309+
*,
310+
family: int = ...,
311+
proto: int = ...,
312+
flags: int = ...,
313+
reuse_port: bool | None = ...,
314+
allow_broadcast: bool | None = ...,
315+
sock: socket | None = ...,
316+
) -> _TransProtPair: ...
302317
# Pipes and subprocesses.
303318
async def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
304319
async def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...

stdlib/asyncio/coroutines.pyi

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import sys
22
import types
3-
from collections.abc import Callable, Coroutine
4-
from typing import Any, TypeVar
3+
from collections.abc import Coroutine
4+
from typing import Any
55
from typing_extensions import TypeGuard
66

7-
_F = TypeVar("_F", bound=Callable[..., Any])
7+
if sys.version_info < (3, 11):
8+
from collections.abc import Callable
9+
from typing import TypeVar
10+
11+
_F = TypeVar("_F", bound=Callable[..., Any])
12+
def coroutine(func: _F) -> _F: ...
813

9-
def coroutine(func: _F) -> _F: ...
1014
def iscoroutinefunction(func: object) -> bool: ...
1115

1216
if sys.version_info < (3, 8):

stdlib/binascii.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ def a2b_base64(__data: str | bytes) -> bytes: ...
1212
def b2a_base64(__data: bytes, *, newline: bool = ...) -> bytes: ...
1313
def a2b_qp(data: str | bytes, header: bool = ...) -> bytes: ...
1414
def b2a_qp(data: bytes, quotetabs: bool = ..., istext: bool = ..., header: bool = ...) -> bytes: ...
15-
def a2b_hqx(__data: str | bytes) -> bytes: ...
16-
def rledecode_hqx(__data: bytes) -> bytes: ...
17-
def rlecode_hqx(__data: bytes) -> bytes: ...
18-
def b2a_hqx(__data: bytes) -> bytes: ...
15+
16+
if sys.version_info < (3, 11):
17+
def a2b_hqx(__data: str | bytes) -> bytes: ...
18+
def rledecode_hqx(__data: bytes) -> bytes: ...
19+
def rlecode_hqx(__data: bytes) -> bytes: ...
20+
def b2a_hqx(__data: bytes) -> bytes: ...
21+
1922
def crc_hqx(__data: bytes, __crc: int) -> int: ...
2023
def crc32(__data: bytes, __crc: int = ...) -> int: ...
2124
def b2a_hex(__data: bytes) -> bytes: ...

stdlib/configparser.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ class RawConfigParser(_parser):
137137
def optionxform(self, optionstr: str) -> str: ...
138138

139139
class ConfigParser(RawConfigParser): ...
140-
class SafeConfigParser(ConfigParser): ...
140+
141+
if sys.version_info < (3, 11):
142+
class SafeConfigParser(ConfigParser): ...
141143

142144
class SectionProxy(MutableMapping[str, str]):
143145
def __init__(self, parser: RawConfigParser, name: str) -> None: ...

stdlib/fileinput.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]):
8585
def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ...
8686
def __iter__(self) -> Iterator[AnyStr]: ...
8787
def __next__(self) -> AnyStr: ...
88-
def __getitem__(self, i: int) -> AnyStr: ...
88+
if sys.version_info < (3, 11):
89+
def __getitem__(self, i: int) -> AnyStr: ...
8990
def nextfile(self) -> None: ...
9091
def readline(self) -> AnyStr: ...
9192
def filename(self) -> str: ...

stdlib/gettext.pyi

Lines changed: 69 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class NullTranslations:
1616
def npgettext(self, context: str, msgid1: str, msgid2: str, n: int) -> str: ...
1717
def info(self) -> Any: ...
1818
def charset(self) -> Any: ...
19-
def output_charset(self) -> Any: ...
20-
def set_output_charset(self, charset: str) -> None: ...
19+
if sys.version_info < (3, 11):
20+
def output_charset(self) -> Any: ...
21+
def set_output_charset(self, charset: str) -> None: ...
2122
def install(self, names: Container[str] | None = ...) -> None: ...
2223

2324
class GNUTranslations(NullTranslations):
@@ -30,52 +31,83 @@ def find(domain: str, localedir: StrPath | None = ..., languages: Iterable[str]
3031

3132
_T = TypeVar("_T")
3233

33-
@overload
34-
def translation(
35-
domain: str,
36-
localedir: StrPath | None = ...,
37-
languages: Iterable[str] | None = ...,
38-
class_: None = ...,
39-
fallback: bool = ...,
40-
codeset: str | None = ...,
41-
) -> NullTranslations: ...
42-
@overload
43-
def translation(
44-
domain: str,
45-
localedir: StrPath | None = ...,
46-
languages: Iterable[str] | None = ...,
47-
class_: Type[_T] = ...,
48-
fallback: Literal[False] = ...,
49-
codeset: str | None = ...,
50-
) -> _T: ...
51-
@overload
52-
def translation(
53-
domain: str,
54-
localedir: StrPath | None = ...,
55-
languages: Iterable[str] | None = ...,
56-
class_: Type[Any] = ...,
57-
fallback: Literal[True] = ...,
58-
codeset: str | None = ...,
59-
) -> Any: ...
60-
def install(
61-
domain: str, localedir: StrPath | None = ..., codeset: str | None = ..., names: Container[str] | None = ...
62-
) -> None: ...
34+
if sys.version_info < (3, 11):
35+
@overload
36+
def translation(
37+
domain: str,
38+
localedir: StrPath | None = ...,
39+
languages: Iterable[str] | None = ...,
40+
class_: None = ...,
41+
fallback: bool = ...,
42+
codeset: str | None = ...,
43+
) -> NullTranslations: ...
44+
@overload
45+
def translation(
46+
domain: str,
47+
localedir: StrPath | None = ...,
48+
languages: Iterable[str] | None = ...,
49+
class_: Type[_T] = ...,
50+
fallback: Literal[False] = ...,
51+
codeset: str | None = ...,
52+
) -> _T: ...
53+
@overload
54+
def translation(
55+
domain: str,
56+
localedir: StrPath | None = ...,
57+
languages: Iterable[str] | None = ...,
58+
class_: Type[Any] = ...,
59+
fallback: Literal[True] = ...,
60+
codeset: str | None = ...,
61+
) -> Any: ...
62+
def install(
63+
domain: str, localedir: StrPath | None = ..., codeset: str | None = ..., names: Container[str] | None = ...
64+
) -> None: ...
65+
66+
else:
67+
@overload
68+
def translation(
69+
domain: str,
70+
localedir: StrPath | None = ...,
71+
languages: Iterable[str] | None = ...,
72+
class_: None = ...,
73+
fallback: bool = ...,
74+
) -> NullTranslations: ...
75+
@overload
76+
def translation(
77+
domain: str,
78+
localedir: StrPath | None = ...,
79+
languages: Iterable[str] | None = ...,
80+
class_: Type[_T] = ...,
81+
fallback: Literal[False] = ...,
82+
) -> _T: ...
83+
@overload
84+
def translation(
85+
domain: str,
86+
localedir: StrPath | None = ...,
87+
languages: Iterable[str] | None = ...,
88+
class_: Type[Any] = ...,
89+
fallback: Literal[True] = ...,
90+
) -> Any: ...
91+
def install(domain: str, localedir: StrPath | None = ..., names: Container[str] | None = ...) -> None: ...
92+
6393
def textdomain(domain: str | None = ...) -> str: ...
6494
def bindtextdomain(domain: str, localedir: StrPath | None = ...) -> str: ...
65-
def bind_textdomain_codeset(domain: str, codeset: str | None = ...) -> str: ...
6695
def dgettext(domain: str, message: str) -> str: ...
67-
def ldgettext(domain: str, message: str) -> str: ...
6896
def dngettext(domain: str, msgid1: str, msgid2: str, n: int) -> str: ...
69-
def ldngettext(domain: str, msgid1: str, msgid2: str, n: int) -> str: ...
7097
def gettext(message: str) -> str: ...
71-
def lgettext(message: str) -> str: ...
7298
def ngettext(msgid1: str, msgid2: str, n: int) -> str: ...
73-
def lngettext(msgid1: str, msgid2: str, n: int) -> str: ...
7499

75100
if sys.version_info >= (3, 8):
76101
def pgettext(context: str, message: str) -> str: ...
77102
def dpgettext(domain: str, context: str, message: str) -> str: ...
78103
def npgettext(context: str, msgid1: str, msgid2: str, n: int) -> str: ...
79104
def dnpgettext(domain: str, context: str, msgid1: str, msgid2: str, n: int) -> str: ...
80105

106+
if sys.version_info < (3, 11):
107+
def lgettext(message: str) -> str: ...
108+
def ldgettext(domain: str, message: str) -> str: ...
109+
def lngettext(msgid1: str, msgid2: str, n: int) -> str: ...
110+
def ldngettext(domain: str, msgid1: str, msgid2: str, n: int) -> str: ...
111+
def bind_textdomain_codeset(domain: str, codeset: str | None = ...) -> str: ...
112+
81113
Catalog = translation

stdlib/inspect.pyi

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,20 @@ class BoundArguments:
247247
def getclasstree(classes: list[type], unique: bool = ...) -> list[Any]: ...
248248
def walktree(classes: list[type], children: dict[Type[Any], list[type]], parent: Type[Any] | None) -> list[Any]: ...
249249

250-
class ArgSpec(NamedTuple):
251-
args: list[str]
252-
varargs: str | None
253-
keywords: str | None
254-
defaults: Tuple[Any, ...]
255-
256250
class Arguments(NamedTuple):
257251
args: list[str]
258252
varargs: str | None
259253
varkw: str | None
260254

261255
def getargs(co: CodeType) -> Arguments: ...
262-
def getargspec(func: object) -> ArgSpec: ...
256+
257+
if sys.version_info < (3, 11):
258+
class ArgSpec(NamedTuple):
259+
args: list[str]
260+
varargs: str | None
261+
keywords: str | None
262+
defaults: Tuple[Any, ...]
263+
def getargspec(func: object) -> ArgSpec: ...
263264

264265
class FullArgSpec(NamedTuple):
265266
args: list[str]
@@ -281,21 +282,24 @@ class ArgInfo(NamedTuple):
281282
def getargvalues(frame: FrameType) -> ArgInfo: ...
282283
def formatannotation(annotation: object, base_module: str | None = ...) -> str: ...
283284
def formatannotationrelativeto(object: object) -> Callable[[object], str]: ...
284-
def formatargspec(
285-
args: list[str],
286-
varargs: str | None = ...,
287-
varkw: str | None = ...,
288-
defaults: Tuple[Any, ...] | None = ...,
289-
kwonlyargs: Sequence[str] | None = ...,
290-
kwonlydefaults: dict[str, Any] | None = ...,
291-
annotations: dict[str, Any] = ...,
292-
formatarg: Callable[[str], str] = ...,
293-
formatvarargs: Callable[[str], str] = ...,
294-
formatvarkw: Callable[[str], str] = ...,
295-
formatvalue: Callable[[Any], str] = ...,
296-
formatreturns: Callable[[Any], str] = ...,
297-
formatannotation: Callable[[Any], str] = ...,
298-
) -> str: ...
285+
286+
if sys.version_info < (3, 11):
287+
def formatargspec(
288+
args: list[str],
289+
varargs: str | None = ...,
290+
varkw: str | None = ...,
291+
defaults: Tuple[Any, ...] | None = ...,
292+
kwonlyargs: Sequence[str] | None = ...,
293+
kwonlydefaults: dict[str, Any] | None = ...,
294+
annotations: dict[str, Any] = ...,
295+
formatarg: Callable[[str], str] = ...,
296+
formatvarargs: Callable[[str], str] = ...,
297+
formatvarkw: Callable[[str], str] = ...,
298+
formatvalue: Callable[[Any], str] = ...,
299+
formatreturns: Callable[[Any], str] = ...,
300+
formatannotation: Callable[[Any], str] = ...,
301+
) -> str: ...
302+
299303
def formatargvalues(
300304
args: list[str],
301305
varargs: str | None,

0 commit comments

Comments
 (0)