diff --git a/django-stubs/db/migrations/operations/models.pyi b/django-stubs/db/migrations/operations/models.pyi index 31f42e2..f0282a4 100644 --- a/django-stubs/db/migrations/operations/models.pyi +++ b/django-stubs/db/migrations/operations/models.pyi @@ -1,18 +1,15 @@ from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union -from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.migrations.operations.base import Operation -from django.db.migrations.state import ProjectState -from django.db.models.fields import Field from django.db.models.indexes import Index from django.db.models.manager import Manager +from django.db.models.fields import Field + class ModelOperation(Operation): - name: Any = ... + name: str = ... def __init__(self, name: str) -> None: ... def name_lower(self) -> str: ... - def references_model(self, name: str, app_label: Optional[str] = ...) -> bool: ... - def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ... class CreateModel(ModelOperation): serialization_expand_args: Any = ... @@ -28,27 +25,9 @@ class CreateModel(ModelOperation): bases: Optional[Union[Tuple[Type[Any], ...], Tuple[str, ...]]] = ..., managers: Optional[List[Tuple[str, Manager]]] = ..., ) -> None: ... - def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[Dict[str, str], List[Tuple[str, Field]], str]]]: ... - def state_forwards(self, app_label: str, state: ProjectState) -> None: ... - def database_forwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def database_backwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def describe(self) -> str: ... def model_to_key(self, model: str) -> List[str]: ... -class DeleteModel(ModelOperation): - def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ... - def state_forwards(self, app_label: str, state: ProjectState) -> None: ... - def database_forwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def database_backwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def describe(self) -> str: ... +class DeleteModel(ModelOperation): ... class RenameModel(ModelOperation): old_name: Any = ... @@ -56,81 +35,37 @@ class RenameModel(ModelOperation): def __init__(self, old_name: str, new_name: str) -> None: ... def old_name_lower(self) -> str: ... def new_name_lower(self) -> str: ... - def deconstruct(self): ... - def state_forwards(self, app_label: str, state: ProjectState) -> None: ... - def database_forwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def database_backwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def describe(self): ... class AlterModelTable(ModelOperation): - table: Any = ... + table: Optional[str] = ... def __init__(self, name: str, table: Optional[str]) -> None: ... - def deconstruct(self): ... - def state_forwards(self, app_label: Any, state: Any) -> None: ... - def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any): ... - def describe(self): ... class ModelOptionOperation(ModelOperation): ... - -class FieldRelatedOptionOperation(ModelOptionOperation): - def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ... +class FieldRelatedOptionOperation(ModelOptionOperation): ... class AlterUniqueTogether(FieldRelatedOptionOperation): option_name: str = ... unique_together: Any = ... def __init__(self, name: str, unique_together: Set[Tuple[str, ...]]) -> None: ... - def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[Set[Tuple[str, str]], str]]]: ... - def state_forwards(self, app_label: str, state: ProjectState) -> None: ... - def database_forwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def database_backwards( - self, app_label: str, schema_editor: BaseDatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState - ) -> None: ... - def describe(self) -> str: ... class AlterIndexTogether(FieldRelatedOptionOperation): option_name: str = ... - index_together: Any = ... - def __init__(self, name: str, index_together: Set[Tuple[str, str]]) -> None: ... - def state_forwards(self, app_label: Any, state: Any) -> None: ... - def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any): ... - def describe(self): ... + index_together: Set[Tuple[str, ...]] = ... + def __init__(self, name: str, index_together: Set[Tuple[str, ...]]) -> None: ... class AlterOrderWithRespectTo(FieldRelatedOptionOperation): order_with_respect_to: str = ... def __init__(self, name: str, order_with_respect_to: str) -> None: ... - def deconstruct(self): ... - def state_forwards(self, app_label: Any, state: Any) -> None: ... - def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def describe(self): ... class AlterModelOptions(ModelOptionOperation): ALTER_OPTION_KEYS: Any = ... - options: Any = ... + options: Dict[str, str] = ... def __init__(self, name: str, options: Dict[str, str]) -> None: ... - def deconstruct(self): ... - def state_forwards(self, app_label: Any, state: Any) -> None: ... - def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def describe(self): ... class AlterModelManagers(ModelOptionOperation): serialization_expand_args: Any = ... managers: Any = ... def __init__(self, name: Any, managers: Any) -> None: ... - def deconstruct(self): ... - def state_forwards(self, app_label: Any, state: Any) -> None: ... - def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def describe(self): ... class IndexOperation(Operation): option_name: str = ... @@ -140,18 +75,8 @@ class AddIndex(IndexOperation): model_name: str = ... index: Index = ... def __init__(self, model_name: str, index: Index) -> None: ... - def state_forwards(self, app_label: Any, state: Any) -> None: ... - def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def deconstruct(self): ... - def describe(self): ... class RemoveIndex(IndexOperation): model_name: str = ... name: str = ... def __init__(self, model_name: str, name: str) -> None: ... - def state_forwards(self, app_label: Any, state: Any) -> None: ... - def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ... - def deconstruct(self): ... - def describe(self): ... diff --git a/django-stubs/db/models/__init__.pyi b/django-stubs/db/models/__init__.pyi index 99509c2..9ea6a3c 100644 --- a/django-stubs/db/models/__init__.pyi +++ b/django-stubs/db/models/__init__.pyi @@ -15,6 +15,7 @@ from .fields import ( SlugField as SlugField, TextField as TextField, BooleanField as BooleanField, + NullBooleanField as NullBooleanField, FileField as FileField, DateField as DateField, DateTimeField as DateTimeField, diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 469ea40..0058c31 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -36,6 +36,10 @@ class BooleanField(Field): def __set__(self, instance, value: bool) -> None: ... def __get__(self, instance, owner) -> bool: ... +class NullBooleanField(BooleanField): + def __set__(self, instance, value: Optional[bool]) -> None: ... + def __get__(self, instance, owner) -> Optional[bool]: ... + class FileField(Field): ... class IPAddressField(Field): ... diff --git a/django-stubs/views/debug.pyi b/django-stubs/views/debug.pyi new file mode 100644 index 0000000..8307c44 --- /dev/null +++ b/django-stubs/views/debug.pyi @@ -0,0 +1,52 @@ +from typing import Any, Callable, Dict, List, Optional, Type, Union + +from django.core.handlers.wsgi import WSGIRequest +from django.http.request import QueryDict +from django.http.response import Http404, HttpResponse +from django.utils.safestring import SafeText + +DEBUG_ENGINE: Any +HIDDEN_SETTINGS: Any +CLEANSED_SUBSTITUTE: str +CURRENT_DIR: Any + +class CallableSettingWrapper: + def __init__(self, callable_setting: Union[Callable, Type[Any]]) -> None: ... + +def cleanse_setting(key: Union[int, str], value: Any) -> Any: ... +def get_safe_settings() -> Dict[str, Any]: ... +def technical_500_response(request: Any, exc_type: Any, exc_value: Any, tb: Any, status_code: int = ...): ... +def get_default_exception_reporter_filter() -> SafeExceptionReporterFilter: ... +def get_exception_reporter_filter(request: Optional[WSGIRequest]) -> SafeExceptionReporterFilter: ... + +class ExceptionReporterFilter: + def get_post_parameters(self, request: Any): ... + def get_traceback_frame_variables(self, request: Any, tb_frame: Any): ... + +class SafeExceptionReporterFilter(ExceptionReporterFilter): + def is_active(self, request: Optional[WSGIRequest]) -> bool: ... + def get_cleansed_multivaluedict(self, request: WSGIRequest, multivaluedict: QueryDict) -> QueryDict: ... + def get_post_parameters(self, request: Optional[WSGIRequest]) -> Union[Dict[Any, Any], QueryDict]: ... + def cleanse_special_types(self, request: Optional[WSGIRequest], value: Any) -> Any: ... + def get_traceback_frame_variables(self, request: Any, tb_frame: Any): ... + +class ExceptionReporter: + request: Optional[django.core.handlers.wsgi.WSGIRequest] = ... + filter: django.views.debug.SafeExceptionReporterFilter = ... + exc_type: None = ... + exc_value: Optional[str] = ... + tb: None = ... + is_email: bool = ... + template_info: None = ... + template_does_not_exist: bool = ... + postmortem: None = ... + def __init__( + self, request: Optional[WSGIRequest], exc_type: None, exc_value: Optional[str], tb: None, is_email: bool = ... + ) -> None: ... + def get_traceback_data(self) -> Dict[str, Any]: ... + def get_traceback_html(self) -> SafeText: ... + def get_traceback_text(self) -> SafeText: ... + def get_traceback_frames(self) -> List[Any]: ... + +def technical_404_response(request: WSGIRequest, exception: Http404) -> HttpResponse: ... +def default_urlconf(request: WSGIRequest) -> HttpResponse: ...