mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Move wsgiref.types to _typeshed.wsgi (#4175)
Re-export the types from wsgiref.types for now to avoid breaking existing code. wsgiref.types should be removed eventually. Also, reduce the boilerplate description in _typeshed/wsgi.pyi as it mirrors the description in _typeshed/__init__.pyi.
This commit is contained in:
32
stdlib/2and3/_typeshed/wsgi.pyi
Normal file
32
stdlib/2and3/_typeshed/wsgi.pyi
Normal file
@@ -0,0 +1,32 @@
|
||||
# Types to support PEP 3333 (WSGI)
|
||||
#
|
||||
# This module doesn't exist at runtime and neither do the types defined in this
|
||||
# file. They are provided for type checking purposes.
|
||||
|
||||
from sys import _OptExcInfo
|
||||
from typing import Callable, Dict, Iterable, List, Any, Text, Protocol, Tuple, Optional
|
||||
|
||||
class StartResponse(Protocol):
|
||||
def __call__(self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_OptExcInfo] = ...) -> Callable[[bytes], Any]: ...
|
||||
|
||||
WSGIEnvironment = Dict[Text, Any]
|
||||
WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]]
|
||||
|
||||
# WSGI input streams per PEP 3333
|
||||
class InputStream(Protocol):
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
def readline(self, size: int = ...) -> bytes: ...
|
||||
def readlines(self, hint: int = ...) -> List[bytes]: ...
|
||||
def __iter__(self) -> Iterable[bytes]: ...
|
||||
|
||||
# WSGI error streams per PEP 3333
|
||||
class ErrorStream(Protocol):
|
||||
def flush(self) -> None: ...
|
||||
def write(self, s: str) -> None: ...
|
||||
def writelines(self, seq: List[str]) -> None: ...
|
||||
|
||||
class _Readable(Protocol):
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
# Optional file wrapper in wsgi.file_wrapper
|
||||
class FileWrapper(Protocol):
|
||||
def __call__(self, file: _Readable, block_size: int = ...) -> Iterable[bytes]: ...
|
||||
@@ -1,44 +1,3 @@
|
||||
# Type declaration for a WSGI Function
|
||||
#
|
||||
# wsgiref/types.py doesn't exist and neither do the types defined in this
|
||||
# file. They are 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.
|
||||
# Obsolete, use _typeshed.wsgi directly.
|
||||
|
||||
from sys import _OptExcInfo
|
||||
from typing import Callable, Dict, Iterable, List, Any, Text, Protocol, Tuple, Optional
|
||||
|
||||
class StartResponse(Protocol):
|
||||
def __call__(self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_OptExcInfo] = ...) -> Callable[[bytes], Any]: ...
|
||||
|
||||
WSGIEnvironment = Dict[Text, Any]
|
||||
WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]]
|
||||
|
||||
# WSGI input streams per PEP 3333
|
||||
class InputStream(Protocol):
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
def readline(self, size: int = ...) -> bytes: ...
|
||||
def readlines(self, hint: int = ...) -> List[bytes]: ...
|
||||
def __iter__(self) -> Iterable[bytes]: ...
|
||||
|
||||
# WSGI error streams per PEP 3333
|
||||
class ErrorStream(Protocol):
|
||||
def flush(self) -> None: ...
|
||||
def write(self, s: str) -> None: ...
|
||||
def writelines(self, seq: List[str]) -> None: ...
|
||||
|
||||
class _Readable(Protocol):
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
# Optional file wrapper in wsgi.file_wrapper
|
||||
class FileWrapper(Protocol):
|
||||
def __call__(self, file: _Readable, block_size: int = ...) -> Iterable[bytes]: ...
|
||||
from _typeshed.wsgi import *
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from typing import Any, Iterable, Iterator, Optional, NoReturn, Callable
|
||||
|
||||
from wsgiref.types import WSGIApplication, InputStream, ErrorStream
|
||||
from _typeshed.wsgi import WSGIApplication, InputStream, ErrorStream
|
||||
|
||||
class WSGIWarning(Warning): ...
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ _importlib_modulespec
|
||||
_operator.methodcaller
|
||||
_threading_local.local.__new__
|
||||
_types
|
||||
_typeshed
|
||||
_typeshed.* # Utility types for typeshed, doesn't exist at runtime
|
||||
_weakref.CallableProxyType.__getattr__
|
||||
_weakref.ProxyType.__getattr__
|
||||
_weakref.ReferenceType.__call__
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Iterable, List, Mapping, Optional, Sequence, Set, Text
|
||||
from wsgiref.types import WSGIApplication, WSGIEnvironment, StartResponse
|
||||
from _typeshed.wsgi import WSGIApplication, WSGIEnvironment, StartResponse
|
||||
|
||||
from ..middleware.proxy_fix import ProxyFix as ProxyFix
|
||||
|
||||
|
||||
2
third_party/2and3/werkzeug/exceptions.pyi
vendored
2
third_party/2and3/werkzeug/exceptions.pyi
vendored
@@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
from typing import Any, Dict, Tuple, List, Text, NoReturn, Optional, Protocol, Type, Union, Iterable
|
||||
|
||||
from wsgiref.types import WSGIEnvironment, StartResponse
|
||||
from _typeshed.wsgi import WSGIEnvironment, StartResponse
|
||||
from werkzeug.wrappers import Response
|
||||
|
||||
class _EnvironContainer(Protocol):
|
||||
|
||||
2
third_party/2and3/werkzeug/formparser.pyi
vendored
2
third_party/2and3/werkzeug/formparser.pyi
vendored
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Optional, Text, Tuple, Callable, Iterable, TypeVar, NoReturn, Protocol, IO, Generator, Dict, Mapping, Union
|
||||
from wsgiref.types import WSGIEnvironment
|
||||
from _typeshed.wsgi import WSGIEnvironment
|
||||
|
||||
from .datastructures import Headers
|
||||
|
||||
|
||||
2
third_party/2and3/werkzeug/http.pyi
vendored
2
third_party/2and3/werkzeug/http.pyi
vendored
@@ -4,7 +4,7 @@ from typing import (
|
||||
Dict, Text, Union, Tuple, Any, Optional, Mapping, Iterable, Callable, List, Type,
|
||||
TypeVar, Protocol, overload, SupportsInt,
|
||||
)
|
||||
from wsgiref.types import WSGIEnvironment
|
||||
from _typeshed.wsgi import WSGIEnvironment
|
||||
|
||||
from .datastructures import (
|
||||
Headers, Accept, RequestCacheControl, HeaderSet, Authorization, WWWAuthenticate,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Iterable, Mapping, Optional, Text
|
||||
from wsgiref.types import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
class DispatcherMiddleware(object):
|
||||
app: WSGIApplication
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Dict, Iterable, Mapping, MutableMapping, Text
|
||||
from wsgiref.types import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
_Opts = Mapping[Text, Any]
|
||||
_MutableOpts = MutableMapping[Text, Any]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Protocol, Tuple
|
||||
from wsgiref.types import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
from ..datastructures import Headers
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import IO, Iterable, List, Optional, Text, Tuple, Union
|
||||
from wsgiref.types import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
class ProfilerMiddleware(object):
|
||||
def __init__(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Iterable, Optional
|
||||
from wsgiref.types import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
class ProxyFix(object):
|
||||
app: WSGIApplication
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import datetime
|
||||
from typing import Callable, IO, Iterable, List, Mapping, Optional, Text, Tuple, Union
|
||||
from wsgiref.types import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
_V = Union[Tuple[Text, Text], Text]
|
||||
|
||||
|
||||
2
third_party/2and3/werkzeug/test.pyi
vendored
2
third_party/2and3/werkzeug/test.pyi
vendored
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from wsgiref.types import WSGIEnvironment
|
||||
from _typeshed.wsgi import WSGIEnvironment
|
||||
from typing import Any, Generic, Optional, Text, Tuple, Type, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
|
||||
2
third_party/2and3/werkzeug/wrappers.pyi
vendored
2
third_party/2and3/werkzeug/wrappers.pyi
vendored
@@ -3,7 +3,7 @@ from datetime import datetime
|
||||
from typing import (
|
||||
Any, Callable, Iterable, Iterator, Mapping, MutableMapping, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, overload
|
||||
)
|
||||
from wsgiref.types import WSGIEnvironment, InputStream
|
||||
from _typeshed.wsgi import WSGIEnvironment, InputStream
|
||||
|
||||
from .datastructures import (
|
||||
Authorization, CombinedMultiDict, EnvironHeaders, Headers, ImmutableMultiDict,
|
||||
|
||||
2
third_party/2and3/werkzeug/wsgi.pyi
vendored
2
third_party/2and3/werkzeug/wsgi.pyi
vendored
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Optional, Protocol, Iterable, Text
|
||||
from wsgiref.types import WSGIEnvironment, InputStream
|
||||
from _typeshed.wsgi import WSGIEnvironment, InputStream
|
||||
|
||||
from .middleware.dispatcher import DispatcherMiddleware as DispatcherMiddleware
|
||||
from .middleware.http_proxy import ProxyMiddleware as ProxyMiddleware
|
||||
|
||||
Reference in New Issue
Block a user