Split stdlib into Python 2 and 3 versions (#5442)

All new files in stdlib/@python2 are straight copies of the
corresponding files in stdlib.
This commit is contained in:
Sebastian Rittau
2021-05-14 21:04:12 +02:00
committed by GitHub
parent 8971c242cb
commit 5b739e0ccb
218 changed files with 18067 additions and 15 deletions

View File

View File

@@ -0,0 +1,93 @@
import sys
from abc import abstractmethod
from types import TracebackType
from typing import IO, Callable, Dict, List, MutableMapping, Optional, Text, Tuple, Type
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]]
def format_date_time(timestamp: Optional[float]) -> str: ... # undocumented
if sys.version_info >= (3, 2):
def read_environ() -> Dict[str, str]: ...
class BaseHandler:
wsgi_version: Tuple[int, int] # undocumented
wsgi_multithread: bool
wsgi_multiprocess: bool
wsgi_run_once: bool
origin_server: bool
http_version: str
server_software: Optional[str]
os_environ: MutableMapping[str, str]
wsgi_file_wrapper: Optional[Type[FileWrapper]]
headers_class: Type[Headers] # undocumented
traceback_limit: Optional[int]
error_status: str
error_headers: List[Tuple[Text, Text]]
error_body: bytes
def run(self, application: WSGIApplication) -> None: ...
def setup_environ(self) -> None: ...
def finish_response(self) -> None: ...
def get_scheme(self) -> str: ...
def set_content_length(self) -> None: ...
def cleanup_headers(self) -> None: ...
def start_response(
self, status: Text, headers: List[Tuple[Text, Text]], exc_info: Optional[_exc_info] = ...
) -> Callable[[bytes], None]: ...
def send_preamble(self) -> None: ...
def write(self, data: bytes) -> None: ...
def sendfile(self) -> bool: ...
def finish_content(self) -> None: ...
def close(self) -> None: ...
def send_headers(self) -> None: ...
def result_is_file(self) -> bool: ...
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]: ...
@abstractmethod
def _write(self, data: bytes) -> None: ...
@abstractmethod
def _flush(self) -> None: ...
@abstractmethod
def get_stdin(self) -> InputStream: ...
@abstractmethod
def get_stderr(self) -> ErrorStream: ...
@abstractmethod
def add_cgi_vars(self) -> None: ...
class SimpleHandler(BaseHandler):
stdin: InputStream
stdout: IO[bytes]
stderr: ErrorStream
base_env: MutableMapping[str, str]
def __init__(
self,
stdin: InputStream,
stdout: IO[bytes],
stderr: ErrorStream,
environ: MutableMapping[str, str],
multithread: bool = ...,
multiprocess: bool = ...,
) -> None: ...
def get_stdin(self) -> InputStream: ...
def get_stderr(self) -> ErrorStream: ...
def add_cgi_vars(self) -> None: ...
def _write(self, data: bytes) -> None: ...
def _flush(self) -> None: ...
class BaseCGIHandler(SimpleHandler): ...
class CGIHandler(BaseCGIHandler):
def __init__(self) -> None: ...
class IISCGIHandler(BaseCGIHandler):
def __init__(self) -> None: ...

View File

@@ -0,0 +1,31 @@
import sys
from typing import List, Optional, Pattern, Tuple, overload
_HeaderList = List[Tuple[str, str]]
tspecials: Pattern[str] # undocumented
class Headers:
if sys.version_info < (3, 5):
def __init__(self, headers: _HeaderList) -> None: ...
else:
def __init__(self, headers: Optional[_HeaderList] = ...) -> None: ...
def __len__(self) -> int: ...
def __setitem__(self, name: str, val: str) -> None: ...
def __delitem__(self, name: str) -> None: ...
def __getitem__(self, name: str) -> Optional[str]: ...
if sys.version_info < (3,):
def has_key(self, name: str) -> bool: ...
def __contains__(self, name: str) -> bool: ...
def get_all(self, name: str) -> List[str]: ...
@overload
def get(self, name: str, default: str) -> str: ...
@overload
def get(self, name: str, default: Optional[str] = ...) -> Optional[str]: ...
def keys(self) -> List[str]: ...
def values(self) -> List[str]: ...
def items(self) -> _HeaderList: ...
if sys.version_info >= (3,):
def __bytes__(self) -> bytes: ...
def setdefault(self, name: str, value: str) -> str: ...
def add_header(self, _name: str, _value: Optional[str], **_params: Optional[str]) -> None: ...

View File

@@ -0,0 +1,42 @@
import sys
from typing import List, Optional, Type, TypeVar, overload
from .handlers import SimpleHandler
from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment
if sys.version_info >= (3, 0):
from http.server import BaseHTTPRequestHandler, HTTPServer
else:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
server_version: str # undocumented
sys_version: str # undocumented
software_version: str # undocumented
class ServerHandler(SimpleHandler): # undocumented
server_software: str
def close(self) -> None: ...
class WSGIServer(HTTPServer):
application: Optional[WSGIApplication]
base_environ: WSGIEnvironment # only available after call to setup_environ()
def setup_environ(self) -> None: ...
def get_app(self) -> Optional[WSGIApplication]: ...
def set_app(self, application: Optional[WSGIApplication]) -> None: ...
class WSGIRequestHandler(BaseHTTPRequestHandler):
server_version: str
def get_environ(self) -> WSGIEnvironment: ...
def get_stderr(self) -> ErrorStream: ...
def handle(self) -> None: ...
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: ...
@overload
def make_server(
host: str, port: int, app: WSGIApplication, server_class: Type[_S], handler_class: Type[WSGIRequestHandler] = ...
) -> _S: ...

View File

@@ -0,0 +1,3 @@
# Obsolete, use _typeshed.wsgi directly.
from _typeshed.wsgi import *

View File

@@ -0,0 +1,23 @@
import sys
from typing import IO, Any, Callable, Optional
from .types import WSGIEnvironment
class FileWrapper:
filelike: IO[bytes]
blksize: int
close: Callable[[], None] # only exists if filelike.close exists
def __init__(self, filelike: IO[bytes], blksize: int = ...) -> None: ...
def __getitem__(self, key: Any) -> bytes: ...
def __iter__(self) -> FileWrapper: ...
if sys.version_info >= (3, 0):
def __next__(self) -> bytes: ...
else:
def next(self) -> bytes: ...
def guess_scheme(environ: WSGIEnvironment) -> str: ...
def application_uri(environ: WSGIEnvironment) -> str: ...
def request_uri(environ: WSGIEnvironment, include_query: bool = ...) -> str: ...
def shift_path_info(environ: WSGIEnvironment) -> Optional[str]: ...
def setup_testing_defaults(environ: WSGIEnvironment) -> None: ...
def is_hop_by_hop(header_name: str) -> bool: ...

View File

@@ -0,0 +1,52 @@
import sys
from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication
from typing import Any, Callable, Iterable, Iterator, NoReturn, Optional
class WSGIWarning(Warning): ...
def validator(application: WSGIApplication) -> WSGIApplication: ...
class InputWrapper:
input: InputStream
def __init__(self, wsgi_input: InputStream) -> None: ...
if sys.version_info >= (3, 0):
def read(self, size: int) -> bytes: ...
def readline(self, size: int = ...) -> bytes: ...
else:
def read(self, size: int = ...) -> bytes: ...
def readline(self) -> bytes: ...
def readlines(self, hint: int = ...) -> bytes: ...
def __iter__(self) -> Iterable[bytes]: ...
def close(self) -> NoReturn: ...
class ErrorWrapper:
errors: ErrorStream
def __init__(self, wsgi_errors: ErrorStream) -> None: ...
def write(self, s: str) -> None: ...
def flush(self) -> None: ...
def writelines(self, seq: Iterable[str]) -> None: ...
def close(self) -> NoReturn: ...
class WriteWrapper:
writer: Callable[[bytes], Any]
def __init__(self, wsgi_writer: Callable[[bytes], Any]) -> None: ...
def __call__(self, s: bytes) -> None: ...
class PartialIteratorWrapper:
iterator: Iterator[bytes]
def __init__(self, wsgi_iterator: Iterator[bytes]) -> None: ...
def __iter__(self) -> IteratorWrapper: ...
class IteratorWrapper:
original_iterator: Iterator[bytes]
iterator: Iterator[bytes]
closed: bool
check_start_response: Optional[bool]
def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: Optional[bool]) -> None: ...
def __iter__(self) -> IteratorWrapper: ...
if sys.version_info >= (3, 0):
def __next__(self) -> bytes: ...
else:
def next(self) -> bytes: ...
def close(self) -> None: ...
def __del__(self) -> None: ...