Skip to content

Remove Python 2 branches from Python 3 stubs #5460

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

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 0 additions & 4 deletions stdlib/@python2/dis.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import types
from opcode import (
EXTENDED_ARG as EXTENDED_ARG,
Expand Down Expand Up @@ -29,6 +28,3 @@ def dis(x: _have_code_or_string = ...) -> None: ...
def distb(tb: types.TracebackType = ...) -> None: ...
def disassemble(co: _have_code, lasti: int = ...) -> None: ...
def disco(co: _have_code, lasti: int = ...) -> None: ...

if sys.version_info >= (3, 0):
def show_code(co: _have_code) -> None: ...
150 changes: 1 addition & 149 deletions stdlib/@python2/socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ SOCK_RAW: SocketKind
SOCK_RDM: SocketKind
SOCK_SEQPACKET: SocketKind

if sys.platform == "linux" and sys.version_info >= (3,):
SOCK_CLOEXEC: SocketKind
SOCK_NONBLOCK: SocketKind

# Address families not mentioned in the docs
AF_AAL5: AddressFamily
AF_APPLETALK: AddressFamily
Expand Down Expand Up @@ -261,88 +257,6 @@ TCP_SYNCNT: int
TCP_WINDOW_CLAMP: int
# Specifically-documented constants

if sys.platform == "linux" and sys.version_info >= (3,):
AF_CAN: AddressFamily
PF_CAN: int
SOL_CAN_BASE: int
SOL_CAN_RAW: int
CAN_EFF_FLAG: int
CAN_EFF_MASK: int
CAN_ERR_FLAG: int
CAN_ERR_MASK: int
CAN_RAW: int
CAN_RAW_ERR_FILTER: int
CAN_RAW_FILTER: int
CAN_RAW_LOOPBACK: int
CAN_RAW_RECV_OWN_MSGS: int
CAN_RTR_FLAG: int
CAN_SFF_MASK: int

CAN_BCM: int
CAN_BCM_TX_SETUP: int
CAN_BCM_TX_DELETE: int
CAN_BCM_TX_READ: int
CAN_BCM_TX_SEND: int
CAN_BCM_RX_SETUP: int
CAN_BCM_RX_DELETE: int
CAN_BCM_RX_READ: int
CAN_BCM_TX_STATUS: int
CAN_BCM_TX_EXPIRED: int
CAN_BCM_RX_STATUS: int
CAN_BCM_RX_TIMEOUT: int
CAN_BCM_RX_CHANGED: int

CAN_RAW_FD_FRAMES: int

if sys.platform == "linux" and sys.version_info >= (3, 8):
CAN_BCM_SETTIMER: int
CAN_BCM_STARTTIMER: int
CAN_BCM_TX_COUNTEVT: int
CAN_BCM_TX_ANNOUNCE: int
CAN_BCM_TX_CP_CAN_ID: int
CAN_BCM_RX_FILTER_ID: int
CAN_BCM_RX_CHECK_DLC: int
CAN_BCM_RX_NO_AUTOTIMER: int
CAN_BCM_RX_ANNOUNCE_RESUME: int
CAN_BCM_TX_RESET_MULTI_IDX: int
CAN_BCM_RX_RTR_FRAME: int
CAN_BCM_CAN_FD_FRAME: int

if sys.platform == "linux" and sys.version_info >= (3, 7):
CAN_ISOTP: int

if sys.platform == "linux" and sys.version_info >= (3, 9):
CAN_J1939: int

J1939_MAX_UNICAST_ADDR: int
J1939_IDLE_ADDR: int
J1939_NO_ADDR: int
J1939_NO_NAME: int
J1939_PGN_REQUEST: int
J1939_PGN_ADDRESS_CLAIMED: int
J1939_PGN_ADDRESS_COMMANDED: int
J1939_PGN_PDU1_MAX: int
J1939_PGN_MAX: int
J1939_NO_PGN: int

SO_J1939_FILTER: int
SO_J1939_PROMISC: int
SO_J1939_SEND_PRIO: int
SO_J1939_ERRQUEUE: int

SCM_J1939_DEST_ADDR: int
SCM_J1939_DEST_NAME: int
SCM_J1939_PRIO: int
SCM_J1939_ERRQUEUE: int

J1939_NLA_PAD: int
J1939_NLA_BYTES_ACKED: int

J1939_EE_INFO_NONE: int
J1939_EE_INFO_TX_ABORT: int

J1939_FILTER_MAX: int

if sys.platform == "linux":
AF_PACKET: AddressFamily
PF_PACKET: int
Expand All @@ -354,29 +268,6 @@ if sys.platform == "linux":
PACKET_OTHERHOST: int
PACKET_OUTGOING: int

if sys.platform == "linux" and sys.version_info >= (3,):
AF_RDS: AddressFamily
PF_RDS: int
SOL_RDS: int
RDS_CANCEL_SENT_TO: int
RDS_CMSG_RDMA_ARGS: int
RDS_CMSG_RDMA_DEST: int
RDS_CMSG_RDMA_MAP: int
RDS_CMSG_RDMA_STATUS: int
RDS_CMSG_RDMA_UPDATE: int
RDS_CONG_MONITOR: int
RDS_FREE_MR: int
RDS_GET_MR: int
RDS_GET_MR_FOR_DEST: int
RDS_RDMA_DONTWAIT: int
RDS_RDMA_FENCE: int
RDS_RDMA_INVALIDATE: int
RDS_RDMA_NOTIFY_ME: int
RDS_RDMA_READWRITE: int
RDS_RDMA_SILENT: int
RDS_RDMA_USE_ONCE: int
RDS_RECVERR: int

if sys.platform == "win32":
SIO_RCVALL: int
SIO_KEEPALIVE_VALS: int
Expand Down Expand Up @@ -413,38 +304,8 @@ if sys.platform == "linux":
TIPC_WITHDRAWN: int
TIPC_ZONE_SCOPE: int

if sys.platform == "linux" and sys.version_info >= (3, 6):
AF_ALG: AddressFamily
SOL_ALG: int
ALG_OP_DECRYPT: int
ALG_OP_ENCRYPT: int
ALG_OP_SIGN: int
ALG_OP_VERIFY: int
ALG_SET_AEAD_ASSOCLEN: int
ALG_SET_AEAD_AUTHSIZE: int
ALG_SET_IV: int
ALG_SET_KEY: int
ALG_SET_OP: int
ALG_SET_PUBKEY: int

if sys.platform == "linux" and sys.version_info >= (3, 7):
AF_VSOCK: AddressFamily
IOCTL_VM_SOCKETS_GET_LOCAL_CID: int
VMADDR_CID_ANY: int
VMADDR_CID_HOST: int
VMADDR_PORT_ANY: int
SO_VM_SOCKETS_BUFFER_MAX_SIZE: int
SO_VM_SOCKETS_BUFFER_SIZE: int
SO_VM_SOCKETS_BUFFER_MIN_SIZE: int
VM_SOCKETS_INVALID_VERSION: int

AF_LINK: AddressFamily # Availability: BSD, macOS

# BDADDR_* and HCI_* listed with other bluetooth constants below

if sys.platform == "linux" and sys.version_info >= (3, 8):
AF_QIPCRTR: AddressFamily

# Semi-documented constants
# (Listed under "Socket families" in the docs, but not "Constants")

Expand Down Expand Up @@ -542,9 +403,7 @@ class socket:
@overload
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
def gettimeout(self) -> Optional[float]: ...
if sys.platform == "win32" and sys.version_info >= (3, 6):
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ...
elif sys.platform == "win32":
if sys.platform == "win32":
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ...
def listen(self, __backlog: int) -> None: ...
# Note that the makefile's documented windows-specific behavior is not represented
Expand All @@ -559,10 +418,6 @@ class socket:
def sendto(self, data: bytes, address: _Address) -> int: ...
@overload
def sendto(self, data: bytes, flags: int, address: _Address) -> int: ...
if sys.platform == "linux" and sys.version_info >= (3, 6):
def sendmsg_afalg(
self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
) -> int: ...
def setblocking(self, flag: bool) -> None: ...
def settimeout(self, value: Optional[float]) -> None: ...
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
Expand All @@ -579,9 +434,6 @@ def create_connection(
) -> socket: ...
def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ...

if sys.platform == "win32" and sys.version_info >= (3, 3):
def fromshare(info: bytes) -> socket: ...

# the 5th tuple item is an address
def getaddrinfo(
host: Optional[Union[bytearray, bytes, Text]],
Expand Down
7 changes: 2 additions & 5 deletions stdlib/__future__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ nested_scopes: _Feature
print_function: _Feature
unicode_literals: _Feature
with_statement: _Feature
if sys.version_info >= (3, 0):
barry_as_FLUFL: _Feature

if sys.version_info >= (3, 5):
generator_stop: _Feature
barry_as_FLUFL: _Feature
generator_stop: _Feature

if sys.version_info >= (3, 7):
annotations: _Feature
Expand Down
22 changes: 6 additions & 16 deletions stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
_Handler = Callable[[Exception], Tuple[Text, int]]
_String = Union[bytes, str]
_Errors = Union[str, Text, None]
if sys.version_info >= (3, 0):
_Decodable = bytes
_Encodable = str
else:
_Decodable = Union[bytes, Text]
_Encodable = Union[bytes, Text]
_Decodable = bytes
_Encodable = str

# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap(object):
Expand All @@ -28,10 +24,6 @@ def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) ->
def charmap_build(__map: Text) -> _MapT: ...
def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...

if sys.version_info < (3, 2):
def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...

def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ...
def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ...
def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ...
Expand Down Expand Up @@ -74,9 +66,7 @@ def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int
if sys.platform == "win32":
def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
if sys.version_info >= (3, 0):
def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
if sys.version_info >= (3, 6):
def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
14 changes: 3 additions & 11 deletions stdlib/_csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,12 @@ _DialectLike = Union[str, Dialect, Type[Dialect]]
class _reader(Iterator[List[str]]):
dialect: Dialect
line_num: int
if sys.version_info >= (3, 0):
def __next__(self) -> List[str]: ...
else:
def next(self) -> List[str]: ...
def __next__(self) -> List[str]: ...

class _writer:
dialect: Dialect

if sys.version_info >= (3, 5):
def writerow(self, row: Iterable[Any]) -> Any: ...
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
else:
def writerow(self, row: Sequence[Any]) -> Any: ...
def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ...
def writerow(self, row: Iterable[Any]) -> Any: ...
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...

class _Writer(Protocol):
def write(self, s: str) -> Any: ...
Expand Down
22 changes: 7 additions & 15 deletions stdlib/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -348,24 +348,17 @@ def tparm(
) -> bytes: ...
def typeahead(__fd: int) -> None: ...
def unctrl(__ch: _chtype) -> bytes: ...

if sys.version_info >= (3, 3):
def unget_wch(__ch: Union[int, str]) -> None: ...

def unget_wch(__ch: Union[int, str]) -> None: ...
def ungetch(__ch: _chtype) -> None: ...
def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ...

if sys.version_info >= (3, 5):
def update_lines_cols() -> int: ...

def update_lines_cols() -> int: ...
def use_default_colors() -> None: ...
def use_env(__flag: bool) -> None: ...

class error(Exception): ...

class _CursesWindow:
if sys.version_info >= (3, 3):
encoding: str
encoding: str
@overload
def addch(self, ch: _chtype, attr: int = ...) -> None: ...
@overload
Expand Down Expand Up @@ -429,11 +422,10 @@ class _CursesWindow:
def getch(self) -> int: ...
@overload
def getch(self, y: int, x: int) -> int: ...
if sys.version_info >= (3, 3):
@overload
def get_wch(self) -> Union[int, str]: ...
@overload
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
@overload
def get_wch(self) -> Union[int, str]: ...
@overload
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
@overload
def getkey(self) -> str: ...
@overload
Expand Down
Loading