Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions django-stubs/test/client.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from collections.abc import Awaitable, Callable, Iterable, Iterator
from collections.abc import Awaitable, Callable, Iterable, Iterator, Mapping
from io import BytesIO
from json import JSONEncoder
from re import Pattern
from types import TracebackType
from typing import Any, Generic, NoReturn, TypeVar
from typing import Any, Generic, NoReturn, TypeAlias, TypeVar

from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.sessions.backends.base import SessionBase
Expand Down Expand Up @@ -58,14 +58,18 @@ class AsyncClientHandler(BaseHandler):
def encode_multipart(boundary: str, data: dict[str, Any]) -> bytes: ...
def encode_file(boundary: str, key: str, file: Any) -> list[bytes]: ...

_GetDataType: TypeAlias = (
Mapping[str, str | bytes | Iterable[str | bytes]] | Iterable[tuple[str, str | bytes | Iterable[str | bytes]]] | None
)

class _RequestFactory(Generic[_T]):
json_encoder: type[JSONEncoder]
defaults: dict[str, str]
cookies: SimpleCookie
errors: BytesIO
def __init__(self, *, json_encoder: type[JSONEncoder] = ..., **defaults: Any) -> None: ...
def request(self, **request: Any) -> _T: ...
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> _T: ...
def get(self, path: str, data: _GetDataType = ..., secure: bool = ..., **extra: Any) -> _T: ...
def post(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ...
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> _T: ...
def trace(self, path: str, secure: bool = ..., **extra: Any) -> _T: ...
Expand Down Expand Up @@ -129,7 +133,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
# Silence type warnings, since this class overrides arguments and return types in an unsafe manner.
def request(self, **request: Any) -> _MonkeyPatchedWSGIResponse: ...
def get( # type: ignore
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
self, path: str, data: _GetDataType = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> _MonkeyPatchedWSGIResponse: ...
def post( # type: ignore
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
Expand Down
10 changes: 7 additions & 3 deletions django-stubs/utils/http.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import Iterable
from collections.abc import Iterable, Mapping
from re import Pattern
from typing import Any

ETAG_MATCH: Pattern[str]
MONTHS: list[str]
Expand All @@ -14,7 +13,12 @@ def urlquote(url: str, safe: str = ...) -> str: ...
def urlquote_plus(url: str, safe: str = ...) -> str: ...
def urlunquote(quoted_url: str) -> str: ...
def urlunquote_plus(quoted_url: str) -> str: ...
def urlencode(query: Any, doseq: bool = ...) -> str: ...
def urlencode(
query: Mapping[str, str | bytes | Iterable[str | bytes]]
| Iterable[tuple[str, str | bytes | Iterable[str | bytes]]]
| None,
doseq: bool = ...,
) -> str: ...
def http_date(epoch_seconds: float | None = ...) -> str: ...
def parse_http_date(date: str) -> int: ...
def parse_http_date_safe(date: str) -> int | None: ...
Expand Down