Skip to content
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

Add all stubs reported missing by stubtest #499

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions rest_framework-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
__title__: str
__version__: str
__author__: str
__license__: str
__copyright__: str

VERSION: str
HTTP_HEADER_ENCODING: str
ISO_8601: str
default_app_config: str

class RemovedInDRF313Warning(DeprecationWarning): ...
class RemovedInDRF314Warning(PendingDeprecationWarning): ...
class RemovedInDRF315Warning(PendingDeprecationWarning): ...
2 changes: 2 additions & 0 deletions rest_framework-stubs/authtoken/admin.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.contrib import admin
from django.contrib.admin.views.main import ChangeList

class TokenChangeList(ChangeList): ...
class TokenAdmin(admin.ModelAdmin): ...
2 changes: 2 additions & 0 deletions rest_framework-stubs/authtoken/views.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ from rest_framework.views import APIView, AsView, GenericView
class ObtainAuthToken(APIView):
serializer_class: type[Serializer]
def post(self, request: Request, *args: Any, **kwargs: Any) -> Response: ...
def get_serializer_context(self) -> dict[str, Any]: ...
def get_serializer(self, *args: Any, **kwargs: Any) -> Serializer: ...

obtain_auth_token: AsView[GenericView]
19 changes: 12 additions & 7 deletions rest_framework-stubs/renderers.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Mapping, Sequence
from json import JSONEncoder
from typing import Any
from typing import Any, ClassVar

from django import forms
from rest_framework.request import Request
Expand All @@ -22,10 +22,10 @@ class BaseRenderer:
) -> Any: ...

class JSONRenderer(BaseRenderer):
encoder_class: type[JSONEncoder]
ensure_ascii: bool
compact: bool
strict: bool
encoder_class: ClassVar[type[JSONEncoder]]
ensure_ascii: ClassVar[bool]
compact: ClassVar[bool]
strict: ClassVar[bool]
def get_indent(self, accepted_media_type: str, renderer_context: Mapping[str, Any]) -> int | None: ...

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

class JSONOpenAPIRenderer(_BaseOpenAPIRenderer): ...
class JSONOpenAPIRenderer(_BaseOpenAPIRenderer):
encoder_class: ClassVar[type[JSONEncoder]]
ensure_ascii: ClassVar[bool]

class OpenAPIRenderer(_BaseOpenAPIRenderer): ...
class CoreAPIOpenAPIRenderer(_BaseOpenAPIRenderer): ...
class CoreAPIJSONOpenAPIRenderer(_BaseOpenAPIRenderer): ...

class CoreAPIJSONOpenAPIRenderer(_BaseOpenAPIRenderer):
ensure_ascii: ClassVar[bool]
2 changes: 2 additions & 0 deletions rest_framework-stubs/schemas/generators.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Sequence
from types import ModuleType
from typing import Any
Expand All @@ -12,6 +13,7 @@ from typing_extensions import TypeAlias
def common_path(paths: Iterable[str]) -> str: ...
def get_pk_name(model: type[Model]) -> str: ...
def is_api_view(callback: Any) -> bool: ...
def endpoint_ordering(endpoint: tuple[Incomplete, Incomplete, Incomplete]) -> tuple[int]: ...

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

Expand Down
3 changes: 3 additions & 0 deletions rest_framework-stubs/schemas/openapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class AutoSchema(ViewInspector):
def map_parsers(self, path: str, method: str) -> list[str]: ...
def map_renderers(self, path: str, method: str) -> list[str]: ...
def get_serializer(self, path: str, method: str) -> BaseSerializer | None: ...
def get_request_serializer(self, path: str, method: str) -> BaseSerializer | None: ...
def get_response_serializer(self, path: str, method: str) -> BaseSerializer | None: ...
def get_reference(self, serializer: BaseSerializer) -> dict[str, str]: ...
def get_request_body(self, path: str, method: str) -> dict[str, Any]: ...
def get_responses(self, path: str, method: str) -> dict[str, Any]: ...
def get_tags(self, path: str, method: str) -> list[str]: ...
6 changes: 6 additions & 0 deletions rest_framework-stubs/schemas/views.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from typing import Any

from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.schemas import SchemaGenerator
from rest_framework.views import APIView

class SchemaView(APIView):
_ignore_model_permissions: bool
public: bool
schema_generator: SchemaGenerator | None

def get(self, request: Request, *args: Any, **kwargs: Any) -> Response: ...
4 changes: 4 additions & 0 deletions rest_framework-stubs/status.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def is_server_error(code: int) -> bool: ...

HTTP_100_CONTINUE: Literal[100]
HTTP_101_SWITCHING_PROTOCOLS: Literal[101]
HTTP_102_PROCESSING: Literal[102]
HTTP_103_EARLY_HINTS: Literal[103]
HTTP_200_OK: Literal[200]
HTTP_201_CREATED: Literal[201]
HTTP_202_ACCEPTED: Literal[202]
Expand Down Expand Up @@ -46,9 +48,11 @@ HTTP_415_UNSUPPORTED_MEDIA_TYPE: Literal[415]
HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE: Literal[416]
HTTP_417_EXPECTATION_FAILED: Literal[417]
HTTP_418_IM_A_TEAPOT: Literal[418]
HTTP_421_MISDIRECTED_REQUEST: Literal[421]
HTTP_422_UNPROCESSABLE_ENTITY: Literal[422]
HTTP_423_LOCKED: Literal[423]
HTTP_424_FAILED_DEPENDENCY: Literal[424]
HTTP_425_TOO_EARLY: Literal[425]
HTTP_426_UPGRADE_REQUIRED: Literal[426]
HTTP_428_PRECONDITION_REQUIRED: Literal[428]
HTTP_429_TOO_MANY_REQUESTS: Literal[429]
Expand Down
2 changes: 2 additions & 0 deletions rest_framework-stubs/test.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@ class APILiveServerTestCase(testcases.LiveServerTestCase):
client_class: type[APIClient]
client: APIClient

def cleanup_url_patterns(cls: type[URLPatternsTestCase]) -> None: ...

class URLPatternsTestCase(testcases.SimpleTestCase): ...
1 change: 1 addition & 0 deletions rest_framework-stubs/utils/field_mapping.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ def get_field_kwargs(field_name: str, model_field: models.Field) -> dict[str, An
def get_relation_kwargs(field_name: str, relation_info: Incomplete) -> dict[str, Any]: ...
def get_nested_relation_kwargs(relation_info: Incomplete) -> dict[str, Any]: ...
def get_url_kwargs(model_field: models.Model) -> dict[str, Any]: ...
def get_unique_error_message(model_field: models.Field) -> str: ...
2 changes: 2 additions & 0 deletions rest_framework-stubs/utils/formatting.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _typeshed import Incomplete
from typing import Any

def remove_trailing_string(content: str, trailing: str) -> str: ...
Expand All @@ -11,3 +12,4 @@ class lazy_format:
args: Any
kwargs: Any
def __init__(self, format_string: str, *args: Any, **kwargs: Any) -> None: ...
def __mod__(self, value: Incomplete) -> str: ...
10 changes: 10 additions & 0 deletions scripts/stubtest/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ rest_framework.serializers.HyperlinkedIdentityField.__init__
rest_framework.serializers.HyperlinkedRelatedField.__init__
rest_framework.serializers.ManyRelatedField.__init__
rest_framework.serializers.SlugRelatedField.__init__

# Deprecated and non-functional
rest_framework.request.Request.DATA
rest_framework.request.Request.QUERY_PARAMS

# Migrations are omitted
rest_framework.authtoken.migrations
rest_framework.authtoken.migrations.0001_initial
rest_framework.authtoken.migrations.0002_auto_20160226_1747
rest_framework.authtoken.migrations.0003_tokenproxy
27 changes: 0 additions & 27 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
# Autogenerated by `stubtest`
# Unsorted: there are real problems and things we can really ignore.

rest_framework.RemovedInDRF313Warning
rest_framework.RemovedInDRF314Warning
rest_framework.RemovedInDRF315Warning
rest_framework.__license__
rest_framework.__title__
rest_framework.authtoken.admin.TokenAdmin
rest_framework.authtoken.admin.TokenChangeList
rest_framework.authtoken.default_app_config
rest_framework.authtoken.management.commands.drf_create_token.UserModel
rest_framework.authtoken.migrations
rest_framework.authtoken.migrations.0001_initial
rest_framework.authtoken.migrations.0002_auto_20160226_1747
rest_framework.authtoken.migrations.0003_tokenproxy
rest_framework.authtoken.models.Token.created
rest_framework.authtoken.models.Token.get_next_by_created
rest_framework.authtoken.models.Token.get_previous_by_created
Expand All @@ -24,8 +14,6 @@ rest_framework.authtoken.models.TokenProxy.get_next_by_created
rest_framework.authtoken.models.TokenProxy.get_previous_by_created
rest_framework.authtoken.models.TokenProxy.pk
rest_framework.authtoken.models.TokenProxy.user_id
rest_framework.authtoken.views.ObtainAuthToken.get_serializer
rest_framework.authtoken.views.ObtainAuthToken.get_serializer_context
rest_framework.authtoken.views.ObtainAuthToken.serializer_class
rest_framework.authtoken.views.obtain_auth_token
rest_framework.compat.CodeBlockPreprocessor
Expand Down Expand Up @@ -75,10 +63,7 @@ rest_framework.relations.SlugRelatedField.to_representation
rest_framework.renderers.BaseRenderer.format
rest_framework.renderers.BaseRenderer.media_type
rest_framework.renderers.BrowsableAPIRenderer.get_extra_actions
rest_framework.renderers.CoreAPIJSONOpenAPIRenderer.ensure_ascii
rest_framework.renderers.CoreJSONRenderer.render
rest_framework.renderers.JSONOpenAPIRenderer.encoder_class
rest_framework.renderers.JSONOpenAPIRenderer.ensure_ascii
rest_framework.renderers._BaseOpenAPIRenderer.__init__
rest_framework.renderers._BaseOpenAPIRenderer.render
rest_framework.request.Request.DATA
Expand All @@ -94,18 +79,13 @@ rest_framework.routers.SimpleRouter
rest_framework.schemas.SchemaGenerator.__init__
rest_framework.schemas.coreapi.SchemaGenerator.__init__
rest_framework.schemas.generators.common_path
rest_framework.schemas.generators.endpoint_ordering
rest_framework.schemas.get_schema_view
rest_framework.schemas.openapi.AutoSchema.__init__
rest_framework.schemas.openapi.AutoSchema.get_reference
rest_framework.schemas.openapi.AutoSchema.get_request_serializer
rest_framework.schemas.openapi.AutoSchema.get_response_serializer
rest_framework.schemas.openapi.DRFOpenAPIInfo
rest_framework.schemas.openapi.DRFOpenAPISchema
rest_framework.schemas.openapi.ExternalDocumentationObject
rest_framework.schemas.openapi.SchemaGenerator.get_schema
rest_framework.schemas.views.SchemaView.__init__
rest_framework.schemas.views.SchemaView.get
rest_framework.schemas.views.SchemaView.renderer_classes
rest_framework.serializers.APIException
rest_framework.serializers.AuthenticationFailed
Expand Down Expand Up @@ -146,10 +126,6 @@ rest_framework.serializers.UnsupportedMediaType
rest_framework.serializers.empty
rest_framework.settings.DefaultsSettings
rest_framework.settings.api_settings
rest_framework.status.HTTP_102_PROCESSING
rest_framework.status.HTTP_103_EARLY_HINTS
rest_framework.status.HTTP_421_MISDIRECTED_REQUEST
rest_framework.status.HTTP_425_TOO_EARLY
rest_framework.templatetags.rest_framework.urlize_quoted_links
rest_framework.test.APIClient.options
rest_framework.test.APIRequestFactory.delete
Expand All @@ -159,11 +135,8 @@ rest_framework.test.APIRequestFactory.patch
rest_framework.test.APIRequestFactory.post
rest_framework.test.APIRequestFactory.put
rest_framework.test.RequestsClient.__init__
rest_framework.test.cleanup_url_patterns
rest_framework.throttling.SimpleRateThrottle.cache
rest_framework.utils.encoders.JSONEncoder.default
rest_framework.utils.field_mapping.get_unique_error_message
rest_framework.utils.formatting.lazy_format.__mod__
rest_framework.utils.json.dump
rest_framework.utils.json.dumps
rest_framework.utils.json.load
Expand Down