mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-31 16:44:25 +08:00
Add some missing types to urllib2 (#1012)
* add some missing types to urllib2 stubs There are still a number of missing types in this file. * uri is the union, not realm
This commit is contained in:
committed by
Jukka Lehtosalo
parent
d43f3be914
commit
13dbbf9084
@@ -1,8 +1,11 @@
|
||||
|
||||
from typing import AnyStr, Dict, List, Union, Optional, Mapping, Callable, Tuple
|
||||
import ssl
|
||||
from typing import Any, AnyStr, Dict, List, Union, Optional, Mapping, Callable, Sequence, Tuple
|
||||
from urllib import addinfourl
|
||||
from httplib import HTTPResponse
|
||||
|
||||
_string = Union[str, unicode]
|
||||
|
||||
class URLError(IOError):
|
||||
reason = ... # type: Union[str, BaseException]
|
||||
|
||||
@@ -16,12 +19,12 @@ class Request(object):
|
||||
data = ... # type: str
|
||||
headers = ... # type: Dict[str, str]
|
||||
unverifiable = ... # type: bool
|
||||
type = ...
|
||||
type = ... # type: Optional[str]
|
||||
origin_req_host = ...
|
||||
unredirected_hdrs = ...
|
||||
|
||||
def __init__(self, url: str, data: str = None, headers: Dict[str, str] = ...,
|
||||
origin_req_host: str = None, unverifiable: bool = ...) -> None: ...
|
||||
def __init__(self, url: str, data: Optional[str] = ..., headers: Dict[str, str] = ...,
|
||||
origin_req_host: Optional[str] = ..., unverifiable: bool = ...) -> None: ...
|
||||
def __getattr__(self, attr): ...
|
||||
def get_method(self) -> str: ...
|
||||
def add_data(self, data) -> None: ...
|
||||
@@ -41,19 +44,24 @@ class Request(object):
|
||||
def get_header(self, header_name: str, default: str = None) -> str: ...
|
||||
def header_items(self): ...
|
||||
|
||||
class OpenerDirector(object): ...
|
||||
class OpenerDirector(object):
|
||||
def add_handler(self, handler: BaseHandler) -> None: ...
|
||||
def open(self, url: Union[Request, _string], data: Optional[_string] = ..., timeout: int = ...): ...
|
||||
def error(self, proto: _string, *args: Any): ...
|
||||
|
||||
def urlopen(url, data=None, timeout=..., cafile=None, capath=None, cadefault=False,
|
||||
context=None): ...
|
||||
def install_opener(opener): ...
|
||||
def build_opener(*handlers): ...
|
||||
def urlopen(url: Union[Request, _string], data: Optional[_string] = ..., timeout: int = ...,
|
||||
cafile: Optional[_string] = ..., capath: Optional[_string] = ..., cadefault: bool = ...,
|
||||
context: Optional[ssl.SSLContext] = ...): ...
|
||||
def install_opener(opener: OpenerDirector) -> None: ...
|
||||
def build_opener(*handlers: BaseHandler) -> OpenerDirector: ...
|
||||
|
||||
class BaseHandler:
|
||||
handler_order = ... # int
|
||||
handler_order = ... # type: int
|
||||
parent = ... # type: OpenerDirector
|
||||
|
||||
def add_parent(self, parent) -> None: ...
|
||||
def add_parent(self, parent: OpenerDirector) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def __lt__(self, other) -> bool: ...
|
||||
def __lt__(self, other: Any) -> bool: ...
|
||||
|
||||
class HTTPErrorProcessor(BaseHandler):
|
||||
def http_response(self, request, response): ...
|
||||
@@ -62,8 +70,8 @@ class HTTPDefaultErrorHandler(BaseHandler):
|
||||
def http_error_default(self, req, fp, code, msg, hdrs): ...
|
||||
|
||||
class HTTPRedirectHandler(BaseHandler):
|
||||
max_repeats = ... # int
|
||||
max_redirections = ... # int
|
||||
max_repeats = ... # type: int
|
||||
max_redirections = ... # type: int
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl): ...
|
||||
def http_error_301(self, req, fp, code, msg, headers): ...
|
||||
def http_error_302(self, req, fp, code, msg, headers): ...
|
||||
@@ -78,16 +86,15 @@ class ProxyHandler(BaseHandler):
|
||||
|
||||
class HTTPPasswordMgr:
|
||||
def __init__(self) -> None: ...
|
||||
def add_password(self, realm, uri, user, passwd): ...
|
||||
def find_user_password(self, realm, authuri): ...
|
||||
def reduce_uri(self, uri, default_port: bool): ...
|
||||
def is_suburi(self, base, test): ...
|
||||
def add_password(self, realm: _string, uri: Union[_string, Sequence[_string]], user: _string, passwd: _string) -> None: ...
|
||||
def find_user_password(self, realm: _string, authuri: _string) -> Tuple[Any, Any]: ...
|
||||
def reduce_uri(self, uri: _string, default_port: bool = ...) -> Tuple[Any, Any]: ...
|
||||
def is_suburi(self, base: _string, test: _string) -> bool: ...
|
||||
|
||||
class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): ...
|
||||
|
||||
class AbstractBasicAuthHandler:
|
||||
def __init__(self, password_mgr=None): ...
|
||||
def reset_retry_count(self): ...
|
||||
def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ...
|
||||
def http_error_auth_reqed(self, authreq, host, req, headers): ...
|
||||
def retry_http_basic_auth(self, host, req, realm): ...
|
||||
|
||||
@@ -111,13 +118,13 @@ class AbstractDigestAuthHandler:
|
||||
def get_entity_digest(self, data: Optional[bytes], chal: Mapping[str, str]) -> Optional[str]: ...
|
||||
|
||||
class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
||||
auth_header = ... # str
|
||||
handler_order = ... # int
|
||||
auth_header = ... # type: str
|
||||
handler_order = ... # type: int
|
||||
def http_error_401(self, req, fp, code, msg, headers): ...
|
||||
|
||||
class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
||||
auth_header = ... # str
|
||||
handler_order = ... # int
|
||||
auth_header = ... # type: str
|
||||
handler_order = ... # type: int
|
||||
def http_error_407(self, req, fp, code, msg, headers): ...
|
||||
|
||||
class AbstractHTTPHandler(BaseHandler):
|
||||
@@ -152,7 +159,7 @@ class FTPHandler(BaseHandler):
|
||||
def connect_ftp(self, user, passwd, host, port, dirs, timeout): ...
|
||||
|
||||
class CacheFTPHandler(FTPHandler):
|
||||
def __init__(self): ...
|
||||
def __init__(self) -> None: ...
|
||||
def setTimeout(self, t): ...
|
||||
def setMaxConns(self, m): ...
|
||||
def check_cache(self): ...
|
||||
|
||||
Reference in New Issue
Block a user