Merge Python 2 and 3 wsgiref (#2106)

* Merge Python 2 and 3 wsgiref

* Move wsigref to 2and3
This commit is contained in:
Sebastian Rittau
2018-05-10 01:26:03 +02:00
committed by Jelle Zijlstra
parent 3f196bde44
commit 09008599ce
6 changed files with 20 additions and 84 deletions

View File

View File

@@ -0,0 +1,41 @@
# Type declaration for a WSGI Function
#
# wsgiref/types.py doesn't exist and neither does WSGIApplication, it's a type
# provided for type checking purposes.
#
# This means you cannot simply import wsgiref.types in your code. Instead,
# use the `TYPE_CHECKING` flag from the typing module:
#
# from typing import TYPE_CHECKING
#
# if TYPE_CHECKING:
# from wsgiref.types import WSGIApplication
#
# This import is now only taken into account by the type checker. Consequently,
# you need to use 'WSGIApplication' and not simply WSGIApplication when type
# hinting your code. Otherwise Python will raise NameErrors.
import sys
from typing import Callable, Dict, Iterable, List, Optional, Tuple, Type, Union, Any
from types import TracebackType
_exc_info = Tuple[Optional[Type[BaseException]],
Optional[BaseException],
Optional[TracebackType]]
if sys.version_info < (3,):
_Text = Union[unicode, str]
_BText = _Text
else:
_Text = str
_BText = Union[bytes, str]
WSGIEnvironment = Dict[_Text, Any]
WSGIApplication = Callable[
[
WSGIEnvironment,
Union[
Callable[[_Text, List[Tuple[_Text, _Text]]], Callable[[_BText], None]],
Callable[[_Text, List[Tuple[_Text, _Text]], _exc_info], Callable[[_BText], None]]
]
],
Iterable[_BText]
]

View File

@@ -0,0 +1,50 @@
import sys
from typing import Any
class WSGIWarning(Warning): ...
def validator(application): ...
class InputWrapper:
input = ... # type: Any
def __init__(self, wsgi_input): ...
def read(self, *args): ...
if sys.version_info < (3,):
def readline(self): ...
else:
def readline(self, *args): ...
def readlines(self, *args): ...
def __iter__(self): ...
def close(self): ...
class ErrorWrapper:
errors = ... # type: Any
def __init__(self, wsgi_errors): ...
def write(self, s): ...
def flush(self): ...
def writelines(self, seq): ...
def close(self): ...
class WriteWrapper:
writer = ... # type: Any
def __init__(self, wsgi_writer): ...
def __call__(self, s): ...
class PartialIteratorWrapper:
iterator = ... # type: Any
def __init__(self, wsgi_iterator): ...
def __iter__(self): ...
class IteratorWrapper:
original_iterator = ... # type: Any
iterator = ... # type: Any
closed = ... # type: Any
check_start_response = ... # type: Any
def __init__(self, wsgi_iterator, check_start_response): ...
def __iter__(self): ...
if sys.version_info < (3,):
def next(self): ...
else:
def __next__(self): ...
def close(self): ...
def __del__(self): ...