Skip to content

Use Mapping instead of dict for test Client headers, add missing RequestFactory parameter #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Changes from all commits
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
40 changes: 21 additions & 19 deletions django-stubs/test/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ class _RequestFactory(Generic[_T]):
defaults: dict[str, str]
cookies: SimpleCookie
errors: BytesIO
def __init__(self, *, json_encoder: type[JSONEncoder] = ..., **defaults: Any) -> None: ...
def __init__(
self, *, json_encoder: type[JSONEncoder] = ..., headers: Mapping[str, Any] | None = ..., **defaults: Any
) -> None: ...
def request(self, **request: Any) -> _T: ...
def get(
self,
path: str,
data: _GetDataType = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _T: ...
def post(
Expand All @@ -88,21 +90,21 @@ class _RequestFactory(Generic[_T]):
content_type: str = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _T: ...
def head(
self, path: str, data: Any = ..., secure: bool = ..., *, headers: dict[str, Any] | None = ..., **extra: Any
self, path: str, data: Any = ..., secure: bool = ..., *, headers: Mapping[str, Any] | None = ..., **extra: Any
) -> _T: ...
def trace(self, path: str, secure: bool = ..., *, headers: dict[str, Any] | None = ..., **extra: Any) -> _T: ...
def trace(self, path: str, secure: bool = ..., *, headers: Mapping[str, Any] | None = ..., **extra: Any) -> _T: ...
def options(
self,
path: str,
data: dict[str, str] | str = ...,
content_type: str = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _T: ...
def put(
Expand All @@ -112,7 +114,7 @@ class _RequestFactory(Generic[_T]):
content_type: str = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _T: ...
def patch(
Expand All @@ -122,7 +124,7 @@ class _RequestFactory(Generic[_T]):
content_type: str = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _T: ...
def delete(
Expand All @@ -132,7 +134,7 @@ class _RequestFactory(Generic[_T]):
content_type: str = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _T: ...
def generic(
Expand All @@ -143,7 +145,7 @@ class _RequestFactory(Generic[_T]):
content_type: str | None = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _T: ...

Expand Down Expand Up @@ -192,7 +194,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
enforce_csrf_checks: bool = ...,
raise_request_exception: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**defaults: Any
) -> None: ...
def request(self, **request: Any) -> _MonkeyPatchedWSGIResponse: ...
Expand All @@ -203,7 +205,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
follow: bool = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _MonkeyPatchedWSGIResponse: ...
def post( # type: ignore
Expand All @@ -214,7 +216,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
follow: bool = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _MonkeyPatchedWSGIResponse: ...
def head( # type: ignore
Expand All @@ -224,7 +226,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
follow: bool = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _MonkeyPatchedWSGIResponse: ...
def trace( # type: ignore
Expand All @@ -234,7 +236,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
follow: bool = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _MonkeyPatchedWSGIResponse: ...
def put( # type: ignore
Expand All @@ -245,7 +247,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
follow: bool = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _MonkeyPatchedWSGIResponse: ...
def patch( # type: ignore
Expand All @@ -256,7 +258,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
follow: bool = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _MonkeyPatchedWSGIResponse: ...
def delete( # type: ignore
Expand All @@ -267,7 +269,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
follow: bool = ...,
secure: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**extra: Any
) -> _MonkeyPatchedWSGIResponse: ...

Expand All @@ -282,7 +284,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
enforce_csrf_checks: bool = ...,
raise_request_exception: bool = ...,
*,
headers: dict[str, Any] | None = ...,
headers: Mapping[str, Any] | None = ...,
**defaults: Any
) -> None: ...
async def request(self, **request: Any) -> _MonkeyPatchedASGIResponse: ...