Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)

This commit is contained in:
Alex Waygood
2022-01-18 15:14:03 +00:00
committed by GitHub
parent aa885ecd65
commit 8af5e0d340
264 changed files with 2217 additions and 2411 deletions

View File

@@ -1,6 +1,6 @@
import ssl
from httplib import HTTPConnectionProtocol, HTTPResponse
from typing import Any, AnyStr, Callable, Dict, List, Mapping, Sequence, Text, Tuple, Type, Union
from typing import Any, AnyStr, Callable, Mapping, Sequence, Text, Union
from urllib import addinfourl
_string = Union[str, unicode]
@@ -17,17 +17,17 @@ class Request(object):
host: str
port: str
data: str
headers: Dict[str, str]
headers: dict[str, str]
unverifiable: bool
type: str | None
origin_req_host = ...
unredirected_hdrs: Dict[str, str]
unredirected_hdrs: dict[str, str]
timeout: float | None # Undocumented, only set after __init__() by OpenerDirector.open()
def __init__(
self,
url: str,
data: str | None = ...,
headers: Dict[str, str] = ...,
headers: dict[str, str] = ...,
origin_req_host: str | None = ...,
unverifiable: bool = ...,
) -> None: ...
@@ -51,7 +51,7 @@ class Request(object):
def header_items(self): ...
class OpenerDirector(object):
addheaders: List[Tuple[str, str]]
addheaders: list[tuple[str, str]]
def add_handler(self, handler: BaseHandler) -> None: ...
def open(self, fullurl: Request | _string, data: _string | None = ..., timeout: float | None = ...) -> addinfourl | None: ...
def error(self, proto: _string, *args: Any): ...
@@ -68,7 +68,7 @@ def urlopen(
context: ssl.SSLContext | None = ...,
) -> addinfourl: ...
def install_opener(opener: OpenerDirector) -> None: ...
def build_opener(*handlers: BaseHandler | Type[BaseHandler]) -> OpenerDirector: ...
def build_opener(*handlers: BaseHandler | type[BaseHandler]) -> OpenerDirector: ...
class BaseHandler:
handler_order: int
@@ -101,8 +101,8 @@ class ProxyHandler(BaseHandler):
class HTTPPasswordMgr:
def __init__(self) -> None: ...
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 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): ...
@@ -129,7 +129,7 @@ class AbstractDigestAuthHandler:
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_algorithm_impls(self, algorithm: str) -> tuple[Callable[[str], str], Callable[[str, str], str]]: ...
def get_entity_digest(self, data: bytes | None, chal: Mapping[str, str]) -> str | None: ...
class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
@@ -181,5 +181,5 @@ class CacheFTPHandler(FTPHandler):
def check_cache(self): ...
def clear_cache(self): ...
def parse_http_list(s: AnyStr) -> List[AnyStr]: ...
def parse_keqv_list(l: List[AnyStr]) -> Dict[AnyStr, AnyStr]: ...
def parse_http_list(s: AnyStr) -> list[AnyStr]: ...
def parse_keqv_list(l: list[AnyStr]) -> dict[AnyStr, AnyStr]: ...