mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-01 17:13:24 +08:00
apply black and isort (#4287)
* apply black and isort * move some type ignores
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from enum import IntEnum
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
class HTTPStatus(IntEnum):
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
from typing import (
|
||||
Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional,
|
||||
Protocol, Tuple, Type, TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
BinaryIO,
|
||||
)
|
||||
import email.message
|
||||
import io
|
||||
from socket import socket
|
||||
import sys
|
||||
import ssl
|
||||
import sys
|
||||
import types
|
||||
from socket import socket
|
||||
from typing import (
|
||||
IO,
|
||||
Any,
|
||||
BinaryIO,
|
||||
Dict,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Protocol,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
|
||||
_DataType = Union[bytes, IO[Any], Iterable[bytes], str]
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
HTTP_PORT: int
|
||||
HTTPS_PORT: int
|
||||
@@ -88,8 +98,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO):
|
||||
closed: bool
|
||||
status: int
|
||||
reason: str
|
||||
def __init__(self, sock: socket, debuglevel: int = ...,
|
||||
method: Optional[str] = ..., url: Optional[str] = ...) -> None: ...
|
||||
def __init__(self, sock: socket, debuglevel: int = ..., method: Optional[str] = ..., url: Optional[str] = ...) -> None: ...
|
||||
def read(self, amt: Optional[int] = ...) -> bytes: ...
|
||||
@overload
|
||||
def getheader(self, name: str) -> Optional[str]: ...
|
||||
@@ -100,9 +109,9 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO):
|
||||
def isclosed(self) -> bool: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def __enter__(self) -> HTTPResponse: ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]],
|
||||
exc_val: Optional[BaseException],
|
||||
exc_tb: Optional[types.TracebackType]) -> Optional[bool]: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType]
|
||||
) -> Optional[bool]: ...
|
||||
def info(self) -> email.message.Message: ...
|
||||
def geturl(self) -> str: ...
|
||||
def getcode(self) -> int: ...
|
||||
@@ -133,53 +142,61 @@ class HTTPConnection:
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self,
|
||||
host: str, port: Optional[int] = ...,
|
||||
host: str,
|
||||
port: Optional[int] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ..., blocksize: int = ...
|
||||
source_address: Optional[Tuple[str, int]] = ...,
|
||||
blocksize: int = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
host: str, port: Optional[int] = ...,
|
||||
host: str,
|
||||
port: Optional[int] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ...
|
||||
source_address: Optional[Tuple[str, int]] = ...,
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
def request(self, method: str, url: str,
|
||||
body: Optional[_DataType] = ...,
|
||||
headers: Mapping[str, str] = ...,
|
||||
*, encode_chunked: bool = ...) -> None: ...
|
||||
def request(
|
||||
self,
|
||||
method: str,
|
||||
url: str,
|
||||
body: Optional[_DataType] = ...,
|
||||
headers: Mapping[str, str] = ...,
|
||||
*,
|
||||
encode_chunked: bool = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def request(self, method: str, url: str,
|
||||
body: Optional[_DataType] = ...,
|
||||
headers: Mapping[str, str] = ...) -> None: ...
|
||||
def request(self, method: str, url: str, body: Optional[_DataType] = ..., headers: Mapping[str, str] = ...) -> None: ...
|
||||
def getresponse(self) -> HTTPResponse: ...
|
||||
def set_debuglevel(self, level: int) -> None: ...
|
||||
def set_tunnel(self, host: str, port: Optional[int] = ...,
|
||||
headers: Optional[Mapping[str, str]] = ...) -> None: ...
|
||||
def set_tunnel(self, host: str, port: Optional[int] = ..., headers: Optional[Mapping[str, str]] = ...) -> None: ...
|
||||
def connect(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def putrequest(self, method: str, url: str, skip_host: bool = ...,
|
||||
skip_accept_encoding: bool = ...) -> None: ...
|
||||
def putrequest(self, method: str, url: str, skip_host: bool = ..., skip_accept_encoding: bool = ...) -> None: ...
|
||||
def putheader(self, header: str, *argument: str) -> None: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
def endheaders(self, message_body: Optional[_DataType] = ...,
|
||||
*, encode_chunked: bool = ...) -> None: ...
|
||||
def endheaders(self, message_body: Optional[_DataType] = ..., *, encode_chunked: bool = ...) -> None: ...
|
||||
else:
|
||||
def endheaders(self, message_body: Optional[_DataType] = ...) -> None: ...
|
||||
def send(self, data: _DataType) -> None: ...
|
||||
|
||||
class HTTPSConnection(HTTPConnection):
|
||||
def __init__(self,
|
||||
host: str, port: Optional[int] = ...,
|
||||
key_file: Optional[str] = ...,
|
||||
cert_file: Optional[str] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ...,
|
||||
*, context: Optional[ssl.SSLContext] = ...,
|
||||
check_hostname: Optional[bool] = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
host: str,
|
||||
port: Optional[int] = ...,
|
||||
key_file: Optional[str] = ...,
|
||||
cert_file: Optional[str] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ...,
|
||||
*,
|
||||
context: Optional[ssl.SSLContext] = ...,
|
||||
check_hostname: Optional[bool] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class HTTPException(Exception): ...
|
||||
|
||||
error = HTTPException
|
||||
|
||||
class NotConnected(HTTPException): ...
|
||||
@@ -188,13 +205,10 @@ class UnknownProtocol(HTTPException): ...
|
||||
class UnknownTransferEncoding(HTTPException): ...
|
||||
class UnimplementedFileMode(HTTPException): ...
|
||||
class IncompleteRead(HTTPException): ...
|
||||
|
||||
class ImproperConnectionState(HTTPException): ...
|
||||
class CannotSendRequest(ImproperConnectionState): ...
|
||||
class CannotSendHeader(ImproperConnectionState): ...
|
||||
class ResponseNotReady(ImproperConnectionState): ...
|
||||
|
||||
class BadStatusLine(HTTPException): ...
|
||||
class LineTooLong(HTTPException): ...
|
||||
|
||||
class RemoteDisconnected(ConnectionResetError, BadStatusLine): ...
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
import sys
|
||||
from typing import Dict, Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union, overload
|
||||
from http.client import HTTPResponse
|
||||
from typing import Dict, Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union, overload
|
||||
from urllib.request import Request
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from os import PathLike
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class LoadError(OSError): ...
|
||||
|
||||
|
||||
class CookieJar(Iterable[Cookie]):
|
||||
def __init__(self, policy: Optional[CookiePolicy] = ...) -> None: ...
|
||||
def add_cookie_header(self, request: Request) -> None: ...
|
||||
def extract_cookies(self, response: HTTPResponse,
|
||||
request: Request) -> None: ...
|
||||
def extract_cookies(self, response: HTTPResponse, request: Request) -> None: ...
|
||||
def set_policy(self, policy: CookiePolicy) -> None: ...
|
||||
def make_cookies(self, response: HTTPResponse,
|
||||
request: Request) -> Sequence[Cookie]: ...
|
||||
def make_cookies(self, response: HTTPResponse, request: Request) -> Sequence[Cookie]: ...
|
||||
def set_cookie(self, cookie: Cookie) -> None: ...
|
||||
def set_cookie_if_ok(self, cookie: Cookie,
|
||||
request: Request) -> None: ...
|
||||
def clear(self, domain: str = ..., path: str = ...,
|
||||
name: str = ...) -> None: ...
|
||||
def set_cookie_if_ok(self, cookie: Cookie, request: Request) -> None: ...
|
||||
def clear(self, domain: str = ..., path: str = ..., name: str = ...) -> None: ...
|
||||
def clear_session_cookies(self) -> None: ...
|
||||
def __iter__(self) -> Iterator[Cookie]: ...
|
||||
def __len__(self) -> int: ...
|
||||
@@ -31,17 +27,14 @@ class FileCookieJar(CookieJar):
|
||||
filename: str
|
||||
delayload: bool
|
||||
if sys.version_info >= (3, 8):
|
||||
def __init__(self, filename: Union[str, PathLike[str]] = ..., delayload: bool = ...,
|
||||
policy: Optional[CookiePolicy] = ...) -> None: ...
|
||||
def __init__(
|
||||
self, filename: Union[str, PathLike[str]] = ..., delayload: bool = ..., policy: Optional[CookiePolicy] = ...
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(self, filename: str = ..., delayload: bool = ...,
|
||||
policy: Optional[CookiePolicy] = ...) -> None: ...
|
||||
def save(self, filename: Optional[str] = ..., ignore_discard: bool = ...,
|
||||
ignore_expires: bool = ...) -> None: ...
|
||||
def load(self, filename: Optional[str] = ..., ignore_discard: bool = ...,
|
||||
ignore_expires: bool = ...) -> None: ...
|
||||
def revert(self, filename: Optional[str] = ..., ignore_discard: bool = ...,
|
||||
ignore_expires: bool = ...) -> None: ...
|
||||
def __init__(self, filename: str = ..., delayload: bool = ..., policy: Optional[CookiePolicy] = ...) -> None: ...
|
||||
def save(self, filename: Optional[str] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ...
|
||||
def load(self, filename: Optional[str] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ...
|
||||
def revert(self, filename: Optional[str] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ...
|
||||
|
||||
class MozillaCookieJar(FileCookieJar): ...
|
||||
|
||||
@@ -57,7 +50,6 @@ class CookiePolicy:
|
||||
def domain_return_ok(self, domain: str, request: Request) -> bool: ...
|
||||
def path_return_ok(self, path: str, request: Request) -> bool: ...
|
||||
|
||||
|
||||
class DefaultCookiePolicy(CookiePolicy):
|
||||
rfc2109_as_netscape: bool
|
||||
strict_domain: bool
|
||||
@@ -71,17 +63,21 @@ class DefaultCookiePolicy(CookiePolicy):
|
||||
DomainRFC2965Match: int
|
||||
DomainLiberal: int
|
||||
DomainStrict: int
|
||||
def __init__(self, blocked_domains: Optional[Sequence[str]] = ...,
|
||||
allowed_domains: Optional[Sequence[str]] = ...,
|
||||
netscape: bool = ...,
|
||||
rfc2965: bool = ...,
|
||||
rfc2109_as_netscape: Optional[bool] = ...,
|
||||
hide_cookie2: bool = ..., strict_domain: bool = ...,
|
||||
strict_rfc2965_unverifiable: bool = ...,
|
||||
strict_ns_unverifiable: bool = ...,
|
||||
strict_ns_domain: int = ...,
|
||||
strict_ns_set_initial_dollar: bool = ...,
|
||||
strict_ns_set_path: bool = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
blocked_domains: Optional[Sequence[str]] = ...,
|
||||
allowed_domains: Optional[Sequence[str]] = ...,
|
||||
netscape: bool = ...,
|
||||
rfc2965: bool = ...,
|
||||
rfc2109_as_netscape: Optional[bool] = ...,
|
||||
hide_cookie2: bool = ...,
|
||||
strict_domain: bool = ...,
|
||||
strict_rfc2965_unverifiable: bool = ...,
|
||||
strict_ns_unverifiable: bool = ...,
|
||||
strict_ns_domain: int = ...,
|
||||
strict_ns_set_initial_dollar: bool = ...,
|
||||
strict_ns_set_path: bool = ...,
|
||||
) -> None: ...
|
||||
def blocked_domains(self) -> Tuple[str, ...]: ...
|
||||
def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ...
|
||||
def is_blocked(self, domain: str) -> bool: ...
|
||||
@@ -89,7 +85,6 @@ class DefaultCookiePolicy(CookiePolicy):
|
||||
def set_allowed_domains(self, allowed_domains: Optional[Sequence[str]]) -> None: ...
|
||||
def is_not_allowed(self, domain: str) -> bool: ...
|
||||
|
||||
|
||||
class Cookie:
|
||||
version: Optional[int]
|
||||
name: str
|
||||
@@ -106,14 +101,26 @@ class Cookie:
|
||||
domain: str # undocumented
|
||||
domain_specified: bool
|
||||
domain_initial_dot: bool
|
||||
def __init__(self, version: Optional[int], name: str, value: Optional[str], # undocumented
|
||||
port: Optional[str], port_specified: bool,
|
||||
domain: str, domain_specified: bool, domain_initial_dot: bool,
|
||||
path: str, path_specified: bool,
|
||||
secure: bool, expires: Optional[int], discard: bool,
|
||||
comment: Optional[str], comment_url: Optional[str],
|
||||
rest: Dict[str, str],
|
||||
rfc2109: bool = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
version: Optional[int],
|
||||
name: str,
|
||||
value: Optional[str], # undocumented
|
||||
port: Optional[str],
|
||||
port_specified: bool,
|
||||
domain: str,
|
||||
domain_specified: bool,
|
||||
domain_initial_dot: bool,
|
||||
path: str,
|
||||
path_specified: bool,
|
||||
secure: bool,
|
||||
expires: Optional[int],
|
||||
discard: bool,
|
||||
comment: Optional[str],
|
||||
comment_url: Optional[str],
|
||||
rest: Dict[str, str],
|
||||
rfc2109: bool = ...,
|
||||
) -> None: ...
|
||||
def has_nonstandard_attr(self, name: str) -> bool: ...
|
||||
@overload
|
||||
def get_nonstandard_attr(self, name: str) -> Optional[str]: ...
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Stubs for http.cookies (Python 3.5)
|
||||
|
||||
import sys
|
||||
from typing import Generic, Dict, List, Mapping, Optional, TypeVar, Union, Any
|
||||
from typing import Any, Dict, Generic, List, Mapping, Optional, TypeVar, Union
|
||||
|
||||
_DataType = Union[str, Mapping[str, Union[str, Morsel[Any]]]]
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class CookieError(Exception): ...
|
||||
|
||||
@@ -17,8 +17,7 @@ class Morsel(Dict[str, Any], Generic[_T]):
|
||||
else:
|
||||
def set(self, key: str, val: str, coded_val: _T, LegalChars: str = ...) -> None: ...
|
||||
def isReservedKey(self, K: str) -> bool: ...
|
||||
def output(self, attrs: Optional[List[str]] = ...,
|
||||
header: str = ...) -> str: ...
|
||||
def output(self, attrs: Optional[List[str]] = ..., header: str = ...) -> str: ...
|
||||
def js_output(self, attrs: Optional[List[str]] = ...) -> str: ...
|
||||
def OutputString(self, attrs: Optional[List[str]] = ...) -> str: ...
|
||||
|
||||
@@ -26,8 +25,7 @@ class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]):
|
||||
def __init__(self, input: Optional[_DataType] = ...) -> None: ...
|
||||
def value_decode(self, val: str) -> _T: ...
|
||||
def value_encode(self, val: _T) -> str: ...
|
||||
def output(self, attrs: Optional[List[str]] = ..., header: str = ...,
|
||||
sep: str = ...) -> str: ...
|
||||
def output(self, attrs: Optional[List[str]] = ..., header: str = ..., sep: str = ...) -> str: ...
|
||||
def js_output(self, attrs: Optional[List[str]] = ...) -> str: ...
|
||||
def load(self, rawdata: _DataType) -> None: ...
|
||||
def __setitem__(self, key: str, value: Union[str, Morsel[_T]]) -> None: ...
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Stubs for http.server (Python 3.4)
|
||||
|
||||
import email.message
|
||||
import socketserver
|
||||
import sys
|
||||
from typing import Any, BinaryIO, Callable, ClassVar, Dict, List, Mapping, Optional, Sequence, Tuple, Union
|
||||
import socketserver
|
||||
import email.message
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from builtins import _PathLike
|
||||
@@ -11,8 +11,7 @@ if sys.version_info >= (3, 7):
|
||||
class HTTPServer(socketserver.TCPServer):
|
||||
server_name: str
|
||||
server_port: int
|
||||
def __init__(self, server_address: Tuple[str, int],
|
||||
RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ...
|
||||
def __init__(self, server_address: Tuple[str, int], RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class ThreadingHTTPServer(socketserver.ThreadingMixIn, HTTPServer):
|
||||
@@ -36,22 +35,17 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
|
||||
responses: Mapping[int, Tuple[str, str]]
|
||||
weekdayname: ClassVar[Sequence[str]] = ... # Undocumented
|
||||
monthname: ClassVar[Sequence[Optional[str]]] = ... # Undocumented
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int],
|
||||
server: socketserver.BaseServer) -> None: ...
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer) -> None: ...
|
||||
def handle(self) -> None: ...
|
||||
def handle_one_request(self) -> None: ...
|
||||
def handle_expect_100(self) -> bool: ...
|
||||
def send_error(self, code: int, message: Optional[str] = ...,
|
||||
explain: Optional[str] = ...) -> None: ...
|
||||
def send_response(self, code: int,
|
||||
message: Optional[str] = ...) -> None: ...
|
||||
def send_error(self, code: int, message: Optional[str] = ..., explain: Optional[str] = ...) -> None: ...
|
||||
def send_response(self, code: int, message: Optional[str] = ...) -> None: ...
|
||||
def send_header(self, keyword: str, value: str) -> None: ...
|
||||
def send_response_only(self, code: int,
|
||||
message: Optional[str] = ...) -> None: ...
|
||||
def send_response_only(self, code: int, message: Optional[str] = ...) -> None: ...
|
||||
def end_headers(self) -> None: ...
|
||||
def flush_headers(self) -> None: ...
|
||||
def log_request(self, code: Union[int, str] = ...,
|
||||
size: Union[int, str] = ...) -> None: ...
|
||||
def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ...
|
||||
def log_error(self, format: str, *args: Any) -> None: ...
|
||||
def log_message(self, format: str, *args: Any) -> None: ...
|
||||
def version_string(self) -> str: ...
|
||||
@@ -63,11 +57,15 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
|
||||
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
||||
extensions_map: Dict[str, str]
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int],
|
||||
server: socketserver.BaseServer, directory: Optional[Union[str, _PathLike[str]]]) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
request: bytes,
|
||||
client_address: Tuple[str, int],
|
||||
server: socketserver.BaseServer,
|
||||
directory: Optional[Union[str, _PathLike[str]]],
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int],
|
||||
server: socketserver.BaseServer) -> None: ...
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer) -> None: ...
|
||||
def do_GET(self) -> None: ...
|
||||
def do_HEAD(self) -> None: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user