Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17dcea4

Browse files
Akulisrittau
andauthored
Akuli and srittau: Remove Python 2 branches from Python 3 stubs (#5461)
* run script and do some manual changes (Akuli) * do the whole thing manually (srittau) * merge changes (Akuli) Co-authored-by: Sebastian Rittau <[email protected]>
1 parent b0ef852 commit 17dcea4

106 files changed

Lines changed: 1545 additions & 3281 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

stdlib/@python2/dis.pyi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import types
32
from opcode import (
43
EXTENDED_ARG as EXTENDED_ARG,
@@ -29,6 +28,3 @@ def dis(x: _have_code_or_string = ...) -> None: ...
2928
def distb(tb: types.TracebackType = ...) -> None: ...
3029
def disassemble(co: _have_code, lasti: int = ...) -> None: ...
3130
def disco(co: _have_code, lasti: int = ...) -> None: ...
32-
33-
if sys.version_info >= (3, 0):
34-
def show_code(co: _have_code) -> None: ...

stdlib/@python2/socket.pyi

Lines changed: 1 addition & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ SOCK_RAW: SocketKind
3131
SOCK_RDM: SocketKind
3232
SOCK_SEQPACKET: SocketKind
3333

34-
if sys.platform == "linux" and sys.version_info >= (3,):
35-
SOCK_CLOEXEC: SocketKind
36-
SOCK_NONBLOCK: SocketKind
37-
3834
# Address families not mentioned in the docs
3935
AF_AAL5: AddressFamily
4036
AF_APPLETALK: AddressFamily
@@ -261,88 +257,6 @@ TCP_SYNCNT: int
261257
TCP_WINDOW_CLAMP: int
262258
# Specifically-documented constants
263259

264-
if sys.platform == "linux" and sys.version_info >= (3,):
265-
AF_CAN: AddressFamily
266-
PF_CAN: int
267-
SOL_CAN_BASE: int
268-
SOL_CAN_RAW: int
269-
CAN_EFF_FLAG: int
270-
CAN_EFF_MASK: int
271-
CAN_ERR_FLAG: int
272-
CAN_ERR_MASK: int
273-
CAN_RAW: int
274-
CAN_RAW_ERR_FILTER: int
275-
CAN_RAW_FILTER: int
276-
CAN_RAW_LOOPBACK: int
277-
CAN_RAW_RECV_OWN_MSGS: int
278-
CAN_RTR_FLAG: int
279-
CAN_SFF_MASK: int
280-
281-
CAN_BCM: int
282-
CAN_BCM_TX_SETUP: int
283-
CAN_BCM_TX_DELETE: int
284-
CAN_BCM_TX_READ: int
285-
CAN_BCM_TX_SEND: int
286-
CAN_BCM_RX_SETUP: int
287-
CAN_BCM_RX_DELETE: int
288-
CAN_BCM_RX_READ: int
289-
CAN_BCM_TX_STATUS: int
290-
CAN_BCM_TX_EXPIRED: int
291-
CAN_BCM_RX_STATUS: int
292-
CAN_BCM_RX_TIMEOUT: int
293-
CAN_BCM_RX_CHANGED: int
294-
295-
CAN_RAW_FD_FRAMES: int
296-
297-
if sys.platform == "linux" and sys.version_info >= (3, 8):
298-
CAN_BCM_SETTIMER: int
299-
CAN_BCM_STARTTIMER: int
300-
CAN_BCM_TX_COUNTEVT: int
301-
CAN_BCM_TX_ANNOUNCE: int
302-
CAN_BCM_TX_CP_CAN_ID: int
303-
CAN_BCM_RX_FILTER_ID: int
304-
CAN_BCM_RX_CHECK_DLC: int
305-
CAN_BCM_RX_NO_AUTOTIMER: int
306-
CAN_BCM_RX_ANNOUNCE_RESUME: int
307-
CAN_BCM_TX_RESET_MULTI_IDX: int
308-
CAN_BCM_RX_RTR_FRAME: int
309-
CAN_BCM_CAN_FD_FRAME: int
310-
311-
if sys.platform == "linux" and sys.version_info >= (3, 7):
312-
CAN_ISOTP: int
313-
314-
if sys.platform == "linux" and sys.version_info >= (3, 9):
315-
CAN_J1939: int
316-
317-
J1939_MAX_UNICAST_ADDR: int
318-
J1939_IDLE_ADDR: int
319-
J1939_NO_ADDR: int
320-
J1939_NO_NAME: int
321-
J1939_PGN_REQUEST: int
322-
J1939_PGN_ADDRESS_CLAIMED: int
323-
J1939_PGN_ADDRESS_COMMANDED: int
324-
J1939_PGN_PDU1_MAX: int
325-
J1939_PGN_MAX: int
326-
J1939_NO_PGN: int
327-
328-
SO_J1939_FILTER: int
329-
SO_J1939_PROMISC: int
330-
SO_J1939_SEND_PRIO: int
331-
SO_J1939_ERRQUEUE: int
332-
333-
SCM_J1939_DEST_ADDR: int
334-
SCM_J1939_DEST_NAME: int
335-
SCM_J1939_PRIO: int
336-
SCM_J1939_ERRQUEUE: int
337-
338-
J1939_NLA_PAD: int
339-
J1939_NLA_BYTES_ACKED: int
340-
341-
J1939_EE_INFO_NONE: int
342-
J1939_EE_INFO_TX_ABORT: int
343-
344-
J1939_FILTER_MAX: int
345-
346260
if sys.platform == "linux":
347261
AF_PACKET: AddressFamily
348262
PF_PACKET: int
@@ -354,29 +268,6 @@ if sys.platform == "linux":
354268
PACKET_OTHERHOST: int
355269
PACKET_OUTGOING: int
356270

357-
if sys.platform == "linux" and sys.version_info >= (3,):
358-
AF_RDS: AddressFamily
359-
PF_RDS: int
360-
SOL_RDS: int
361-
RDS_CANCEL_SENT_TO: int
362-
RDS_CMSG_RDMA_ARGS: int
363-
RDS_CMSG_RDMA_DEST: int
364-
RDS_CMSG_RDMA_MAP: int
365-
RDS_CMSG_RDMA_STATUS: int
366-
RDS_CMSG_RDMA_UPDATE: int
367-
RDS_CONG_MONITOR: int
368-
RDS_FREE_MR: int
369-
RDS_GET_MR: int
370-
RDS_GET_MR_FOR_DEST: int
371-
RDS_RDMA_DONTWAIT: int
372-
RDS_RDMA_FENCE: int
373-
RDS_RDMA_INVALIDATE: int
374-
RDS_RDMA_NOTIFY_ME: int
375-
RDS_RDMA_READWRITE: int
376-
RDS_RDMA_SILENT: int
377-
RDS_RDMA_USE_ONCE: int
378-
RDS_RECVERR: int
379-
380271
if sys.platform == "win32":
381272
SIO_RCVALL: int
382273
SIO_KEEPALIVE_VALS: int
@@ -413,38 +304,8 @@ if sys.platform == "linux":
413304
TIPC_WITHDRAWN: int
414305
TIPC_ZONE_SCOPE: int
415306

416-
if sys.platform == "linux" and sys.version_info >= (3, 6):
417-
AF_ALG: AddressFamily
418-
SOL_ALG: int
419-
ALG_OP_DECRYPT: int
420-
ALG_OP_ENCRYPT: int
421-
ALG_OP_SIGN: int
422-
ALG_OP_VERIFY: int
423-
ALG_SET_AEAD_ASSOCLEN: int
424-
ALG_SET_AEAD_AUTHSIZE: int
425-
ALG_SET_IV: int
426-
ALG_SET_KEY: int
427-
ALG_SET_OP: int
428-
ALG_SET_PUBKEY: int
429-
430-
if sys.platform == "linux" and sys.version_info >= (3, 7):
431-
AF_VSOCK: AddressFamily
432-
IOCTL_VM_SOCKETS_GET_LOCAL_CID: int
433-
VMADDR_CID_ANY: int
434-
VMADDR_CID_HOST: int
435-
VMADDR_PORT_ANY: int
436-
SO_VM_SOCKETS_BUFFER_MAX_SIZE: int
437-
SO_VM_SOCKETS_BUFFER_SIZE: int
438-
SO_VM_SOCKETS_BUFFER_MIN_SIZE: int
439-
VM_SOCKETS_INVALID_VERSION: int
440-
441307
AF_LINK: AddressFamily # Availability: BSD, macOS
442308

443-
# BDADDR_* and HCI_* listed with other bluetooth constants below
444-
445-
if sys.platform == "linux" and sys.version_info >= (3, 8):
446-
AF_QIPCRTR: AddressFamily
447-
448309
# Semi-documented constants
449310
# (Listed under "Socket families" in the docs, but not "Constants")
450311

@@ -542,9 +403,7 @@ class socket:
542403
@overload
543404
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
544405
def gettimeout(self) -> Optional[float]: ...
545-
if sys.platform == "win32" and sys.version_info >= (3, 6):
546-
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ...
547-
elif sys.platform == "win32":
406+
if sys.platform == "win32":
548407
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ...
549408
def listen(self, __backlog: int) -> None: ...
550409
# Note that the makefile's documented windows-specific behavior is not represented
@@ -559,10 +418,6 @@ class socket:
559418
def sendto(self, data: bytes, address: _Address) -> int: ...
560419
@overload
561420
def sendto(self, data: bytes, flags: int, address: _Address) -> int: ...
562-
if sys.platform == "linux" and sys.version_info >= (3, 6):
563-
def sendmsg_afalg(
564-
self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
565-
) -> int: ...
566421
def setblocking(self, flag: bool) -> None: ...
567422
def settimeout(self, value: Optional[float]) -> None: ...
568423
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
@@ -579,9 +434,6 @@ def create_connection(
579434
) -> socket: ...
580435
def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ...
581436

582-
if sys.platform == "win32" and sys.version_info >= (3, 3):
583-
def fromshare(info: bytes) -> socket: ...
584-
585437
# the 5th tuple item is an address
586438
def getaddrinfo(
587439
host: Optional[Union[bytearray, bytes, Text]],

stdlib/__future__.pyi

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ nested_scopes: _Feature
1414
print_function: _Feature
1515
unicode_literals: _Feature
1616
with_statement: _Feature
17-
if sys.version_info >= (3, 0):
18-
barry_as_FLUFL: _Feature
19-
20-
if sys.version_info >= (3, 5):
21-
generator_stop: _Feature
17+
barry_as_FLUFL: _Feature
18+
generator_stop: _Feature
2219

2320
if sys.version_info >= (3, 7):
2421
annotations: _Feature

stdlib/_codecs.pyi

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
66
_Handler = Callable[[Exception], Tuple[Text, int]]
77
_String = Union[bytes, str]
88
_Errors = Union[str, Text, None]
9-
if sys.version_info >= (3, 0):
10-
_Decodable = bytes
11-
_Encodable = str
12-
else:
13-
_Decodable = Union[bytes, Text]
14-
_Encodable = Union[bytes, Text]
9+
_Decodable = bytes
10+
_Encodable = str
1511

1612
# This type is not exposed; it is defined in unicodeobject.c
1713
class _EncodingMap(object):
@@ -28,10 +24,6 @@ def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) ->
2824
def charmap_build(__map: Text) -> _MapT: ...
2925
def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
3026
def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
31-
32-
if sys.version_info < (3, 2):
33-
def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
34-
3527
def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ...
3628
def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ...
3729
def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ...
@@ -74,9 +66,7 @@ def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int
7466
if sys.platform == "win32":
7567
def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
7668
def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
77-
if sys.version_info >= (3, 0):
78-
def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
79-
def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
80-
if sys.version_info >= (3, 6):
81-
def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
82-
def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
69+
def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
70+
def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
71+
def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
72+
def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...

stdlib/_csv.pyi

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import sys
2-
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Sequence, Text, Type, Union
1+
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Text, Type, Union
32

43
QUOTE_ALL: int
54
QUOTE_MINIMAL: int
@@ -24,20 +23,12 @@ _DialectLike = Union[str, Dialect, Type[Dialect]]
2423
class _reader(Iterator[List[str]]):
2524
dialect: Dialect
2625
line_num: int
27-
if sys.version_info >= (3, 0):
28-
def __next__(self) -> List[str]: ...
29-
else:
30-
def next(self) -> List[str]: ...
26+
def __next__(self) -> List[str]: ...
3127

3228
class _writer:
3329
dialect: Dialect
34-
35-
if sys.version_info >= (3, 5):
36-
def writerow(self, row: Iterable[Any]) -> Any: ...
37-
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
38-
else:
39-
def writerow(self, row: Sequence[Any]) -> Any: ...
40-
def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ...
30+
def writerow(self, row: Iterable[Any]) -> Any: ...
31+
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
4132

4233
class _Writer(Protocol):
4334
def write(self, s: str) -> Any: ...

stdlib/_curses.pyi

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -348,24 +348,17 @@ def tparm(
348348
) -> bytes: ...
349349
def typeahead(__fd: int) -> None: ...
350350
def unctrl(__ch: _chtype) -> bytes: ...
351-
352-
if sys.version_info >= (3, 3):
353-
def unget_wch(__ch: Union[int, str]) -> None: ...
354-
351+
def unget_wch(__ch: Union[int, str]) -> None: ...
355352
def ungetch(__ch: _chtype) -> None: ...
356353
def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ...
357-
358-
if sys.version_info >= (3, 5):
359-
def update_lines_cols() -> int: ...
360-
354+
def update_lines_cols() -> int: ...
361355
def use_default_colors() -> None: ...
362356
def use_env(__flag: bool) -> None: ...
363357

364358
class error(Exception): ...
365359

366360
class _CursesWindow:
367-
if sys.version_info >= (3, 3):
368-
encoding: str
361+
encoding: str
369362
@overload
370363
def addch(self, ch: _chtype, attr: int = ...) -> None: ...
371364
@overload
@@ -429,11 +422,10 @@ class _CursesWindow:
429422
def getch(self) -> int: ...
430423
@overload
431424
def getch(self, y: int, x: int) -> int: ...
432-
if sys.version_info >= (3, 3):
433-
@overload
434-
def get_wch(self) -> Union[int, str]: ...
435-
@overload
436-
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
425+
@overload
426+
def get_wch(self) -> Union[int, str]: ...
427+
@overload
428+
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
437429
@overload
438430
def getkey(self) -> str: ...
439431
@overload

0 commit comments

Comments
 (0)