16 Commits

Author SHA1 Message Date
Dave Halter d386452478 Make builtins work
One change is a Jedi issue, Jedi cannot really deal with __new__.
The other is a typeshed issue. "function" should not be defined in the stubs.
2019-12-14 11:30:20 +01:00
Dave Halter 772f7a48e6 Make sure that the context manager for sqlite3.Connection works (#3542) 2019-12-14 10:08:37 +01:00
Reid Swan 3e638aa3c3 Add __enter__, __exit__ to IMAP4, make __init__ arguments optional (#3540)
Fixes #3537
2019-12-13 12:05:57 +01:00
Ophir LOJKINE fda384fe0a Add date.__radd__ and datetime.__radd__ (#3539)
Fixes #3538
2019-12-12 18:38:51 +01:00
Alois Klink a06abc5dff Make fieldnames of csv.DictReader Optional (#3534)
Also run stdlib/2and3/csv.pyi through black and isort
2019-12-09 20:22:42 +01:00
Dylan Anthony 9b63192390 Update orjson stub from orjson repository(#3532) 2019-12-06 15:59:27 +01:00
Jacob Ilias Komissar 39ebd62e71 Update stub for socket module (#3451)
* Add new socket constants from 3.7 and 3.8
* Also move TCP_NOTSENT_LOWAT to 3.7 section and add AF_ALG to AddressFamily
* Add missing and updated socket module (and class) methods
* Improve formatting of socket.pyi
    * Add missing line breaks in long function parameters
* Reorder to mirror module documentations
* Fix type of create_server's family parameter
* Add more system conditionals
* Remove CAPI; it isn't an int (it's a PyCapsule)
* Slightly improve version conditions in socket.pyi
* Add incomplete signatures for socket.sendfile and .sendmsg_afalg
* Add VM_SOCKETS_INVALID_VERSION to socket.pyi
* Remove private _GLOBAL_DEFAULT_TIMEOUT from socket.pyi
* Add mode-dependent return types to socket.makefile
    - For Python 2, return and mode types are based on those of 'open'
    - For Python 3, types are based on actual behaviors
* Mark recv_into and recvfrom_into's nbytes argument as optional
* Improve docstring for socket stub
2019-12-05 08:13:06 +01:00
Alois Klink 4766ca0846 Use Literal to improve SpooledTemporaryFile (#3526)
* Run black code formatter on tempfile.pyi
* Use Literal to improve SpooledTemporaryFile

Previously, SpooledTemporaryFile was always an AnyStr.
Now, we load a SpooledTemporaryFile[bytes] if we open in bytes mode,
and we load a SpooledTemporaryFile[str] if we open in str mode.
2019-12-05 08:04:53 +01:00
hauntsaninja 6b321548c4 random: fix type for sample (#3525)
Fixes #3374
2019-12-04 13:07:24 -08:00
cshesse 9a32f0d26a add raw property to BufferedIOBase (#3483) 2019-12-04 08:20:07 +01:00
toppk 86775c803e Minor fixes to cryptography (x509) (#3520) 2019-12-03 18:29:05 +01:00
Jelle Zijlstra 97f830030c Simplify WatchedFileHandler.__init__ (#3506)
Fixes #3502
2019-12-03 14:54:29 +01:00
Jelle Zijlstra d215f502c6 Improve warnings stubs (#3501)
* merge 2and3 for _warnings

* move warn and warn_explicit into _warnings
2019-12-03 14:33:37 +01:00
toppk b585c96e5d padding can take an int or an object (PSS.MAX_LENGTH) (#3521) 2019-12-03 13:26:16 +01:00
Ran Benita 3934da12f6 __future__: add _Feature.compiler_flag (#3522)
Documented under the "CompilerFlag" paragraph here:
https://docs.python.org/3/library/__future__.html
2019-12-03 13:17:03 +01:00
Katelyn Gigante e8647d2d1d A few return annotations for redis client (#3517) 2019-12-02 21:06:11 -08:00
18 changed files with 515 additions and 348 deletions
-16
View File
@@ -1,16 +0,0 @@
from typing import Any, Dict, List, Optional, Tuple, Type
default_action: str
filters: List[Tuple[Any, ...]]
once_registry: Dict[Any, Any]
def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
def warn_explicit(
message: Warning,
category: Optional[Type[Warning]],
filename: str,
lineno: int,
module: Any = ...,
registry: Dict[Any, Any] = ...,
module_globals: Dict[Any, Any] = ...,
) -> None: ...
+9 -7
View File
@@ -7,12 +7,14 @@
# ----- random classes -----
import _random
from typing import (
Any, TypeVar, Sequence, List, Callable, AbstractSet, Union,
overload
)
from typing import AbstractSet, Any, Callable, Iterator, List, Protocol, Sequence, TypeVar, Union, overload
_T = TypeVar('_T')
_T = TypeVar("_T")
_T_co = TypeVar('_T_co', covariant=True)
class _Sampleable(Protocol[_T_co]):
def __iter__(self) -> Iterator[_T_co]: ...
def __len__(self) -> int: ...
class Random(_random.Random):
def __init__(self, x: object = ...) -> None: ...
@@ -28,7 +30,7 @@ class Random(_random.Random):
def randint(self, a: int, b: int) -> int: ...
def choice(self, seq: Sequence[_T]) -> _T: ...
def shuffle(self, x: List[Any], random: Callable[[], None] = ...) -> None: ...
def sample(self, population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def sample(self, population: _Sampleable[_T], k: int) -> List[_T]: ...
def random(self) -> float: ...
def uniform(self, a: float, b: float) -> float: ...
def triangular(self, low: float = ..., high: float = ..., mode: float = ...) -> float: ...
@@ -59,7 +61,7 @@ def randrange(start: int, stop: int, step: int = ...) -> int: ...
def randint(a: int, b: int) -> int: ...
def choice(seq: Sequence[_T]) -> _T: ...
def shuffle(x: List[Any], random: Callable[[], float] = ...) -> None: ...
def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def sample(population: _Sampleable[_T], k: int) -> List[_T]: ...
def random() -> float: ...
def uniform(a: float, b: float) -> float: ...
def triangular(low: float = ..., high: float = ...,
+2 -1
View File
@@ -4,6 +4,7 @@ from typing import List
class _Feature:
def getOptionalRelease(self) -> sys._version_info: ...
def getMandatoryRelease(self) -> sys._version_info: ...
compiler_flag: int
absolute_import: _Feature
division: _Feature
@@ -21,4 +22,4 @@ if sys.version_info >= (3, 5):
if sys.version_info >= (3, 7):
annotations: _Feature
all_feature_names: List[str]
all_feature_names: List[str] # undocumented
+34
View File
@@ -0,0 +1,34 @@
import sys
from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload
if sys.version_info >= (3, 0):
_defaultaction: str
_onceregistry: Dict[Any, Any]
else:
default_action: str
once_registry: Dict[Any, Any]
filters: List[Tuple[Any, ...]]
@overload
def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ...) -> None: ...
@overload
def warn_explicit(
message: str,
category: Type[Warning],
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
) -> None: ...
@overload
def warn_explicit(
message: Warning,
category: Any,
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
) -> None: ...
+37 -25
View File
@@ -1,23 +1,23 @@
from collections import OrderedDict
import sys
from _csv import (
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Error as Error,
_reader,
_writer,
field_size_limit as field_size_limit,
get_dialect as get_dialect,
list_dialects as list_dialects,
reader as reader,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
writer as writer,
)
from collections import OrderedDict
from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, Union
from _csv import (_reader,
_writer,
reader as reader,
writer as writer,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
get_dialect as get_dialect,
list_dialects as list_dialects,
field_size_limit as field_size_limit,
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Error as Error,
)
_Dialect = Union[str, Dialect, Type[Dialect]]
_DictRow = Mapping[str, Any]
@@ -56,7 +56,6 @@ if sys.version_info >= (3, 6):
else:
_DRMapping = Dict[str, str]
class DictReader(Iterator[_DRMapping]):
restkey: Optional[str]
restval: Optional[str]
@@ -64,24 +63,37 @@ class DictReader(Iterator[_DRMapping]):
dialect: _Dialect
line_num: int
fieldnames: Sequence[str]
def __init__(self, f: Iterable[Text], fieldnames: Sequence[str] = ...,
restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ...,
*args: Any, **kwds: Any) -> None: ...
def __init__(
self,
f: Iterable[Text],
fieldnames: Optional[Sequence[str]] = ...,
restkey: Optional[str] = ...,
restval: Optional[str] = ...,
dialect: _Dialect = ...,
*args: Any,
**kwds: Any,
) -> None: ...
def __iter__(self) -> DictReader: ...
if sys.version_info >= (3,):
def __next__(self) -> _DRMapping: ...
else:
def next(self) -> _DRMapping: ...
class DictWriter(object):
fieldnames: Sequence[str]
restval: Optional[Any]
extrasaction: str
writer: _writer
def __init__(self, f: Any, fieldnames: Iterable[str],
restval: Optional[Any] = ..., extrasaction: str = ..., dialect: _Dialect = ...,
*args: Any, **kwds: Any) -> None: ...
def __init__(
self,
f: Any,
fieldnames: Iterable[str],
restval: Optional[Any] = ...,
extrasaction: str = ...,
dialect: _Dialect = ...,
*args: Any,
**kwds: Any,
) -> None: ...
def writeheader(self) -> None: ...
def writerow(self, rowdict: _DictRow) -> None: ...
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...
+4
View File
@@ -72,8 +72,10 @@ class date:
def __gt__(self, other: date) -> bool: ...
if sys.version_info >= (3, 8):
def __add__(self: _S, other: timedelta) -> _S: ...
def __radd__(self: _S, other: timedelta) -> _S: ...
else:
def __add__(self, other: timedelta) -> date: ...
def __radd__(self, other: timedelta) -> date: ...
@overload
def __sub__(self, other: timedelta) -> date: ...
@overload
@@ -299,8 +301,10 @@ class datetime(date):
def __gt__(self, other: datetime) -> bool: ... # type: ignore
if sys.version_info >= (3, 8):
def __add__(self: _S, other: timedelta) -> _S: ...
def __radd__(self: _S, other: timedelta) -> _S: ...
else:
def __add__(self, other: timedelta) -> datetime: ...
def __radd__(self, other: timedelta) -> datetime: ...
@overload # type: ignore
def __sub__(self, other: datetime) -> timedelta: ...
@overload
+3 -1
View File
@@ -29,7 +29,7 @@ class IMAP4:
welcome: bytes = ...
capabilities: Tuple[str] = ...
PROTOCOL_VERSION: str = ...
def __init__(self, host: str, port: int) -> None: ...
def __init__(self, host: str = ..., port: int = ...) -> None: ...
def __getattr__(self, attr: str) -> Any: ...
host: str = ...
port: int = ...
@@ -54,6 +54,8 @@ class IMAP4:
def deleteacl(self, mailbox: str, who: str) -> CommandResults: ...
if sys.version_info >= (3, 5):
def enable(self, capability: str) -> CommandResults: ...
def __enter__(self) -> IMAP4: ...
def __exit__(self, *args) -> None: ...
def expunge(self) -> CommandResults: ...
def fetch(self, message_set: str, message_parts: str) -> CommandResults: ...
def getacl(self, mailbox: str) -> CommandResults: ...
+2 -10
View File
@@ -29,16 +29,8 @@ SYSLOG_UDP_PORT: int
SYSLOG_TCP_PORT: int
class WatchedFileHandler(FileHandler):
@overload
def __init__(self, filename: _Path) -> None: ...
@overload
def __init__(self, filename: _Path, mode: str) -> None: ...
@overload
def __init__(self, filename: _Path, mode: str,
encoding: Optional[str]) -> None: ...
@overload
def __init__(self, filename: _Path, mode: str, encoding: Optional[str],
delay: bool) -> None: ...
def __init__(self, filename: _Path, mode: str = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
if sys.version_info >= (3,):
+334 -205
View File
@@ -1,43 +1,73 @@
# Stubs for socket
# Ron Murawski <ron@horizonchess.com>
"""Stub for the socket module
# based on: http://docs.python.org/3.2/library/socket.html
# see: http://hg.python.org/cpython/file/3d0686d90f55/Lib/socket.py
# see: http://nullege.com/codes/search/socket
# adapted for Python 2.7 by Michal Pokorny
This file is organized to mirror the module's documentation, with a very small
number of exceptions.
To avoid requiring tests on all platforms, platform checks are included only
where the documentation notes platform availability (as opposed to following
actual availability), with one or two exceptions.
Module documentation: https://docs.python.org/3/library/socket.html
CPython module source: https://github.com/python/cpython/blob/master/Lib/socket.py
CPython C source: https://github.com/python/cpython/blob/master/Modules/socketmodule.c
"""
# Authorship from original mypy stubs (not in typeshed git history):
# Ron Murawski <ron@horizonchess.com>
# adapted for Python 2.7 by Michal Pokorny
import sys
from typing import Any, Iterable, Tuple, List, Optional, Union, overload, TypeVar, Text
from typing import Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, TypeVar, Union, overload
_WriteBuffer = Union[bytearray, memoryview]
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
# ----- variables and constants -----
# ----- Constants -----
# Some socket families are listed in the "Socket families" section of the docs,
# but not the "Constants" section. These are listed at the end of the list of
# constants.
#
# Besides those and the first few constants listed, the constants are listed in
# documentation order.
# Constants defined by Python (i.e. not OS constants re-exported from C)
has_ipv6: bool
SocketType: Any
if sys.version_info >= (3,):
SocketIO: Any
# Re-exported errno
EAGAIN: int
EBADF: int
EINTR: int
EWOULDBLOCK: int
# Constants re-exported from C
# Per socketmodule.c, only these three families are portable
AF_UNIX: AddressFamily
AF_INET: AddressFamily
AF_INET6: AddressFamily
SOCK_STREAM: SocketKind
SOCK_DGRAM: SocketKind
SOCK_RAW: SocketKind
SOCK_RDM: SocketKind
SOCK_SEQPACKET: SocketKind
SOCK_CLOEXEC: SocketKind
SOCK_NONBLOCK: SocketKind
SOMAXCONN: int
has_ipv6: bool
_GLOBAL_DEFAULT_TIMEOUT: Any
SocketType: Any
SocketIO: Any
# These are flags that may exist on Python 3.6. Many don't exist on all platforms.
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
AF_ASH: AddressFamily
AF_ATMPVC: AddressFamily
AF_ATMSVC: AddressFamily
AF_AX25: AddressFamily
AF_BLUETOOTH: AddressFamily
AF_BRIDGE: AddressFamily
AF_CAN: AddressFamily
AF_DECnet: AddressFamily
AF_ECONET: AddressFamily
AF_IPX: AddressFamily
@@ -45,20 +75,19 @@ AF_IRDA: AddressFamily
AF_KEY: AddressFamily
AF_LLC: AddressFamily
AF_NETBEUI: AddressFamily
AF_NETLINK: AddressFamily
AF_NETROM: AddressFamily
AF_PACKET: AddressFamily
AF_PPPOX: AddressFamily
AF_RDS: AddressFamily
AF_ROSE: AddressFamily
AF_ROUTE: AddressFamily
AF_SECURITY: AddressFamily
AF_SNA: AddressFamily
AF_SYSTEM: AddressFamily
AF_TIPC: AddressFamily
AF_UNSPEC: AddressFamily
AF_WANPIPE: AddressFamily
AF_X25: AddressFamily
# The "many constants" referenced by the docs
SOMAXCONN: int
AI_ADDRCONFIG: AddressInfo
AI_ALL: AddressInfo
AI_CANONNAME: AddressInfo
@@ -69,26 +98,7 @@ AI_NUMERICSERV: AddressInfo
AI_PASSIVE: AddressInfo
AI_V4MAPPED: AddressInfo
AI_V4MAPPED_CFG: AddressInfo
BDADDR_ANY: str
BDADDR_LOCAL: str
BTPROTO_HCI: int
BTPROTO_L2CAP: int
BTPROTO_RFCOMM: int
BTPROTO_SCO: 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
CAPI: int
EAGAIN: int
EAI_ADDRFAMILY: int
EAIEAI_ADDRFAMILY: int
EAI_AGAIN: int
EAI_BADFLAGS: int
EAI_BADHINTS: int
@@ -103,12 +113,6 @@ EAI_PROTOCOL: int
EAI_SERVICE: int
EAI_SOCKTYPE: int
EAI_SYSTEM: int
EBADF: int
EINTR: int
EWOULDBLOCK: int
HCI_DATA_DIR: int
HCI_FILTER: int
HCI_TIME_STAMP: int
INADDR_ALLHOSTS_GROUP: int
INADDR_ANY: int
INADDR_BROADCAST: int
@@ -174,12 +178,13 @@ IPV6_RECVPKTINFO: int
IPV6_RECVRTHDR: int
IPV6_RECVTCLASS: int
IPV6_RTHDR: int
IPV6_RTHDR_TYPE_0: int
IPV6_RTHDRDSTOPTS: int
IPV6_RTHDR_TYPE_0: int
IPV6_TCLASS: int
IPV6_UNICAST_HOPS: int
IPV6_USE_MIN_MTU: int
IPV6_V6ONLY: int
IPX_TYPE: int
IP_ADD_MEMBERSHIP: int
IP_DEFAULT_MULTICAST_LOOP: int
IP_DEFAULT_MULTICAST_TTL: int
@@ -197,7 +202,6 @@ IP_RETOPTS: int
IP_TOS: int
IP_TRANSPARENT: int
IP_TTL: int
IPX_TYPE: int
LOCAL_PEERCRED: int
MSG_BCAST: MsgFlag
MSG_BTAG: MsgFlag
@@ -219,20 +223,6 @@ MSG_OOB: MsgFlag
MSG_PEEK: MsgFlag
MSG_TRUNC: MsgFlag
MSG_WAITALL: MsgFlag
NETLINK_ARPD: int
NETLINK_CRYPTO: int
NETLINK_DNRTMSG: int
NETLINK_FIREWALL: int
NETLINK_IP6_FW: int
NETLINK_NFLOG: int
NETLINK_ROUTE6: int
NETLINK_ROUTE: int
NETLINK_SKIP: int
NETLINK_TAPBASE: int
NETLINK_TCPDIAG: int
NETLINK_USERSOCK: int
NETLINK_W1: int
NETLINK_XFRM: int
NI_DGRAM: int
NI_MAXHOST: int
NI_MAXSERV: int
@@ -240,17 +230,6 @@ NI_NAMEREQD: int
NI_NOFQDN: int
NI_NUMERICHOST: int
NI_NUMERICSERV: int
PACKET_BROADCAST: int
PACKET_FASTROUTE: int
PACKET_HOST: int
PACKET_LOOPBACK: int
PACKET_MULTICAST: int
PACKET_OTHERHOST: int
PACKET_OUTGOING: int
PF_CAN: int
PF_PACKET: int
PF_RDS: int
PF_SYSTEM: int
SCM_CREDENTIALS: int
SCM_CREDS: int
SCM_RIGHTS: int
@@ -259,17 +238,13 @@ SHUT_RDWR: int
SHUT_WR: int
SOL_ATALK: int
SOL_AX25: int
SOL_CAN_BASE: int
SOL_CAN_RAW: int
SOL_HCI: int
SOL_IP: int
SOL_IPX: int
SOL_NETROM: int
SOL_RDS: int
SOL_ROSE: int
SOL_SOCKET: int
SOL_TCP: int
SOL_TIPC: int
SOL_UDP: int
SO_ACCEPTCONN: int
SO_BINDTODEVICE: int
@@ -296,7 +271,6 @@ SO_SNDLOWAT: int
SO_SNDTIMEO: int
SO_TYPE: int
SO_USELOOPBACK: int
SYSPROTO_CONTROL: int
TCP_CORK: int
TCP_DEFER_ACCEPT: int
TCP_FASTOPEN: int
@@ -307,35 +281,65 @@ TCP_KEEPINTVL: int
TCP_LINGER2: int
TCP_MAXSEG: int
TCP_NODELAY: int
TCP_NOTSENT_LOWAT: int
TCP_QUICKACK: int
TCP_SYNCNT: int
TCP_WINDOW_CLAMP: int
TIPC_ADDR_ID: int
TIPC_ADDR_NAME: int
TIPC_ADDR_NAMESEQ: int
TIPC_CFG_SRV: int
TIPC_CLUSTER_SCOPE: int
TIPC_CONN_TIMEOUT: int
TIPC_CRITICAL_IMPORTANCE: int
TIPC_DEST_DROPPABLE: int
TIPC_HIGH_IMPORTANCE: int
TIPC_IMPORTANCE: int
TIPC_LOW_IMPORTANCE: int
TIPC_MEDIUM_IMPORTANCE: int
TIPC_NODE_SCOPE: int
TIPC_PUBLISHED: int
TIPC_SRC_DROPPABLE: int
TIPC_SUB_CANCEL: int
TIPC_SUB_PORTS: int
TIPC_SUB_SERVICE: int
TIPC_SUBSCR_TIMEOUT: int
TIPC_TOP_SRV: int
TIPC_WAIT_FOREVER: int
TIPC_WITHDRAWN: int
TIPC_ZONE_SCOPE: int
if sys.version_info >= (3, 7):
TCP_NOTSENT_LOWAT: int
if sys.version_info >= (3, 3):
# 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, 7):
CAN_ISOTP: int
if sys.platform == 'linux':
AF_PACKET: AddressFamily
PF_PACKET: int
PACKET_BROADCAST: int
PACKET_FASTROUTE: int
PACKET_HOST: int
PACKET_LOOPBACK: int
PACKET_MULTICAST: int
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
@@ -355,58 +359,130 @@ if sys.version_info >= (3, 3):
RDS_RDMA_USE_ONCE: int
RDS_RECVERR: int
if sys.version_info >= (3, 4):
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
AF_LINK: AddressFamily
if sys.version_info >= (3, 5):
CAN_RAW_FD_FRAMES: int
if sys.version_info >= (3, 6):
SO_DOMAIN: int
SO_PROTOCOL: int
SO_PEERSEC: int
SO_PASSSEC: int
TCP_USER_TIMEOUT: int
TCP_CONGESTION: int
AF_ALG: AddressFamily
SOL_ALG: int
ALG_SET_KEY: int
ALG_SET_IV: int
ALG_SET_OP: int
ALG_SET_AEAD_ASSOCLEN: int
ALG_SET_AEAD_AUTHSIZE: int
ALG_SET_PUBKEY: int
ALG_OP_DECRYPT: int
ALG_OP_ENCRYPT: int
ALG_OP_SIGN: int
ALG_OP_VERIFY: int
if sys.platform == 'win32':
SIO_RCVALL: int
SIO_KEEPALIVE_VALS: int
if sys.version_info >= (3, 6):
SIO_LOOPBACK_FAST_PATH: int
RCVALL_IPLEVEL: int
RCVALL_MAX: int
RCVALL_OFF: int
RCVALL_ON: int
RCVALL_SOCKETLEVELONLY: int
if sys.version_info >= (3, 6):
SIO_LOOPBACK_FAST_PATH: int
if sys.platform == 'linux':
AF_TIPC: AddressFamily
SOL_TIPC: int
TIPC_ADDR_ID: int
TIPC_ADDR_NAME: int
TIPC_ADDR_NAMESEQ: int
TIPC_CFG_SRV: int
TIPC_CLUSTER_SCOPE: int
TIPC_CONN_TIMEOUT: int
TIPC_CRITICAL_IMPORTANCE: int
TIPC_DEST_DROPPABLE: int
TIPC_HIGH_IMPORTANCE: int
TIPC_IMPORTANCE: int
TIPC_LOW_IMPORTANCE: int
TIPC_MEDIUM_IMPORTANCE: int
TIPC_NODE_SCOPE: int
TIPC_PUBLISHED: int
TIPC_SRC_DROPPABLE: int
TIPC_SUBSCR_TIMEOUT: int
TIPC_SUB_CANCEL: int
TIPC_SUB_PORTS: int
TIPC_SUB_SERVICE: int
TIPC_TOP_SRV: int
TIPC_WAIT_FOREVER: int
TIPC_WITHDRAWN: int
TIPC_ZONE_SCOPE: int
# enum versions of above flags py 3.4+
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.version_info >= (3, 6):
SO_DOMAIN: int
SO_PASSSEC: int
SO_PEERSEC: int
SO_PROTOCOL: int
TCP_CONGESTION: int
TCP_USER_TIMEOUT: int
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")
if sys.platform == 'linux':
# Netlink is defined by Linux
AF_NETLINK: AddressFamily
NETLINK_ARPD: int
NETLINK_CRYPTO: int
NETLINK_DNRTMSG: int
NETLINK_FIREWALL: int
NETLINK_IP6_FW: int
NETLINK_NFLOG: int
NETLINK_ROUTE6: int
NETLINK_ROUTE: int
NETLINK_SKIP: int
NETLINK_TAPBASE: int
NETLINK_TCPDIAG: int
NETLINK_USERSOCK: int
NETLINK_W1: int
NETLINK_XFRM: int
if sys.platform != 'win32' and sys.platform != 'darwin':
# Linux and some BSD support is explicit in the docs
# Windows and macOS do not support in practice
AF_BLUETOOTH: AddressFamily
BTPROTO_HCI: int
BTPROTO_L2CAP: int
BTPROTO_RFCOMM: int
BTPROTO_SCO: int # not in FreeBSD
BDADDR_ANY: str
BDADDR_LOCAL: str
HCI_FILTER: int # not in NetBSD or DragonFlyBSD
# not in FreeBSD, NetBSD, or DragonFlyBSD
HCI_TIME_STAMP: int
HCI_DATA_DIR: int
if sys.platform == 'darwin':
# PF_SYSTEM is defined by macOS
PF_SYSTEM: int
SYSPROTO_CONTROL: int
# enum versions of above flags
if sys.version_info >= (3, 4):
from enum import IntEnum
@@ -414,6 +490,8 @@ if sys.version_info >= (3, 4):
AF_UNIX: int
AF_INET: int
AF_INET6: int
AF_AAL5: int
AF_ALG: int
AF_APPLETALK: int
AF_ASH: int
AF_ATMPVC: int
@@ -421,26 +499,31 @@ if sys.version_info >= (3, 4):
AF_AX25: int
AF_BLUETOOTH: int
AF_BRIDGE: int
AF_CAN: int
AF_DECnet: int
AF_ECONET: int
AF_IPX: int
AF_IRDA: int
AF_KEY: int
AF_LINK: int
AF_LLC: int
AF_NETBEUI: int
AF_NETLINK: int
AF_NETROM: int
AF_PACKET: int
AF_PPPOX: int
AF_QIPCRTR: int
AF_RDS: int
AF_ROSE: int
AF_ROUTE: int
AF_SECURITY: int
AF_SNA: int
AF_SYSTEM: int
AF_TIPC: int
AF_UNSPEC: int
AF_VSOCK: int
AF_WANPIPE: int
AF_X25: int
AF_LINK: int
class SocketKind(IntEnum):
SOCK_STREAM: int
@@ -480,7 +563,8 @@ else:
MsgFlag = int
# ----- exceptions -----
# ----- Exceptions -----
if sys.version_info < (3,):
class error(IOError): ...
else:
@@ -496,18 +580,19 @@ class timeout(error):
def __init__(self, error: int = ..., string: str = ...) -> None: ...
# ----- Classes -----
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
# AF_NETLINK, AF_TIPC) or strings (AF_UNIX).
_Address = Union[tuple, str]
_RetAddress = Any
# TODO Most methods allow bytes as address objects
# TODO AF_PACKET and AF_BLUETOOTH address objects
_WriteBuffer = Union[bytearray, memoryview]
_CMSG = Tuple[int, int, bytes]
_SelfT = TypeVar('_SelfT', bound=socket)
# ----- classes -----
class socket:
family: int
type: int
@@ -517,8 +602,6 @@ class socket:
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
else:
def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: Optional[int] = ...) -> None: ...
if sys.version_info >= (3, 2):
def __enter__(self: _SelfT) -> _SelfT: ...
def __exit__(self, *args: Any) -> None: ...
@@ -529,8 +612,10 @@ class socket:
def connect(self, address: Union[_Address, bytes]) -> None: ...
def connect_ex(self, address: Union[_Address, bytes]) -> int: ...
def detach(self) -> int: ...
def dup(self) -> socket: ...
def fileno(self) -> int: ...
if sys.version_info >= (3, 4):
def get_inheritable(self) -> bool: ...
def getpeername(self) -> _RetAddress: ...
def getsockname(self) -> _RetAddress: ...
@@ -539,71 +624,118 @@ class socket:
@overload
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
if sys.version_info >= (3, 7):
def getblocking(self) -> bool: ...
def gettimeout(self) -> Optional[float]: ...
def ioctl(self, control: object,
option: Tuple[int, int, int]) -> None: ...
if sys.version_info < (3, 5):
def listen(self, backlog: int) -> None: ...
else:
def listen(self, backlog: int = ...) -> None: ...
# TODO the return value may be BinaryIO or TextIO, depending on mode
def makefile(self, mode: str = ..., buffering: int = ...,
encoding: str = ..., errors: str = ...,
newline: str = ...) -> Any:
...
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
if sys.platform == 'win32':
def ioctl(self, control: object, option: Tuple[int, int, int]) -> None: ...
if sys.version_info >= (3, 5):
def listen(self, __backlog: int = ...) -> None: ...
else:
def listen(self, __backlog: int) -> None: ...
# Note that the makefile's documented windows-specific behavior is not represented
if sys.version_info < (3,):
def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
else:
# mode strings with duplicates are intentionally excluded
@overload
def makefile(self,
mode: Literal['r', 'w', 'rw', 'wr', ''],
buffering: Optional[int] = ...,
*,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...) -> TextIO: ...
@overload
def makefile(self,
mode: Literal['b', 'rb', 'br', 'wb', 'bw', 'rwb', 'rbw', 'wrb', 'wbr', 'brw', 'bwr'] = ...,
buffering: Optional[int] = ...,
*,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...) -> BinaryIO: ...
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
def recvfrom(self, bufsize: int, flags: int = ...) -> Tuple[bytes, _RetAddress]: ...
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int,
flags: int = ...) -> Tuple[int, _RetAddress]: ...
def recv_into(self, buffer: _WriteBuffer, nbytes: int,
flags: int = ...) -> int: ...
if sys.version_info >= (3, 3):
def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ...
def recvmsg_into(self,
__buffers: Iterable[_WriteBuffer],
__ancbufsize: int = ...,
__flags: int = ...) -> Tuple[int, List[_CMSG], int, Any]: ...
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> Tuple[int, _RetAddress]: ...
def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
def send(self, data: bytes, flags: int = ...) -> int: ...
def sendall(self, data: bytes, flags: int = ...) -> None:
... # return type: None on success
def sendall(self, data: bytes, flags: int = ...) -> None: ... # return type: None on success
@overload
def sendto(self, data: bytes, address: _Address) -> int: ...
@overload
def sendto(self, data: bytes, flags: int, address: _Address) -> int: ...
if sys.version_info >= (3, 3):
def sendmsg(self,
__buffers: Iterable[bytes],
__ancdata: Iterable[_CMSG] = ...,
__flags: int = ...,
__address: _Address = ...) -> int: ...
if sys.platform == 'linux' and sys.version_info >= (3, 6):
# TODO add the parameter types for sendmsg_afalg
def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> int: ...
if sys.version_info >= (3,):
# TODO determine legal types for file parameter
def sendfile(self, file, offset: int = ..., count: Optional[int] = ...) -> int: ...
def set_inheritable(self, inheritable: bool) -> None: ...
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: ...
if sys.version_info < (3, 6):
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
else:
@overload
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
@overload
def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ...
if sys.platform == 'win32':
def share(self, process_id: int) -> bytes: ...
def shutdown(self, how: int) -> None: ...
if sys.version_info >= (3, 3):
def recvmsg(self, __bufsize: int, __ancbufsize: int = ...,
__flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ...
def recvmsg_into(self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ...,
__flags: int = ...) -> Tuple[int, List[_CMSG], int, Any]: ...
def sendmsg(self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ...,
__flags: int = ..., __address: _Address = ...) -> int: ...
if sys.version_info >= (3, 4):
def set_inheritable(self, inheritable: bool) -> None: ...
# ----- Functions -----
if sys.version_info >= (3, 7):
def close(fd: int) -> None: ...
# ----- functions -----
def create_connection(address: Tuple[Optional[str], int],
timeout: Optional[float] = ...,
source_address: Tuple[Union[bytearray, bytes, Text], int] = ...) -> socket: ...
if sys.version_info >= (3, 8):
def create_server(address: _Address,
*,
family: int = ...,
backlog: Optional[int] = ...,
reuse_port: bool = ...,
dualstack_ipv6: bool = ...) -> socket: ...
def has_dualstack_ipv6() -> bool: ...
def create_server(
address: Tuple[str, int],
*,
family: AddressFamily = ...,
backlog: Optional[int] = ...,
reuse_port: bool = ...,
dualstack_ipv6: bool = ...,
) -> socket: ...
def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ...
if sys.platform == 'win32' and sys.version_info >= (3, 3):
def fromshare(data: bytes) -> socket: ...
# the 5th tuple item is an address
# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers
# https://github.com/python/mypy/issues/2509
def getaddrinfo(
host: Optional[Union[bytearray, bytes, Text]], port: Union[str, int, None], family: int = ...,
socktype: int = ..., proto: int = ...,
flags: int = ...) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]:
...
def getaddrinfo(host: Optional[Union[bytearray, bytes, Text]],
port: Union[str, int, None],
family: int = ...,
socktype: int = ...,
proto: int = ...,
flags: int = ...) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]: ...
def getfqdn(name: str = ...) -> str: ...
def gethostbyname(hostname: str) -> str: ...
@@ -614,10 +746,7 @@ def getnameinfo(sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], fla
def getprotobyname(protocolname: str) -> int: ...
def getservbyname(servicename: str, protocolname: str = ...) -> int: ...
def getservbyport(port: int, protocolname: str = ...) -> str: ...
def socketpair(family: int = ...,
type: int = ...,
proto: int = ...) -> Tuple[socket, socket]: ...
def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ...
def socketpair(family: int = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ...
def ntohl(x: int) -> int: ... # param & ret val are 32-bit ints
def ntohs(x: int) -> int: ... # param & ret val are 16-bit ints
def htonl(x: int) -> int: ... # param & ret val are 32-bit ints
@@ -626,12 +755,12 @@ def inet_aton(ip_string: str) -> bytes: ... # ret val 4 bytes in length
def inet_ntoa(packed_ip: bytes) -> str: ...
def inet_pton(address_family: int, ip_string: str) -> bytes: ...
def inet_ntop(address_family: int, packed_ip: bytes) -> str: ...
def getdefaulttimeout() -> Optional[float]: ...
def setdefaulttimeout(timeout: Optional[float]) -> None: ...
if sys.version_info >= (3, 3):
def CMSG_LEN(length: int) -> int: ...
def CMSG_SPACE(length: int) -> int: ...
def getdefaulttimeout() -> Optional[float]: ...
def setdefaulttimeout(timeout: Optional[float]) -> None: ...
if sys.version_info >= (3, 3):
def sethostname(name: str) -> None: ...
def if_nameindex() -> List[Tuple[int, str]]: ...
def if_nametoindex(name: str) -> int: ...
+1 -1
View File
@@ -154,7 +154,7 @@ class Connection(object):
progress: Optional[Callable[[int, int, int], object]] = ..., name: str = ...,
sleep: float = ...) -> None: ...
def __call__(self, *args, **kwargs): ...
def __enter__(self, *args, **kwargs): ...
def __enter__(self, *args, **kwargs) -> Connection: ...
def __exit__(self, *args, **kwargs): ...
class Cursor(Iterator[Any]):
+14 -35
View File
@@ -1,38 +1,17 @@
# Stubs for warnings
import sys
from typing import Any, Dict, List, NamedTuple, Optional, overload, TextIO, Tuple, Type, Union
from typing import List, NamedTuple, Optional, overload, TextIO, Type
from types import ModuleType, TracebackType
from typing_extensions import Literal
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from _warnings import warn as warn, warn_explicit as warn_explicit
@overload
def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ...) -> None: ...
@overload
def warn_explicit(message: str, category: Type[Warning],
filename: str, lineno: int, module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...) -> None: ...
@overload
def warn_explicit(message: Warning, category: Any,
filename: str, lineno: int, module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...) -> None: ...
def showwarning(message: str, category: Type[Warning], filename: str,
lineno: int, file: Optional[TextIO] = ...,
line: Optional[str] = ...) -> None: ...
def formatwarning(message: str, category: Type[Warning], filename: str,
lineno: int, line: Optional[str] = ...) -> str: ...
def filterwarnings(action: str, message: str = ...,
category: Type[Warning] = ..., module: str = ...,
lineno: int = ..., append: bool = ...) -> None: ...
def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ...,
append: bool = ...) -> None: ...
def showwarning(
message: str, category: Type[Warning], filename: str, lineno: int, file: Optional[TextIO] = ..., line: Optional[str] = ...
) -> None: ...
def formatwarning(message: str, category: Type[Warning], filename: str, lineno: int, line: Optional[str] = ...) -> str: ...
def filterwarnings(
action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ...
) -> None: ...
def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ...
def resetwarnings() -> None: ...
class _Record(NamedTuple):
@@ -51,9 +30,9 @@ class catch_warnings:
@overload
def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ...
def __enter__(self) -> Optional[List[_Record]]: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
class _catch_warnings_without_records(catch_warnings):
def __enter__(self) -> None: ...
-11
View File
@@ -1,11 +0,0 @@
from typing import Any, Dict, List, Optional, Tuple, Type
_defaultaction: str
_onceregistry: Dict[Any, Any]
filters: List[Tuple[Any, ...]]
def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
def warn_explicit(message: Warning, category: Optional[Type[Warning]],
filename: str, lineno: int,
module: Any = ..., registry: Dict[Any, Any] = ...,
module_globals: Dict[Any, Any] = ...) -> None: ...
+1
View File
@@ -53,6 +53,7 @@ class RawIOBase(IOBase):
def read(self, size: int = ...) -> Optional[bytes]: ...
class BufferedIOBase(IOBase):
raw: RawIOBase # This is not part of the BufferedIOBase API and may not exist on some implementations.
def detach(self) -> RawIOBase: ...
def readinto(self, b: _bytearray_like) -> int: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
+50 -21
View File
@@ -55,7 +55,6 @@ def TemporaryFile(
prefix: Optional[AnyStr] = ...,
dir: Optional[_DirT[AnyStr]] = ...,
) -> IO[Any]: ...
@overload
def NamedTemporaryFile(
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"],
@@ -93,17 +92,48 @@ def NamedTemporaryFile(
# It does not actually derive from IO[AnyStr], but it does implement the
# protocol.
class SpooledTemporaryFile(IO[AnyStr]):
def __init__(self, max_size: int = ..., mode: str = ...,
buffering: int = ..., encoding: Optional[str] = ...,
newline: Optional[str] = ..., suffix: Optional[str] = ...,
prefix: Optional[str] = ..., dir: Optional[str] = ...
) -> None: ...
# bytes needs to go first, as default mode is to open as bytes
@overload
def __init__(
self: SpooledTemporaryFile[bytes],
max_size: int = ...,
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
newline: Optional[str] = ...,
suffix: Optional[str] = ...,
prefix: Optional[str] = ...,
dir: Optional[str] = ...,
) -> None: ...
@overload
def __init__(
self: SpooledTemporaryFile[str],
max_size: int = ...,
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"] = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
newline: Optional[str] = ...,
suffix: Optional[str] = ...,
prefix: Optional[str] = ...,
dir: Optional[str] = ...,
) -> None: ...
@overload
def __init__(
self,
max_size: int = ...,
mode: str = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
newline: Optional[str] = ...,
suffix: Optional[str] = ...,
prefix: Optional[str] = ...,
dir: Optional[str] = ...,
) -> None: ...
def rollover(self) -> None: ...
def __enter__(self: _S) -> _S: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Optional[bool]: ...
# These methods are copied from the abstract methods of IO, because
# SpooledTemporaryFile implements IO.
# See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918.
@@ -127,25 +157,24 @@ class SpooledTemporaryFile(IO[AnyStr]):
class TemporaryDirectory(Generic[AnyStr]):
name: str
def __init__(self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
dir: Optional[_DirT[AnyStr]] = ...) -> None: ...
def __init__(
self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...
) -> None: ...
def cleanup(self) -> None: ...
def __enter__(self) -> AnyStr: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
def mkstemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...,
text: bool = ...) -> Tuple[int, AnyStr]: ...
def mkstemp(
suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., text: bool = ...
) -> Tuple[int, AnyStr]: ...
@overload
def mkdtemp() -> str: ...
@overload
def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
def mktemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
def gettempdirb() -> bytes: ...
def gettempprefixb() -> bytes: ...
def gettempdir() -> str: ...
def gettempprefix() -> str: ...
@@ -1,5 +1,5 @@
from abc import ABCMeta, abstractmethod
from typing import ClassVar, Optional
from typing import ClassVar, Optional, Union
from cryptography.hazmat.primitives.hashes import HashAlgorithm
@@ -22,6 +22,6 @@ class PKCS1v15(AsymmetricPadding):
class PSS(AsymmetricPadding):
MAX_LENGTH: ClassVar[object]
def __init__(self, mgf: MGF1, salt_length: int) -> None: ...
def __init__(self, mgf: MGF1, salt_length: Union[int, object]) -> None: ...
@property
def name(self) -> str: ...
+7 -4
View File
@@ -2,7 +2,7 @@ import datetime
from abc import ABCMeta, abstractmethod
from enum import Enum
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
from typing import Any, ClassVar, Generator, List, Optional, Union, Text, Iterable, Sequence
from typing import Any, ClassVar, Generator, List, Optional, Union, Text, Iterable, Sequence, Type
from cryptography.hazmat.backends.interfaces import X509Backend
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
@@ -205,7 +205,7 @@ class CertificateSigningRequest(metaclass=ABCMeta):
subject: Name
tbs_certrequest_bytes: bytes
@abstractmethod
def public_bytes(self) -> bytes: ...
def public_bytes(self, encoding: Encoding) -> bytes: ...
@abstractmethod
def public_key(self) -> Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey]: ...
@@ -232,7 +232,8 @@ class RevokedCertificateBuilder(object):
# General Name Classes
class GeneralName(metaclass=ABCMeta): ...
class GeneralName(metaclass=ABCMeta):
value: Any
class DirectoryName(GeneralName):
value: Name
@@ -277,15 +278,17 @@ class Extensions(object):
def __init__(self, general_names: List[Extension]) -> None: ...
def __iter__(self) -> Generator[Extension, None, None]: ...
def get_extension_for_oid(self, oid: ObjectIdentifier) -> Extension: ...
def get_extension_for_class(self, extclass: ExtensionType) -> Extension: ...
def get_extension_for_class(self, extclass: Type[ExtensionType]) -> Extension: ...
class IssuerAlternativeName(ExtensionType):
def __init__(self, general_names: List[GeneralName]) -> None: ...
def __iter__(self) -> Generator[GeneralName, None, None]: ...
def get_values_for_type(self, type: Type[GeneralName]) -> List[Any]: ...
class SubjectAlternativeName(ExtensionType):
def __init__(self, general_names: List[GeneralName]) -> None: ...
def __iter__(self) -> Generator[GeneralName, None, None]: ...
def get_values_for_type(self, type: Type[GeneralName]) -> List[Any]: ...
def load_der_x509_certificate(data: bytes, backend: X509Backend) -> Certificate: ...
def load_pem_x509_certificate(data: bytes, backend: X509Backend) -> Certificate: ...
+6 -6
View File
@@ -87,13 +87,13 @@ class Redis(object):
def dbsize(self) -> int: ...
def debug_object(self, key): ...
def echo(self, value): ...
def flushall(self): ...
def flushdb(self): ...
def flushall(self) -> bool: ...
def flushdb(self) -> bool: ...
def info(self, section: Optional[Text] = ...) -> Mapping[str, Any]: ...
def lastsave(self): ...
def object(self, infotype, key): ...
def ping(self): ...
def save(self): ...
def ping(self) -> bool: ...
def save(self) -> bool: ...
def sentinel(self, *args): ...
def sentinel_get_master_addr_by_name(self, service_name): ...
def sentinel_master(self, service_name): ...
@@ -114,10 +114,10 @@ class Redis(object):
def bitop(self, operation, dest, *keys): ...
def bitpos(self, key, bit, start=..., end=...): ...
def decr(self, name, amount=...): ...
def delete(self, *names): ...
def delete(self, *names: Text): ...
def __delitem__(self, name): ...
def dump(self, name): ...
def exists(self, name): ...
def exists(self, *names: Text) -> int: ...
__contains__: Any
def expire(self, name: Union[Text, bytes], time: Union[int, timedelta]) -> bool: ...
def expireat(self, name, when): ...
+9 -3
View File
@@ -2,13 +2,19 @@
from typing import Any, Callable, Optional, Union
__version__ = str
def dumps(
__obj: Any, default: Optional[Callable[[Any], Any]] = ..., option: Optional[int] = ...
__obj: Any,
default: Optional[Callable[[Any], Any]] = ...,
option: Optional[int] = ...,
) -> bytes: ...
def loads(__obj: Union[bytes, str]) -> Any: ...
def loads(__obj: Union[bytes, bytearray, str]) -> Any: ...
class JSONDecodeError(ValueError): ...
class JSONEncodeError(TypeError): ...
OPT_STRICT_INTEGER: int
OPT_SERIALIZE_DATACLASS: int
OPT_NAIVE_UTC: int
OPT_OMIT_MICROSECONDS: int
OPT_STRICT_INTEGER: int