mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Annotate some missing http client and urllib APIs. (#2582)
This commit is contained in:
committed by
Sebastian Rittau
parent
c7b0e60032
commit
cd4572e43c
@@ -46,6 +46,8 @@ class HTTPConnection:
|
||||
timeout = ... # type: Any
|
||||
source_address = ... # type: Any
|
||||
sock = ... # type: Any
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
def __init__(self, host, port=None, strict=None, timeout=..., source_address=None) -> None: ...
|
||||
def set_tunnel(self, host, port=None, headers=None): ...
|
||||
def set_debuglevel(self, level): ...
|
||||
|
||||
@@ -131,7 +131,7 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
||||
class AbstractHTTPHandler(BaseHandler):
|
||||
def __init__(self, debuglevel: int = ...) -> None: ...
|
||||
def do_request_(self, request): ...
|
||||
def do_open(self, http_class, req): ...
|
||||
def do_open(self, http_class, req): ... # undocumented
|
||||
|
||||
class HTTPHandler(AbstractHTTPHandler):
|
||||
def http_open(self, req): ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from typing import (
|
||||
Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional, Tuple, Type, TypeVar,
|
||||
Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional,
|
||||
Protocol, Tuple, Type, TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
BinaryIO,
|
||||
@@ -107,6 +108,7 @@ if sys.version_info >= (3, 5):
|
||||
def info(self) -> email.message.Message: ...
|
||||
def geturl(self) -> str: ...
|
||||
def getcode(self) -> int: ...
|
||||
def begin(self) -> None: ...
|
||||
else:
|
||||
class HTTPResponse(io.RawIOBase, BinaryIO): # type: ignore
|
||||
msg = ... # type: HTTPMessage
|
||||
@@ -132,8 +134,24 @@ else:
|
||||
def info(self) -> email.message.Message: ...
|
||||
def geturl(self) -> str: ...
|
||||
def getcode(self) -> int: ...
|
||||
def begin(self) -> None: ...
|
||||
|
||||
# This is an API stub only for the class below, not a class itself.
|
||||
# urllib.request uses it for a parameter.
|
||||
class HTTPConnectionProtocol(Protocol):
|
||||
if sys.version_info >= (3, 7):
|
||||
def __call__(self, host: str, port: Optional[int] = ...,
|
||||
timeout: int = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ...,
|
||||
blocksize: int = ...): ...
|
||||
else:
|
||||
def __call__(self, host: str, port: Optional[int] = ...,
|
||||
timeout: int = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ...): ...
|
||||
|
||||
class HTTPConnection:
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self,
|
||||
@@ -148,9 +166,15 @@ class HTTPConnection:
|
||||
timeout: int = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ...
|
||||
) -> None: ...
|
||||
def request(self, method: str, url: str,
|
||||
body: Optional[_DataType] = ...,
|
||||
headers: Mapping[str, str] = ...) -> 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: ...
|
||||
else:
|
||||
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] = ...,
|
||||
@@ -160,7 +184,11 @@ class HTTPConnection:
|
||||
def putrequest(self, request: str, selector: str, skip_host: bool = ...,
|
||||
skip_accept_encoding: bool = ...) -> None: ...
|
||||
def putheader(self, header: str, *argument: str) -> None: ...
|
||||
def endheaders(self, message_body: Optional[_DataType] = ...) -> None: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
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):
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import (
|
||||
Any, Callable, ClassVar, Dict, List, IO, Mapping, Optional, Sequence, Tuple,
|
||||
TypeVar, Union, overload, NoReturn,
|
||||
)
|
||||
from http.client import HTTPResponse, HTTPMessage
|
||||
from http.client import HTTPResponse, HTTPMessage, HTTPConnectionProtocol
|
||||
from http.cookiejar import CookieJar
|
||||
from email.message import Message
|
||||
from urllib.response import addinfourl
|
||||
@@ -159,6 +159,9 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
||||
|
||||
class HTTPHandler(BaseHandler):
|
||||
def http_open(self, req: Request) -> HTTPResponse: ...
|
||||
def do_open(self, # undocumented
|
||||
http_class: HTTPConnectionProtocol,
|
||||
req: Request) -> HTTPResponse: ...
|
||||
|
||||
class HTTPSHandler(BaseHandler):
|
||||
def __init__(self, debuglevel: int = ...,
|
||||
|
||||
Reference in New Issue
Block a user