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

@@ -1,4 +1,4 @@
# Type declaration for a WSGI Function in Python 2
# 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.
@@ -15,21 +15,27 @@
# 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]]
_Text = Union[unicode, str]
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[[_Text], None]],
Callable[[_Text, List[Tuple[_Text, _Text]], _exc_info], Callable[[_Text], None]]
Callable[[_Text, List[Tuple[_Text, _Text]]], Callable[[_BText], None]],
Callable[[_Text, List[Tuple[_Text, _Text]], _exc_info], Callable[[_BText], None]]
]
],
Iterable[_Text]
Iterable[_BText]
]

View File

@@ -1,3 +1,4 @@
import sys
from typing import Any
class WSGIWarning(Warning): ...
@@ -8,7 +9,10 @@ class InputWrapper:
input = ... # type: Any
def __init__(self, wsgi_input): ...
def read(self, *args): ...
def readline(self): ...
if sys.version_info < (3,):
def readline(self): ...
else:
def readline(self, *args): ...
def readlines(self, *args): ...
def __iter__(self): ...
def close(self): ...
@@ -38,6 +42,9 @@ class IteratorWrapper:
check_start_response = ... # type: Any
def __init__(self, wsgi_iterator, check_start_response): ...
def __iter__(self): ...
def next(self): ...
if sys.version_info < (3,):
def next(self): ...
else:
def __next__(self): ...
def close(self): ...
def __del__(self): ...

View File

@@ -1,34 +0,0 @@
# Type declaration for a WSGI Function in Python 3
#
# 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.
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]]
WSGIEnvironment = Dict[str, Any]
WSGIApplication = Callable[
[
WSGIEnvironment,
Union[
Callable[[str, List[Tuple[str, str]]], Callable[[Union[bytes, str]], None]],
Callable[[str, List[Tuple[str, str]], _exc_info], Callable[[Union[bytes, str]], None]]
]
],
Iterable[Union[bytes, str]]
]

View File

@@ -1,43 +0,0 @@
from typing import Any
class WSGIWarning(Warning): ...
def validator(application): ...
class InputWrapper:
input = ... # type: Any
def __init__(self, wsgi_input): ...
def read(self, *args): ...
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): ...
def __next__(self): ...
def close(self): ...
def __del__(self): ...