Skip to content

Commit ec376e5

Browse files
authored
Add all stubs reported missing by stubtest (#499)
* Add all stubs reported missing by stubtest. I filtered all stubtest reports that have message "is not present in stub" or "failed to find stubs" and fixed them. * Omit migrations
1 parent 843fd91 commit ec376e5

File tree

13 files changed

+53
-36
lines changed

13 files changed

+53
-36
lines changed

rest_framework-stubs/__init__.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
__title__: str
2+
__version__: str
3+
__author__: str
4+
__license__: str
5+
__copyright__: str
6+
17
VERSION: str
28
HTTP_HEADER_ENCODING: str
39
ISO_8601: str
410
default_app_config: str
511

6-
class RemovedInDRF313Warning(DeprecationWarning): ...
7-
class RemovedInDRF314Warning(PendingDeprecationWarning): ...
12+
class RemovedInDRF315Warning(PendingDeprecationWarning): ...
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from django.contrib import admin
2+
from django.contrib.admin.views.main import ChangeList
23

4+
class TokenChangeList(ChangeList): ...
35
class TokenAdmin(admin.ModelAdmin): ...

rest_framework-stubs/authtoken/views.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ from rest_framework.views import APIView, AsView, GenericView
88
class ObtainAuthToken(APIView):
99
serializer_class: type[Serializer]
1010
def post(self, request: Request, *args: Any, **kwargs: Any) -> Response: ...
11+
def get_serializer_context(self) -> dict[str, Any]: ...
12+
def get_serializer(self, *args: Any, **kwargs: Any) -> Serializer: ...
1113

1214
obtain_auth_token: AsView[GenericView]

rest_framework-stubs/renderers.pyi

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import Incomplete
22
from collections.abc import Iterable, Mapping, Sequence
33
from json import JSONEncoder
4-
from typing import Any
4+
from typing import Any, ClassVar
55

66
from django import forms
77
from rest_framework.request import Request
@@ -22,10 +22,10 @@ class BaseRenderer:
2222
) -> Any: ...
2323

2424
class JSONRenderer(BaseRenderer):
25-
encoder_class: type[JSONEncoder]
26-
ensure_ascii: bool
27-
compact: bool
28-
strict: bool
25+
encoder_class: ClassVar[type[JSONEncoder]]
26+
ensure_ascii: ClassVar[bool]
27+
compact: ClassVar[bool]
28+
strict: ClassVar[bool]
2929
def get_indent(self, accepted_media_type: str, renderer_context: Mapping[str, Any]) -> int | None: ...
3030

3131
class TemplateHTMLRenderer(BaseRenderer):
@@ -109,7 +109,12 @@ class _BaseOpenAPIRenderer:
109109
def get_paths(self, document: Incomplete) -> dict[str, Any]: ...
110110
def get_structure(self, data: Any) -> dict[str, Any]: ...
111111

112-
class JSONOpenAPIRenderer(_BaseOpenAPIRenderer): ...
112+
class JSONOpenAPIRenderer(_BaseOpenAPIRenderer):
113+
encoder_class: ClassVar[type[JSONEncoder]]
114+
ensure_ascii: ClassVar[bool]
115+
113116
class OpenAPIRenderer(_BaseOpenAPIRenderer): ...
114117
class CoreAPIOpenAPIRenderer(_BaseOpenAPIRenderer): ...
115-
class CoreAPIJSONOpenAPIRenderer(_BaseOpenAPIRenderer): ...
118+
119+
class CoreAPIJSONOpenAPIRenderer(_BaseOpenAPIRenderer):
120+
ensure_ascii: ClassVar[bool]

rest_framework-stubs/schemas/generators.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import Incomplete
12
from collections.abc import Iterable, Sequence
23
from types import ModuleType
34
from typing import Any
@@ -12,6 +13,7 @@ from typing_extensions import TypeAlias
1213
def common_path(paths: Iterable[str]) -> str: ...
1314
def get_pk_name(model: type[Model]) -> str: ...
1415
def is_api_view(callback: Any) -> bool: ...
16+
def endpoint_ordering(endpoint: tuple[Incomplete, Incomplete, Incomplete]) -> tuple[int]: ...
1517

1618
_APIEndpoint: TypeAlias = tuple[str, str, Any]
1719

rest_framework-stubs/schemas/openapi.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class AutoSchema(ViewInspector):
6363
def map_parsers(self, path: str, method: str) -> list[str]: ...
6464
def map_renderers(self, path: str, method: str) -> list[str]: ...
6565
def get_serializer(self, path: str, method: str) -> BaseSerializer | None: ...
66+
def get_request_serializer(self, path: str, method: str) -> BaseSerializer | None: ...
67+
def get_response_serializer(self, path: str, method: str) -> BaseSerializer | None: ...
68+
def get_reference(self, serializer: BaseSerializer) -> dict[str, str]: ...
6669
def get_request_body(self, path: str, method: str) -> dict[str, Any]: ...
6770
def get_responses(self, path: str, method: str) -> dict[str, Any]: ...
6871
def get_tags(self, path: str, method: str) -> list[str]: ...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
from typing import Any
2+
3+
from rest_framework.request import Request
4+
from rest_framework.response import Response
15
from rest_framework.schemas import SchemaGenerator
26
from rest_framework.views import APIView
37

48
class SchemaView(APIView):
59
_ignore_model_permissions: bool
610
public: bool
711
schema_generator: SchemaGenerator | None
12+
13+
def get(self, request: Request, *args: Any, **kwargs: Any) -> Response: ...

rest_framework-stubs/status.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ def is_server_error(code: int) -> bool: ...
88

99
HTTP_100_CONTINUE: Literal[100]
1010
HTTP_101_SWITCHING_PROTOCOLS: Literal[101]
11+
HTTP_102_PROCESSING: Literal[102]
12+
HTTP_103_EARLY_HINTS: Literal[103]
1113
HTTP_200_OK: Literal[200]
1214
HTTP_201_CREATED: Literal[201]
1315
HTTP_202_ACCEPTED: Literal[202]
@@ -46,9 +48,11 @@ HTTP_415_UNSUPPORTED_MEDIA_TYPE: Literal[415]
4648
HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE: Literal[416]
4749
HTTP_417_EXPECTATION_FAILED: Literal[417]
4850
HTTP_418_IM_A_TEAPOT: Literal[418]
51+
HTTP_421_MISDIRECTED_REQUEST: Literal[421]
4952
HTTP_422_UNPROCESSABLE_ENTITY: Literal[422]
5053
HTTP_423_LOCKED: Literal[423]
5154
HTTP_424_FAILED_DEPENDENCY: Literal[424]
55+
HTTP_425_TOO_EARLY: Literal[425]
5256
HTTP_426_UPGRADE_REQUIRED: Literal[426]
5357
HTTP_428_PRECONDITION_REQUIRED: Literal[428]
5458
HTTP_429_TOO_MANY_REQUESTS: Literal[429]

rest_framework-stubs/test.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ class APILiveServerTestCase(testcases.LiveServerTestCase):
103103
client_class: type[APIClient]
104104
client: APIClient
105105

106+
def cleanup_url_patterns(cls: type[URLPatternsTestCase]) -> None: ...
107+
106108
class URLPatternsTestCase(testcases.SimpleTestCase): ...

rest_framework-stubs/utils/field_mapping.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ def get_field_kwargs(field_name: str, model_field: models.Field) -> dict[str, An
2121
def get_relation_kwargs(field_name: str, relation_info: Incomplete) -> dict[str, Any]: ...
2222
def get_nested_relation_kwargs(relation_info: Incomplete) -> dict[str, Any]: ...
2323
def get_url_kwargs(model_field: models.Model) -> dict[str, Any]: ...
24+
def get_unique_error_message(model_field: models.Field) -> str: ...

0 commit comments

Comments
 (0)