From bb701d6615198dd55353fcefcf717268674fc70a Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Thu, 4 Oct 2018 03:49:25 +0300 Subject: [PATCH] cleanup core.handlers.wsgi --- django-stubs/core/handlers/wsgi.pyi | 74 ++++++++++++++++------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/django-stubs/core/handlers/wsgi.pyi b/django-stubs/core/handlers/wsgi.pyi index 9ebc0f4..43d9e80 100644 --- a/django-stubs/core/handlers/wsgi.pyi +++ b/django-stubs/core/handlers/wsgi.pyi @@ -1,79 +1,85 @@ from io import BytesIO -from typing import Any, Callable, Dict, Optional, Tuple, Union +from typing import Any, Callable, Dict, Optional, Union +from django.contrib.auth.models import AbstractUser +from django.contrib.sessions.backends.base import SessionBase from django.core.handlers import base from django.http import HttpRequest from django.http.request import QueryDict from django.http.response import HttpResponse -from django.test.client import FakePayload from django.utils.datastructures import MultiValueDict +_Stream = Union[BytesIO, str] + + class LimitedStream: - stream: django.test.client.FakePayload = ... + stream: _Stream = ... remaining: int = ... buffer: bytes = ... buf_size: int = ... + def __init__( - self, - stream: Union[BytesIO, FakePayload, str], - limit: int, - buf_size: int = ..., + self, + stream: _Stream, + limit: int, + buf_size: int = ..., ) -> None: ... + def read(self, size: Optional[int] = ...) -> bytes: ... + def readline(self, size: Optional[int] = ...) -> bytes: ... + class WSGIRequest(HttpRequest): content_params: Dict[str, str] content_type: str - environ: Dict[ - str, - Union[ - Tuple[int, int], - _io.BytesIO, - django.test.client.FakePayload, - int, - str, - ], - ] = ... + environ: Dict[str, Any] = ... path_info: str = ... path: str = ... - META: Dict[ - str, - Union[ - Tuple[int, int], - _io.BytesIO, - django.test.client.FakePayload, - int, - str, - ], - ] = ... + user: AbstractUser + session: SessionBase + + META: Dict[str, Any] = ... method: str = ... encoding: Any = ... resolver_match: None = ... + def __init__(self, environ: Dict[str, Any]) -> None: ... + def GET(self) -> QueryDict: ... + def COOKIES(self) -> Dict[str, str]: ... + @property def FILES(self) -> MultiValueDict: ... + POST: Any = ... + class WSGIHandler(base.BaseHandler): request_class: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def __call__( - self, - environ: Dict[ - str, Union[Tuple[int, int], BytesIO, FakePayload, int, str] - ], - start_response: Callable, + self, + environ: Dict[str, Any], + start_response: Callable, ) -> HttpResponse: ... + def get_path_info(environ: Dict[str, Any]) -> str: ... + + def get_script_name(environ: Dict[str, Any]) -> str: ... + + def get_bytes_from_wsgi( - environ: Dict[str, Any], key: str, default: str + environ: Dict[str, Any], key: str, default: str ) -> bytes: ... + + def get_str_from_wsgi( - environ: Dict[str, Any], key: str, default: str + environ: Dict[str, Any], key: str, default: str ) -> str: ...