mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Switch to PEP-604 syntax in python2 stubs (#5915)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import ssl
|
||||
from httplib import HTTPConnectionProtocol, HTTPResponse
|
||||
from typing import Any, AnyStr, Callable, Dict, List, Mapping, Optional, Sequence, Text, Tuple, Type, Union
|
||||
from typing import Any, AnyStr, Callable, Dict, List, Mapping, Sequence, Text, Tuple, Type, Union
|
||||
from urllib import addinfourl
|
||||
|
||||
_string = Union[str, unicode]
|
||||
|
||||
class URLError(IOError):
|
||||
reason: Union[str, BaseException]
|
||||
reason: str | BaseException
|
||||
|
||||
class HTTPError(URLError, addinfourl):
|
||||
code: int
|
||||
@@ -19,16 +19,16 @@ class Request(object):
|
||||
data: str
|
||||
headers: Dict[str, str]
|
||||
unverifiable: bool
|
||||
type: Optional[str]
|
||||
type: str | None
|
||||
origin_req_host = ...
|
||||
unredirected_hdrs: Dict[str, str]
|
||||
timeout: Optional[float] # Undocumented, only set after __init__() by OpenerDirector.open()
|
||||
timeout: float | None # Undocumented, only set after __init__() by OpenerDirector.open()
|
||||
def __init__(
|
||||
self,
|
||||
url: str,
|
||||
data: Optional[str] = ...,
|
||||
data: str | None = ...,
|
||||
headers: Dict[str, str] = ...,
|
||||
origin_req_host: Optional[str] = ...,
|
||||
origin_req_host: str | None = ...,
|
||||
unverifiable: bool = ...,
|
||||
) -> None: ...
|
||||
def __getattr__(self, attr): ...
|
||||
@@ -47,30 +47,28 @@ class Request(object):
|
||||
def add_header(self, key: str, val: str) -> None: ...
|
||||
def add_unredirected_header(self, key: str, val: str) -> None: ...
|
||||
def has_header(self, header_name: str) -> bool: ...
|
||||
def get_header(self, header_name: str, default: Optional[str] = ...) -> str: ...
|
||||
def get_header(self, header_name: str, default: str | None = ...) -> str: ...
|
||||
def header_items(self): ...
|
||||
|
||||
class OpenerDirector(object):
|
||||
addheaders: List[Tuple[str, str]]
|
||||
def add_handler(self, handler: BaseHandler) -> None: ...
|
||||
def open(
|
||||
self, fullurl: Union[Request, _string], data: Optional[_string] = ..., timeout: Optional[float] = ...
|
||||
) -> Optional[addinfourl]: ...
|
||||
def open(self, fullurl: Request | _string, data: _string | None = ..., timeout: float | None = ...) -> addinfourl | None: ...
|
||||
def error(self, proto: _string, *args: Any): ...
|
||||
|
||||
# Note that this type is somewhat a lie. The return *can* be None if
|
||||
# a custom opener has been installed that fails to handle the request.
|
||||
def urlopen(
|
||||
url: Union[Request, _string],
|
||||
data: Optional[_string] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
cafile: Optional[_string] = ...,
|
||||
capath: Optional[_string] = ...,
|
||||
url: Request | _string,
|
||||
data: _string | None = ...,
|
||||
timeout: float | None = ...,
|
||||
cafile: _string | None = ...,
|
||||
capath: _string | None = ...,
|
||||
cadefault: bool = ...,
|
||||
context: Optional[ssl.SSLContext] = ...,
|
||||
context: ssl.SSLContext | None = ...,
|
||||
) -> addinfourl: ...
|
||||
def install_opener(opener: OpenerDirector) -> None: ...
|
||||
def build_opener(*handlers: Union[BaseHandler, Type[BaseHandler]]) -> OpenerDirector: ...
|
||||
def build_opener(*handlers: BaseHandler | Type[BaseHandler]) -> OpenerDirector: ...
|
||||
|
||||
class BaseHandler:
|
||||
handler_order: int
|
||||
@@ -97,21 +95,21 @@ class HTTPRedirectHandler(BaseHandler):
|
||||
|
||||
class ProxyHandler(BaseHandler):
|
||||
proxies: Mapping[str, str]
|
||||
def __init__(self, proxies: Optional[Mapping[str, str]] = ...): ...
|
||||
def __init__(self, proxies: Mapping[str, str] | None = ...): ...
|
||||
def proxy_open(self, req: Request, proxy, type): ...
|
||||
|
||||
class HTTPPasswordMgr:
|
||||
def __init__(self) -> None: ...
|
||||
def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ...
|
||||
def find_user_password(self, realm: Optional[Text], authuri: Text) -> Tuple[Any, Any]: ...
|
||||
def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ...
|
||||
def find_user_password(self, realm: Text | None, authuri: Text) -> 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: Optional[HTTPPasswordMgr] = ...) -> None: ...
|
||||
def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ...
|
||||
def __init__(self, password_mgr: HTTPPasswordMgr | None = ...) -> None: ...
|
||||
def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ...
|
||||
def http_error_auth_reqed(self, authreq, host, req: Request, headers: Mapping[str, str]): ...
|
||||
def retry_http_basic_auth(self, host, req: Request, realm): ...
|
||||
|
||||
@@ -124,15 +122,15 @@ class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
|
||||
def http_error_407(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
|
||||
|
||||
class AbstractDigestAuthHandler:
|
||||
def __init__(self, passwd: Optional[HTTPPasswordMgr] = ...) -> None: ...
|
||||
def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ...
|
||||
def __init__(self, passwd: HTTPPasswordMgr | None = ...) -> None: ...
|
||||
def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ...
|
||||
def reset_retry_count(self) -> None: ...
|
||||
def http_error_auth_reqed(self, auth_header: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ...
|
||||
def retry_http_digest_auth(self, req: Request, auth: str) -> Optional[HTTPResponse]: ...
|
||||
def retry_http_digest_auth(self, req: Request, auth: str) -> HTTPResponse | None: ...
|
||||
def get_cnonce(self, nonce: str) -> str: ...
|
||||
def get_authorization(self, req: Request, chal: Mapping[str, str]) -> str: ...
|
||||
def get_algorithm_impls(self, algorithm: str) -> Tuple[Callable[[str], str], Callable[[str, str], str]]: ...
|
||||
def get_entity_digest(self, data: Optional[bytes], chal: Mapping[str, str]) -> Optional[str]: ...
|
||||
def get_entity_digest(self, data: bytes | None, chal: Mapping[str, str]) -> str | None: ...
|
||||
|
||||
class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
|
||||
auth_header: str
|
||||
@@ -148,19 +146,19 @@ class AbstractHTTPHandler(BaseHandler): # undocumented
|
||||
def __init__(self, debuglevel: int = ...) -> None: ...
|
||||
def set_http_debuglevel(self, level: int) -> None: ...
|
||||
def do_request_(self, request: Request) -> Request: ...
|
||||
def do_open(self, http_class: HTTPConnectionProtocol, req: Request, **http_conn_args: Optional[Any]) -> addinfourl: ...
|
||||
def do_open(self, http_class: HTTPConnectionProtocol, req: Request, **http_conn_args: Any | None) -> addinfourl: ...
|
||||
|
||||
class HTTPHandler(AbstractHTTPHandler):
|
||||
def http_open(self, req: Request) -> addinfourl: ...
|
||||
def http_request(self, request: Request) -> Request: ... # undocumented
|
||||
|
||||
class HTTPSHandler(AbstractHTTPHandler):
|
||||
def __init__(self, debuglevel: int = ..., context: Optional[ssl.SSLContext] = ...) -> None: ...
|
||||
def __init__(self, debuglevel: int = ..., context: ssl.SSLContext | None = ...) -> None: ...
|
||||
def https_open(self, req: Request) -> addinfourl: ...
|
||||
def https_request(self, request: Request) -> Request: ... # undocumented
|
||||
|
||||
class HTTPCookieProcessor(BaseHandler):
|
||||
def __init__(self, cookiejar: Optional[Any] = ...): ...
|
||||
def __init__(self, cookiejar: Any | None = ...): ...
|
||||
def http_request(self, request: Request): ...
|
||||
def http_response(self, request: Request, response): ...
|
||||
|
||||
@@ -178,7 +176,7 @@ class FTPHandler(BaseHandler):
|
||||
|
||||
class CacheFTPHandler(FTPHandler):
|
||||
def __init__(self) -> None: ...
|
||||
def setTimeout(self, t: Optional[float]): ...
|
||||
def setTimeout(self, t: float | None): ...
|
||||
def setMaxConns(self, m: int): ...
|
||||
def check_cache(self): ...
|
||||
def clear_cache(self): ...
|
||||
|
||||
Reference in New Issue
Block a user