Skip to content

Commit 977c0e5

Browse files
[5.2] Fix new errors in django.http module (#2632)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a616717 commit 977c0e5

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

django-stubs/http/request.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime
2-
from collections.abc import Awaitable, Callable, Iterable, Mapping
2+
from collections.abc import Awaitable, Callable, Iterable, Mapping, Sequence
33
from io import BytesIO
44
from re import Pattern
55
from typing import Any, BinaryIO, Literal, NoReturn, TypeAlias, TypeVar, overload, type_check_only
@@ -93,7 +93,8 @@ class HttpRequest(BytesIO):
9393
def upload_handlers(self, upload_handlers: _UploadHandlerList) -> None: ...
9494
@cached_property
9595
def accepted_types(self) -> list[MediaType]: ...
96-
def accepted_type(self) -> MediaType | None: ...
96+
def accepted_type(self, media_type: str) -> MediaType | None: ...
97+
def get_preferred_type(self, media_types: Sequence[str]) -> str | None: ...
9798
def parse_file_upload(
9899
self, META: Mapping[str, Any], post_data: BinaryIO
99100
) -> tuple[QueryDict, MultiValueDict[str, uploadedfile.UploadedFile]]: ...

django-stubs/http/response.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from collections.abc import AsyncIterable, AsyncIterator, Iterable, Iterator
33
from http.cookies import SimpleCookie
44
from io import BytesIO
55
from json import JSONEncoder
6-
from typing import Any, Literal, TypeVar, overload, type_check_only
6+
from typing import Any, Literal, NoReturn, TypeVar, overload, type_check_only
77

88
from django.utils.datastructures import CaseInsensitiveMapping, _PropertyDescriptor
99
from django.utils.functional import cached_property
@@ -117,6 +117,8 @@ class StreamingHttpResponse(HttpResponseBase, Iterable[bytes], AsyncIterable[byt
117117
def __iter__(self) -> Iterator[bytes]: ...
118118
def __aiter__(self) -> AsyncIterator[bytes]: ...
119119
def getvalue(self) -> bytes: ...
120+
@property
121+
def text(self) -> NoReturn: ...
120122

121123
class FileResponse(StreamingHttpResponse):
122124
file_to_stream: BytesIO | None

scripts/stubtest/allowlist_todo_django52.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,8 @@ django.forms.boundfield.BoundField.aria_describedby
166166
django.forms.forms.BaseForm.bound_field_class
167167
django.forms.models.ModelChoiceField.validate_no_null_characters
168168
django.forms.renderers.BaseRenderer.bound_field_class
169-
django.http.HttpRequest.accepted_type
170-
django.http.HttpRequest.get_preferred_type
171169
django.http.QueryDict.pop
172-
django.http.StreamingHttpResponse.text
173-
django.http.request.HttpRequest.accepted_type
174-
django.http.request.HttpRequest.get_preferred_type
175170
django.http.request.QueryDict.pop
176-
django.http.response.StreamingHttpResponse.text
177171
django.template.Library.simple_block_tag
178172
django.template.autoreload
179173
django.template.library.Library.simple_block_tag

0 commit comments

Comments
 (0)