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,17 +1,17 @@
from abc import abstractmethod
from types import TracebackType
from typing import IO, Callable, List, MutableMapping, Optional, Text, Tuple, Type
from typing import IO, Callable, MutableMapping, Optional, Text
from .headers import Headers
from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment
from .util import FileWrapper
_exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
_exc_info = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]]
def format_date_time(timestamp: float | None) -> str: ... # undocumented
class BaseHandler:
wsgi_version: Tuple[int, int] # undocumented
wsgi_version: tuple[int, int] # undocumented
wsgi_multithread: bool
wsgi_multiprocess: bool
wsgi_run_once: bool
@@ -22,12 +22,12 @@ class BaseHandler:
os_environ: MutableMapping[str, str]
wsgi_file_wrapper: Type[FileWrapper] | None
headers_class: Type[Headers] # undocumented
wsgi_file_wrapper: type[FileWrapper] | None
headers_class: type[Headers] # undocumented
traceback_limit: int | None
error_status: str
error_headers: List[Tuple[Text, Text]]
error_headers: list[tuple[Text, Text]]
error_body: bytes
def run(self, application: WSGIApplication) -> None: ...
def setup_environ(self) -> None: ...
@@ -36,7 +36,7 @@ class BaseHandler:
def set_content_length(self) -> None: ...
def cleanup_headers(self) -> None: ...
def start_response(
self, status: Text, headers: List[Tuple[Text, Text]], exc_info: _exc_info | None = ...
self, status: Text, headers: list[tuple[Text, Text]], exc_info: _exc_info | None = ...
) -> Callable[[bytes], None]: ...
def send_preamble(self) -> None: ...
def write(self, data: bytes) -> None: ...
@@ -48,7 +48,7 @@ class BaseHandler:
def client_is_modern(self) -> bool: ...
def log_exception(self, exc_info: _exc_info) -> None: ...
def handle_error(self) -> None: ...
def error_output(self, environ: WSGIEnvironment, start_response: StartResponse) -> List[bytes]: ...
def error_output(self, environ: WSGIEnvironment, start_response: StartResponse) -> list[bytes]: ...
@abstractmethod
def _write(self, data: bytes) -> None: ...
@abstractmethod

View File

@@ -1,6 +1,6 @@
from typing import List, Pattern, Tuple, overload
from typing import Pattern, overload
_HeaderList = List[Tuple[str, str]]
_HeaderList = list[tuple[str, str]]
tspecials: Pattern[str] # undocumented
@@ -12,13 +12,13 @@ class Headers:
def __getitem__(self, name: str) -> str | None: ...
def has_key(self, name: str) -> bool: ...
def __contains__(self, name: str) -> bool: ...
def get_all(self, name: str) -> List[str]: ...
def get_all(self, name: str) -> list[str]: ...
@overload
def get(self, name: str, default: str) -> str: ...
@overload
def get(self, name: str, default: str | None = ...) -> str | None: ...
def keys(self) -> List[str]: ...
def values(self) -> List[str]: ...
def keys(self) -> list[str]: ...
def values(self) -> list[str]: ...
def items(self) -> _HeaderList: ...
def setdefault(self, name: str, value: str) -> str: ...
def add_header(self, _name: str, _value: str | None, **_params: str | None) -> None: ...

View File

@@ -1,5 +1,5 @@
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from typing import List, Type, TypeVar, overload
from typing import TypeVar, overload
from .handlers import SimpleHandler
from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment
@@ -25,13 +25,13 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
def get_stderr(self) -> ErrorStream: ...
def handle(self) -> None: ...
def demo_app(environ: WSGIEnvironment, start_response: StartResponse) -> List[bytes]: ...
def demo_app(environ: WSGIEnvironment, start_response: StartResponse) -> list[bytes]: ...
_S = TypeVar("_S", bound=WSGIServer)
@overload
def make_server(host: str, port: int, app: WSGIApplication, *, handler_class: Type[WSGIRequestHandler] = ...) -> WSGIServer: ...
def make_server(host: str, port: int, app: WSGIApplication, *, handler_class: type[WSGIRequestHandler] = ...) -> WSGIServer: ...
@overload
def make_server(
host: str, port: int, app: WSGIApplication, server_class: Type[_S], handler_class: Type[WSGIRequestHandler] = ...
host: str, port: int, app: WSGIApplication, server_class: type[_S], handler_class: type[WSGIRequestHandler] = ...
) -> _S: ...