mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-08 13:04:47 +08:00
enable some test folders, bunch of fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Iterator, Type, Optional
|
from typing import Any, Iterator, Type, Optional, Dict
|
||||||
|
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ class AppConfig:
|
|||||||
verbose_name: str = ...
|
verbose_name: str = ...
|
||||||
path: str = ...
|
path: str = ...
|
||||||
models_module: None = ...
|
models_module: None = ...
|
||||||
models: None = ...
|
models: Optional[Dict[str, Type[Model]]] = ...
|
||||||
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
|
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, entry: str) -> AppConfig: ...
|
def create(cls, entry: str) -> AppConfig: ...
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Apps:
|
|||||||
stored_app_configs: List[Any] = ...
|
stored_app_configs: List[Any] = ...
|
||||||
apps_ready: bool = ...
|
apps_ready: bool = ...
|
||||||
loading: bool = ...
|
loading: bool = ...
|
||||||
_pending_operations: DefaultDict[str, List]
|
_pending_operations: DefaultDict[Tuple[str, str], List]
|
||||||
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
|
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
|
||||||
models_ready: bool = ...
|
models_ready: bool = ...
|
||||||
ready: bool = ...
|
ready: bool = ...
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union, Iterator
|
||||||
|
|
||||||
|
from django.contrib.admin.filters import ListFilter
|
||||||
from django.contrib.admin.models import LogEntry
|
from django.contrib.admin.models import LogEntry
|
||||||
from django.contrib.admin.sites import AdminSite
|
from django.contrib.admin.sites import AdminSite
|
||||||
from django.contrib.admin.views.main import ChangeList
|
from django.contrib.admin.views.main import ChangeList
|
||||||
@@ -68,16 +69,11 @@ class BaseModelAdmin:
|
|||||||
def get_autocomplete_fields(self, request: WSGIRequest) -> Tuple: ...
|
def get_autocomplete_fields(self, request: WSGIRequest) -> Tuple: ...
|
||||||
def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ...
|
def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ...
|
||||||
def get_empty_value_display(self) -> SafeText: ...
|
def get_empty_value_display(self) -> SafeText: ...
|
||||||
def get_exclude(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
|
def get_exclude(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Any: ...
|
||||||
def get_fields(
|
def get_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Sequence[Union[Callable, str]]: ...
|
||||||
self, request: WSGIRequest, obj: Optional[Model] = ...
|
|
||||||
) -> Union[List[Union[Callable, str]], Tuple[str, str]]: ...
|
|
||||||
def get_fieldsets(
|
def get_fieldsets(
|
||||||
self, request: WSGIRequest, obj: Optional[Model] = ...
|
self, request: WSGIRequest, obj: Optional[Model] = ...
|
||||||
) -> Union[
|
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
|
||||||
List[Tuple[None, Dict[str, List[Union[Callable, str]]]]],
|
|
||||||
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
|
|
||||||
]: ...
|
|
||||||
def get_ordering(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
|
def get_ordering(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
|
||||||
def get_readonly_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Union[List[str], Tuple]: ...
|
def get_readonly_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Union[List[str], Tuple]: ...
|
||||||
def get_prepopulated_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
|
def get_prepopulated_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
|
||||||
@@ -93,21 +89,21 @@ class BaseModelAdmin:
|
|||||||
|
|
||||||
class ModelAdmin(BaseModelAdmin):
|
class ModelAdmin(BaseModelAdmin):
|
||||||
formfield_overrides: Any
|
formfield_overrides: Any
|
||||||
list_display: Sequence[str] = ...
|
list_display: Sequence[Union[str, Callable]] = ...
|
||||||
list_display_links: Sequence[str] = ...
|
list_display_links: Sequence[Union[str, Callable]] = ...
|
||||||
list_filter: Sequence[str] = ...
|
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
|
||||||
list_select_related: Sequence[str] = ...
|
list_select_related: Union[bool, Sequence[str]] = ...
|
||||||
list_per_page: int = ...
|
list_per_page: int = ...
|
||||||
list_max_show_all: int = ...
|
list_max_show_all: int = ...
|
||||||
list_editable: Sequence[str] = ...
|
list_editable: Sequence[str] = ...
|
||||||
search_fields: Any = ...
|
search_fields: Sequence[str] = ...
|
||||||
date_hierarchy: Any = ...
|
date_hierarchy: Optional[Any] = ...
|
||||||
save_as: bool = ...
|
save_as: bool = ...
|
||||||
save_as_continue: bool = ...
|
save_as_continue: bool = ...
|
||||||
save_on_top: bool = ...
|
save_on_top: bool = ...
|
||||||
paginator: Any = ...
|
paginator: Any = ...
|
||||||
preserve_filters: bool = ...
|
preserve_filters: bool = ...
|
||||||
inlines: Any = ...
|
inlines: Sequence[Type[InlineModelAdmin]] = ...
|
||||||
add_form_template: Any = ...
|
add_form_template: Any = ...
|
||||||
change_form_template: Any = ...
|
change_form_template: Any = ...
|
||||||
change_list_template: Any = ...
|
change_list_template: Any = ...
|
||||||
@@ -138,7 +134,7 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
def get_object(self, request: WSGIRequest, object_id: str, from_field: None = ...) -> Optional[Model]: ...
|
def get_object(self, request: WSGIRequest, object_id: str, from_field: None = ...) -> Optional[Model]: ...
|
||||||
def get_changelist_form(self, request: Any, **kwargs: Any): ...
|
def get_changelist_form(self, request: Any, **kwargs: Any): ...
|
||||||
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
|
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
|
||||||
def get_formsets_with_inlines(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
|
def get_formsets_with_inlines(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Iterator[Any]: ...
|
||||||
def get_paginator(
|
def get_paginator(
|
||||||
self,
|
self,
|
||||||
request: WSGIRequest,
|
request: WSGIRequest,
|
||||||
@@ -147,18 +143,8 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
orphans: int = ...,
|
orphans: int = ...,
|
||||||
allow_empty_first_page: bool = ...,
|
allow_empty_first_page: bool = ...,
|
||||||
) -> Paginator: ...
|
) -> Paginator: ...
|
||||||
def log_addition(
|
def log_addition(self, request: WSGIRequest, object: Model, message: Any) -> LogEntry: ...
|
||||||
self,
|
def log_change(self, request: WSGIRequest, object: Model, message: Any) -> LogEntry: ...
|
||||||
request: WSGIRequest,
|
|
||||||
object: Model,
|
|
||||||
message: Union[Dict[str, Dict[Any, Any]], List[Dict[str, Dict[str, str]]]],
|
|
||||||
) -> LogEntry: ...
|
|
||||||
def log_change(
|
|
||||||
self,
|
|
||||||
request: WSGIRequest,
|
|
||||||
object: Model,
|
|
||||||
message: Union[Dict[str, Dict[str, List[str]]], List[Dict[str, Dict[str, Union[List[str], str]]]]],
|
|
||||||
) -> LogEntry: ...
|
|
||||||
def log_deletion(self, request: WSGIRequest, object: Model, object_repr: str) -> LogEntry: ...
|
def log_deletion(self, request: WSGIRequest, object: Model, object_repr: str) -> LogEntry: ...
|
||||||
def action_checkbox(self, obj: Model) -> SafeText: ...
|
def action_checkbox(self, obj: Model) -> SafeText: ...
|
||||||
def get_actions(self, request: WSGIRequest) -> OrderedDict: ...
|
def get_actions(self, request: WSGIRequest) -> OrderedDict: ...
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ def result_list(
|
|||||||
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
|
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
|
||||||
]: ...
|
]: ...
|
||||||
def result_list_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
|
def result_list_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
|
||||||
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Union[Dict[str, str], List[Dict[str, str]], bool]]]: ...
|
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Any]]: ...
|
||||||
def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
|
def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
|
||||||
def search_form(cl: ChangeList) -> Dict[str, Union[bool, ChangeList, str]]: ...
|
def search_form(cl: ChangeList) -> Dict[str, Union[bool, ChangeList, str]]: ...
|
||||||
def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
|
def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import collections
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from django.contrib.admin.options import BaseModelAdmin
|
from django.contrib.admin.options import BaseModelAdmin
|
||||||
@@ -8,28 +9,23 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
|
|||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.deletion import Collector
|
from django.db.models.deletion import Collector
|
||||||
from django.db.models.fields import Field
|
|
||||||
from django.db.models.fields.mixins import FieldCacheMixin
|
from django.db.models.fields.mixins import FieldCacheMixin
|
||||||
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel, OneToOneRel
|
from django.db.models.fields.reverse_related import ManyToOneRel
|
||||||
from django.db.models.options import Options
|
from django.db.models.options import Options
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
|
from django.forms.forms import BaseForm
|
||||||
from django.utils.safestring import SafeText
|
from django.utils.safestring import SafeText
|
||||||
|
|
||||||
|
from django.db.models.fields import Field, reverse_related
|
||||||
|
|
||||||
class FieldIsAForeignKeyColumnName(Exception): ...
|
class FieldIsAForeignKeyColumnName(Exception): ...
|
||||||
|
|
||||||
def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ...
|
def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ...
|
||||||
def prepare_lookup_value(key: str, value: Union[datetime, str]) -> Union[bool, datetime, str]: ...
|
def prepare_lookup_value(key: str, value: Union[datetime, str]) -> Union[bool, datetime, str]: ...
|
||||||
def quote(s: Union[int, str, UUID]) -> Union[int, str, UUID]: ...
|
def quote(s: Union[int, str, UUID]) -> str: ...
|
||||||
def unquote(s: str) -> str: ...
|
def unquote(s: str) -> str: ...
|
||||||
def flatten(
|
def flatten(fields: Any) -> List[Union[Callable, str]]: ...
|
||||||
fields: Union[List[Union[Callable, str]], List[Union[List[str], str]], List[Union[Tuple[str, str], str]], Tuple]
|
def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ...
|
||||||
) -> List[Union[Callable, str]]: ...
|
|
||||||
def flatten_fieldsets(
|
|
||||||
fieldsets: Union[
|
|
||||||
List[Tuple[Optional[str], Dict[str, Tuple[str]]]],
|
|
||||||
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
|
|
||||||
]
|
|
||||||
) -> List[Union[Callable, str]]: ...
|
|
||||||
def get_deleted_objects(
|
def get_deleted_objects(
|
||||||
objs: QuerySet, request: WSGIRequest, admin_site: AdminSite
|
objs: QuerySet, request: WSGIRequest, admin_site: AdminSite
|
||||||
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
|
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
|
||||||
@@ -47,7 +43,7 @@ class NestedObjects(Collector):
|
|||||||
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
|
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
|
||||||
def collect(
|
def collect(
|
||||||
self,
|
self,
|
||||||
objs: Union[List[Model], QuerySet],
|
objs: Union[Sequence[Model], QuerySet],
|
||||||
source: Optional[Type[Model]] = ...,
|
source: Optional[Type[Model]] = ...,
|
||||||
source_attr: Optional[str] = ...,
|
source_attr: Optional[str] = ...,
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
@@ -62,7 +58,11 @@ def lookup_field(
|
|||||||
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
|
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
|
||||||
) -> Tuple[Optional[Field], Callable, Callable]: ...
|
) -> Tuple[Optional[Field], Callable, Callable]: ...
|
||||||
def label_for_field(
|
def label_for_field(
|
||||||
name: Union[Callable, str], model: Type[Model], model_admin: Optional[BaseModelAdmin] = ..., return_attr: bool = ...
|
name: Union[Callable, str],
|
||||||
|
model: Type[Model],
|
||||||
|
model_admin: Optional[BaseModelAdmin] = ...,
|
||||||
|
return_attr: bool = ...,
|
||||||
|
form: Optional[BaseForm] = ...,
|
||||||
) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ...
|
) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ...
|
||||||
def help_text_for_field(name: str, model: Type[Model]) -> str: ...
|
def help_text_for_field(name: str, model: Type[Model]) -> str: ...
|
||||||
def display_for_field(
|
def display_for_field(
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class GenericForeignKey(FieldCacheMixin):
|
|||||||
|
|
||||||
class GenericRel(ForeignObjectRel):
|
class GenericRel(ForeignObjectRel):
|
||||||
field: GenericRelation
|
field: GenericRelation
|
||||||
limit_choices_to: Dict[Any, Any]
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]]
|
||||||
model: Type[Model]
|
model: Type[Model]
|
||||||
multiple: bool
|
multiple: bool
|
||||||
on_delete: Callable
|
on_delete: Callable
|
||||||
@@ -65,7 +65,7 @@ class GenericRel(ForeignObjectRel):
|
|||||||
to: Union[Type[Model], str],
|
to: Union[Type[Model], str],
|
||||||
related_name: None = ...,
|
related_name: None = ...,
|
||||||
related_query_name: Optional[str] = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: None = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
class GenericRelation(ForeignObject):
|
class GenericRelation(ForeignObject):
|
||||||
@@ -87,7 +87,7 @@ class GenericRelation(ForeignObject):
|
|||||||
content_type_field: str = ...,
|
content_type_field: str = ...,
|
||||||
for_concrete_model: bool = ...,
|
for_concrete_model: bool = ...,
|
||||||
related_query_name: Optional[str] = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: None = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, List, Optional, Tuple, Union, TypeVar, Generic, Sequence
|
from typing import Any, Generic, List, Optional, Sequence, TypeVar
|
||||||
|
|
||||||
from django.db.models.fields import Field
|
from django.db.models.fields import Field
|
||||||
from .mixins import CheckFieldDefaultMixin
|
from .mixins import CheckFieldDefaultMixin
|
||||||
@@ -12,7 +12,7 @@ class ArrayField(CheckFieldDefaultMixin, Field, Generic[_T]):
|
|||||||
size: Any = ...
|
size: Any = ...
|
||||||
default_validators: Any = ...
|
default_validators: Any = ...
|
||||||
from_db_value: Any = ...
|
from_db_value: Any = ...
|
||||||
def __init__(self, base_field: _T, size: None = ..., **kwargs: Any) -> None: ...
|
def __init__(self, base_field: _T, size: Optional[int] = ..., **kwargs: Any) -> None: ...
|
||||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||||
@property
|
@property
|
||||||
def description(self): ...
|
def description(self): ...
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ def get_public_serializer_formats() -> List[str]: ...
|
|||||||
def get_deserializer(format: str) -> Union[Callable, Type[Deserializer]]: ...
|
def get_deserializer(format: str) -> Union[Callable, Type[Deserializer]]: ...
|
||||||
def serialize(
|
def serialize(
|
||||||
format: str, queryset: Union[Iterator[Any], List[Model], QuerySet], **options: Any
|
format: str, queryset: Union[Iterator[Any], List[Model], QuerySet], **options: Any
|
||||||
) -> Optional[Union[List[OrderedDict], bytes, str]]: ...
|
) -> Optional[Union[bytes, str]]: ...
|
||||||
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ...
|
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ...
|
||||||
def sort_dependencies(
|
def sort_dependencies(
|
||||||
app_list: Union[List[Tuple[AppConfig, None]], List[Tuple[str, List[Type[Model]]]]]
|
app_list: Union[List[Tuple[AppConfig, None]], List[Tuple[str, List[Type[Model]]]]]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class DummyNode(Node):
|
|||||||
parents: Set[Any]
|
parents: Set[Any]
|
||||||
origin: Any = ...
|
origin: Any = ...
|
||||||
error_message: Any = ...
|
error_message: Any = ...
|
||||||
def __init__(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
|
def __init__(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ...
|
||||||
__class__: Any = ...
|
__class__: Any = ...
|
||||||
def promote(self) -> None: ...
|
def promote(self) -> None: ...
|
||||||
def raise_error(self) -> None: ...
|
def raise_error(self) -> None: ...
|
||||||
@@ -35,7 +35,7 @@ class MigrationGraph:
|
|||||||
cached: bool = ...
|
cached: bool = ...
|
||||||
def __init__(self) -> None: ...
|
def __init__(self) -> None: ...
|
||||||
def add_node(self, key: Tuple[str, str], migration: Optional[Migration]) -> None: ...
|
def add_node(self, key: Tuple[str, str], migration: Optional[Migration]) -> None: ...
|
||||||
def add_dummy_node(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
|
def add_dummy_node(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ...
|
||||||
def add_dependency(
|
def add_dependency(
|
||||||
self,
|
self,
|
||||||
migration: Optional[Union[Migration, str]],
|
migration: Optional[Union[Migration, str]],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
|
from typing import Any, Collection, Dict, List, Optional, Sequence, Tuple, Union
|
||||||
|
|
||||||
from django.db.migrations.operations.base import Operation
|
from django.db.migrations.operations.base import Operation
|
||||||
from django.db.models.indexes import Index
|
from django.db.models.indexes import Index
|
||||||
@@ -13,17 +13,17 @@ class ModelOperation(Operation):
|
|||||||
|
|
||||||
class CreateModel(ModelOperation):
|
class CreateModel(ModelOperation):
|
||||||
serialization_expand_args: Any = ...
|
serialization_expand_args: Any = ...
|
||||||
fields: Any = ...
|
fields: Sequence[Tuple[str, Field]] = ...
|
||||||
options: Any = ...
|
options: Any = ...
|
||||||
bases: Any = ...
|
bases: Optional[Sequence[Union[type, str]]] = ...
|
||||||
managers: Any = ...
|
managers: Optional[Sequence[Tuple[str, Manager]]] = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
fields: List[Tuple[str, Field]],
|
fields: Sequence[Tuple[str, Field]],
|
||||||
options: Optional[Dict[str, Any]] = ...,
|
options: Optional[Dict[str, Any]] = ...,
|
||||||
bases: Optional[Union[Tuple[Type[Any], ...], Tuple[str, ...]]] = ...,
|
bases: Optional[Sequence[Union[type, str]]] = ...,
|
||||||
managers: Optional[List[Tuple[str, Manager]]] = ...,
|
managers: Optional[Sequence[Tuple[str, Manager]]] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def model_to_key(self, model: str) -> List[str]: ...
|
def model_to_key(self, model: str) -> List[str]: ...
|
||||||
|
|
||||||
@@ -45,13 +45,13 @@ class FieldRelatedOptionOperation(ModelOptionOperation): ...
|
|||||||
|
|
||||||
class AlterUniqueTogether(FieldRelatedOptionOperation):
|
class AlterUniqueTogether(FieldRelatedOptionOperation):
|
||||||
option_name: str = ...
|
option_name: str = ...
|
||||||
unique_together: Any = ...
|
unique_together: Collection[Sequence[str]] = ...
|
||||||
def __init__(self, name: str, unique_together: Set[Tuple[str, ...]]) -> None: ...
|
def __init__(self, name: str, unique_together: Collection[Sequence[str]]) -> None: ...
|
||||||
|
|
||||||
class AlterIndexTogether(FieldRelatedOptionOperation):
|
class AlterIndexTogether(FieldRelatedOptionOperation):
|
||||||
option_name: str = ...
|
option_name: str = ...
|
||||||
index_together: Set[Tuple[str, ...]] = ...
|
index_together: Collection[Sequence[str]] = ...
|
||||||
def __init__(self, name: str, index_together: Set[Tuple[str, ...]]) -> None: ...
|
def __init__(self, name: str, index_together: Collection[Sequence[str]]) -> None: ...
|
||||||
|
|
||||||
class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
|
class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
|
||||||
order_with_respect_to: str = ...
|
order_with_respect_to: str = ...
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
from typing import Any, Callable, List, Optional
|
from typing import Any, Callable, Optional, Sequence, Dict
|
||||||
|
|
||||||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||||
from django.db.migrations.operations.models import CreateModel
|
from django.db.migrations.state import StateApps
|
||||||
from django.db.migrations.state import ProjectState, StateApps
|
|
||||||
|
|
||||||
from .base import Operation
|
from .base import Operation
|
||||||
|
|
||||||
class SeparateDatabaseAndState(Operation):
|
class SeparateDatabaseAndState(Operation):
|
||||||
serialization_expand_args: Any = ...
|
serialization_expand_args: Any = ...
|
||||||
database_operations: Any = ...
|
database_operations: Sequence[Operation] = ...
|
||||||
state_operations: Any = ...
|
state_operations: Sequence[Operation] = ...
|
||||||
def __init__(self, database_operations: List[Any] = ..., state_operations: List[CreateModel] = ...) -> None: ...
|
def __init__(
|
||||||
|
self, database_operations: Sequence[Operation] = ..., state_operations: Sequence[Operation] = ...
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class RunSQL(Operation):
|
class RunSQL(Operation):
|
||||||
noop: str = ...
|
noop: str = ...
|
||||||
@@ -30,17 +31,17 @@ class RunSQL(Operation):
|
|||||||
|
|
||||||
class RunPython(Operation):
|
class RunPython(Operation):
|
||||||
reduces_to_sql: bool = ...
|
reduces_to_sql: bool = ...
|
||||||
atomic: Any = ...
|
atomic: bool = ...
|
||||||
code: Any = ...
|
code: Callable = ...
|
||||||
reverse_code: Any = ...
|
reverse_code: Optional[Callable] = ...
|
||||||
hints: Any = ...
|
hints: Optional[Dict[str, Any]] = ...
|
||||||
elidable: Any = ...
|
elidable: bool = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
code: Callable,
|
code: Callable,
|
||||||
reverse_code: Optional[Callable] = ...,
|
reverse_code: Optional[Callable] = ...,
|
||||||
atomic: Optional[bool] = ...,
|
atomic: Optional[bool] = ...,
|
||||||
hints: None = ...,
|
hints: Optional[Dict[str, Any]] = ...,
|
||||||
elidable: bool = ...,
|
elidable: bool = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, DefaultDict
|
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, DefaultDict, Union, Sequence
|
||||||
|
|
||||||
from django.apps.registry import Apps
|
from django.apps.registry import Apps
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
@@ -31,7 +31,7 @@ class ModelState:
|
|||||||
name: str,
|
name: str,
|
||||||
fields: List[Tuple[str, Field]],
|
fields: List[Tuple[str, Field]],
|
||||||
options: Optional[Dict[str, Any]] = ...,
|
options: Optional[Dict[str, Any]] = ...,
|
||||||
bases: Optional[Tuple[Type[Model]]] = ...,
|
bases: Optional[Sequence[Union[Type[Model], str]]] = ...,
|
||||||
managers: Optional[List[Tuple[str, Manager]]] = ...,
|
managers: Optional[List[Tuple[str, Manager]]] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def clone(self) -> ModelState: ...
|
def clone(self) -> ModelState: ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional, Set, Tuple, Type, List
|
from typing import Any, Optional, Set, Tuple, Type, List, Union
|
||||||
|
|
||||||
from django.db.migrations.migration import Migration
|
from django.db.migrations.migration import Migration
|
||||||
from django.db.migrations.operations.base import Operation
|
from django.db.migrations.operations.base import Operation
|
||||||
@@ -24,7 +24,7 @@ class OperationWriter:
|
|||||||
class MigrationWriter:
|
class MigrationWriter:
|
||||||
migration: Migration = ...
|
migration: Migration = ...
|
||||||
needs_manual_porting: bool = ...
|
needs_manual_porting: bool = ...
|
||||||
def __init__(self, migration: Migration) -> None: ...
|
def __init__(self, migration: Union[type, Migration]) -> None: ...
|
||||||
def as_string(self) -> str: ...
|
def as_string(self) -> str: ...
|
||||||
@property
|
@property
|
||||||
def basedir(self) -> str: ...
|
def basedir(self) -> str: ...
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ from .fields import (
|
|||||||
BinaryField as BinaryField,
|
BinaryField as BinaryField,
|
||||||
DurationField as DurationField,
|
DurationField as DurationField,
|
||||||
BigAutoField as BigAutoField,
|
BigAutoField as BigAutoField,
|
||||||
FileField as FileField,
|
|
||||||
CommaSeparatedIntegerField as CommaSeparatedIntegerField,
|
CommaSeparatedIntegerField as CommaSeparatedIntegerField,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,7 +52,12 @@ from .fields.related import (
|
|||||||
OneToOneRel as OneToOneRel,
|
OneToOneRel as OneToOneRel,
|
||||||
ForeignObjectRel as ForeignObjectRel,
|
ForeignObjectRel as ForeignObjectRel,
|
||||||
)
|
)
|
||||||
from .fields.files import ImageField as ImageField, FileField as FileField
|
from .fields.files import (
|
||||||
|
ImageField as ImageField,
|
||||||
|
FileField as FileField,
|
||||||
|
FieldFile as FieldFile,
|
||||||
|
FileDescriptor as FileDescriptor,
|
||||||
|
)
|
||||||
from .fields.proxy import OrderWrt as OrderWrt
|
from .fields.proxy import OrderWrt as OrderWrt
|
||||||
|
|
||||||
from .deletion import (
|
from .deletion import (
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ def PROTECT(collector, field, sub_objs, using): ...
|
|||||||
def SET(value: Any) -> Callable: ...
|
def SET(value: Any) -> Callable: ...
|
||||||
|
|
||||||
class ProtectedError(IntegrityError): ...
|
class ProtectedError(IntegrityError): ...
|
||||||
|
class Collector: ...
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import uuid
|
||||||
|
from datetime import date, time, datetime, timedelta
|
||||||
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type
|
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type
|
||||||
import decimal
|
import decimal
|
||||||
|
|
||||||
from django.core.files.storage import Storage
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
from django.db.models.query_utils import RegisterLookupMixin
|
from django.db.models.query_utils import RegisterLookupMixin
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
|
|||||||
from django.forms import Widget, Field as FormField
|
from django.forms import Widget, Field as FormField
|
||||||
from .mixins import NOT_PROVIDED as NOT_PROVIDED
|
from .mixins import NOT_PROVIDED as NOT_PROVIDED
|
||||||
|
|
||||||
_Choice = Tuple[Any, str]
|
_Choice = Tuple[Any, Any]
|
||||||
_ChoiceNamedGroup = Union[Tuple[str, Iterable[_Choice]], Tuple[str, Any]]
|
_ChoiceNamedGroup = Union[Tuple[str, Iterable[_Choice]], Tuple[str, Any]]
|
||||||
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ class Field(RegisterLookupMixin):
|
|||||||
def get_internal_type(self) -> str: ...
|
def get_internal_type(self) -> str: ...
|
||||||
def formfield(self, **kwargs) -> FormField: ...
|
def formfield(self, **kwargs) -> FormField: ...
|
||||||
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
|
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
|
||||||
|
def to_python(self, value: Any) -> Any: ...
|
||||||
|
|
||||||
class IntegerField(Field):
|
class IntegerField(Field):
|
||||||
def __set__(self, instance, value: Union[int, F]) -> None: ...
|
def __set__(self, instance, value: Union[int, F]) -> None: ...
|
||||||
@@ -70,7 +72,9 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
|
|||||||
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
|
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
|
||||||
class SmallIntegerField(IntegerField): ...
|
class SmallIntegerField(IntegerField): ...
|
||||||
class BigIntegerField(IntegerField): ...
|
class BigIntegerField(IntegerField): ...
|
||||||
class FloatField(Field): ...
|
|
||||||
|
class FloatField(Field):
|
||||||
|
def __get__(self, instance, owner) -> float: ...
|
||||||
|
|
||||||
class DecimalField(Field):
|
class DecimalField(Field):
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -170,35 +174,8 @@ class NullBooleanField(Field):
|
|||||||
def __set__(self, instance, value: Optional[bool]) -> None: ...
|
def __set__(self, instance, value: Optional[bool]) -> None: ...
|
||||||
def __get__(self, instance, owner) -> Optional[bool]: ...
|
def __get__(self, instance, owner) -> Optional[bool]: ...
|
||||||
|
|
||||||
class FileField(Field):
|
class IPAddressField(Field):
|
||||||
def __init__(
|
def __get__(self, instance, owner) -> str: ...
|
||||||
self,
|
|
||||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
|
||||||
name: Optional[str] = ...,
|
|
||||||
upload_to: str = ...,
|
|
||||||
storage: Optional[Storage] = ...,
|
|
||||||
primary_key: bool = ...,
|
|
||||||
max_length: Optional[int] = ...,
|
|
||||||
unique: bool = ...,
|
|
||||||
blank: bool = ...,
|
|
||||||
null: bool = ...,
|
|
||||||
db_index: bool = ...,
|
|
||||||
default: Any = ...,
|
|
||||||
editable: bool = ...,
|
|
||||||
auto_created: bool = ...,
|
|
||||||
serialize: bool = ...,
|
|
||||||
unique_for_date: Optional[str] = ...,
|
|
||||||
unique_for_month: Optional[str] = ...,
|
|
||||||
unique_for_year: Optional[str] = ...,
|
|
||||||
choices: Optional[_FieldChoices] = ...,
|
|
||||||
help_text: str = ...,
|
|
||||||
db_column: Optional[str] = ...,
|
|
||||||
db_tablespace: Optional[str] = ...,
|
|
||||||
validators: Iterable[_ValidatorCallable] = ...,
|
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
|
||||||
): ...
|
|
||||||
|
|
||||||
class IPAddressField(Field): ...
|
|
||||||
|
|
||||||
class GenericIPAddressField(Field):
|
class GenericIPAddressField(Field):
|
||||||
default_error_messages: Any = ...
|
default_error_messages: Any = ...
|
||||||
@@ -226,6 +203,7 @@ class GenericIPAddressField(Field):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
def __get__(self, instance, owner) -> str: ...
|
||||||
|
|
||||||
class DateTimeCheckMixin: ...
|
class DateTimeCheckMixin: ...
|
||||||
|
|
||||||
@@ -253,6 +231,7 @@ class DateField(DateTimeCheckMixin, Field):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
): ...
|
): ...
|
||||||
|
def __get__(self, instance, owner) -> date: ...
|
||||||
|
|
||||||
class TimeField(DateTimeCheckMixin, Field):
|
class TimeField(DateTimeCheckMixin, Field):
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -277,9 +256,13 @@ class TimeField(DateTimeCheckMixin, Field):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
): ...
|
): ...
|
||||||
|
def __get__(self, instance, owner) -> time: ...
|
||||||
|
|
||||||
class DateTimeField(DateField): ...
|
class DateTimeField(DateField):
|
||||||
class UUIDField(Field): ...
|
def __get__(self, instance, owner) -> datetime: ...
|
||||||
|
|
||||||
|
class UUIDField(Field):
|
||||||
|
def __get__(self, instance, owner) -> uuid.UUID: ...
|
||||||
|
|
||||||
class FilePathField(Field):
|
class FilePathField(Field):
|
||||||
path: str = ...
|
path: str = ...
|
||||||
@@ -315,6 +298,9 @@ class FilePathField(Field):
|
|||||||
): ...
|
): ...
|
||||||
|
|
||||||
class BinaryField(Field): ...
|
class BinaryField(Field): ...
|
||||||
class DurationField(Field): ...
|
|
||||||
|
class DurationField(Field):
|
||||||
|
def __get__(self, instance, owner) -> timedelta: ...
|
||||||
|
|
||||||
class BigAutoField(AutoField): ...
|
class BigAutoField(AutoField): ...
|
||||||
class CommaSeparatedIntegerField(CharField): ...
|
class CommaSeparatedIntegerField(CharField): ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Callable, List, Optional, Type, Union, Tuple
|
from typing import Any, Callable, List, Optional, Type, Union, Tuple, Iterable
|
||||||
|
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import Error
|
||||||
from django.core.files.base import File
|
from django.core.files.base import File
|
||||||
@@ -6,7 +6,7 @@ from django.core.files.images import ImageFile
|
|||||||
from django.core.files.storage import FileSystemStorage, Storage
|
from django.core.files.storage import FileSystemStorage, Storage
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
|
||||||
from django.db.models.fields import Field
|
from django.db.models.fields import Field, _FieldChoices, _ValidatorCallable, _ErrorMessagesToOverride
|
||||||
from django.forms import fields as form_fields
|
from django.forms import fields as form_fields
|
||||||
|
|
||||||
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
|
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
|
||||||
@@ -31,31 +31,39 @@ class FieldFile(File):
|
|||||||
class FileDescriptor:
|
class FileDescriptor:
|
||||||
field: FileField = ...
|
field: FileField = ...
|
||||||
def __init__(self, field: FileField) -> None: ...
|
def __init__(self, field: FileField) -> None: ...
|
||||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
|
|
||||||
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
|
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
|
||||||
|
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
|
||||||
|
|
||||||
class FileField(Field):
|
class FileField(Field):
|
||||||
attr_class: Any = ...
|
|
||||||
descriptor_class: Any = ...
|
|
||||||
description: Any = ...
|
|
||||||
storage: Any = ...
|
storage: Any = ...
|
||||||
upload_to: Any = ...
|
upload_to: Union[str, Callable] = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
verbose_name: Optional[str] = ...,
|
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||||
name: Optional[str] = ...,
|
name: Optional[str] = ...,
|
||||||
upload_to: Union[Callable, str] = ...,
|
upload_to: Union[str, Callable] = ...,
|
||||||
storage: Optional[Storage] = ...,
|
storage: Optional[Storage] = ...,
|
||||||
**kwargs: Any
|
primary_key: bool = ...,
|
||||||
) -> None: ...
|
max_length: Optional[int] = ...,
|
||||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
unique: bool = ...,
|
||||||
def deconstruct(self) -> Any: ...
|
blank: bool = ...,
|
||||||
def get_internal_type(self) -> str: ...
|
null: bool = ...,
|
||||||
def get_prep_value(self, value: Union[FieldFile, str]) -> str: ...
|
db_index: bool = ...,
|
||||||
def pre_save(self, model_instance: Model, add: bool) -> FieldFile: ...
|
default: Any = ...,
|
||||||
|
editable: bool = ...,
|
||||||
|
auto_created: bool = ...,
|
||||||
|
serialize: bool = ...,
|
||||||
|
unique_for_date: Optional[str] = ...,
|
||||||
|
unique_for_month: Optional[str] = ...,
|
||||||
|
unique_for_year: Optional[str] = ...,
|
||||||
|
choices: Optional[_FieldChoices] = ...,
|
||||||
|
help_text: str = ...,
|
||||||
|
db_column: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
|
): ...
|
||||||
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
|
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
|
||||||
def save_form_data(self, instance: Model, data: Optional[Union[bool, File, str]]) -> None: ...
|
|
||||||
def formfield(self, **kwargs: Any) -> form_fields.FileField: ...
|
|
||||||
|
|
||||||
class ImageFileDescriptor(FileDescriptor):
|
class ImageFileDescriptor(FileDescriptor):
|
||||||
field: ImageField
|
field: ImageField
|
||||||
@@ -74,7 +82,4 @@ class ImageField(FileField):
|
|||||||
height_field: Optional[str] = ...,
|
height_field: Optional[str] = ...,
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
|
||||||
def deconstruct(self) -> Any: ...
|
|
||||||
def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ...
|
def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||||
def formfield(self, **kwargs: Any) -> form_fields.ImageField: ...
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class ForeignObject(RelatedField):
|
|||||||
rel: None = ...,
|
rel: None = ...,
|
||||||
related_name: Optional[str] = ...,
|
related_name: Optional[str] = ...,
|
||||||
related_query_name: None = ...,
|
related_query_name: None = ...,
|
||||||
limit_choices_to: None = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
parent_link: bool = ...,
|
parent_link: bool = ...,
|
||||||
swappable: bool = ...,
|
swappable: bool = ...,
|
||||||
verbose_name: Optional[str] = ...,
|
verbose_name: Optional[str] = ...,
|
||||||
@@ -126,7 +126,7 @@ class ManyToManyField(RelatedField, Generic[_T]):
|
|||||||
to: Union[Type[_T], str],
|
to: Union[Type[_T], str],
|
||||||
related_name: Optional[str] = ...,
|
related_name: Optional[str] = ...,
|
||||||
related_query_name: Optional[str] = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: Optional[Dict[str, Any]] = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
symmetrical: Optional[bool] = ...,
|
symmetrical: Optional[bool] = ...,
|
||||||
through: Optional[Union[str, Type[Model]]] = ...,
|
through: Optional[Union[str, Type[Model]]] = ...,
|
||||||
through_fields: Optional[Tuple[str, str]] = ...,
|
through_fields: Optional[Tuple[str, str]] = ...,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class ForeignObjectRel(FieldCacheMixin):
|
|||||||
model: Union[Type[Model], str] = ...
|
model: Union[Type[Model], str] = ...
|
||||||
related_name: Optional[str] = ...
|
related_name: Optional[str] = ...
|
||||||
related_query_name: Optional[str] = ...
|
related_query_name: Optional[str] = ...
|
||||||
limit_choices_to: Union[Callable, Dict[str, Any]] = ...
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...
|
||||||
parent_link: bool = ...
|
parent_link: bool = ...
|
||||||
on_delete: Callable = ...
|
on_delete: Callable = ...
|
||||||
symmetrical: bool = ...
|
symmetrical: bool = ...
|
||||||
@@ -38,7 +38,7 @@ class ForeignObjectRel(FieldCacheMixin):
|
|||||||
to: Union[Type[Model], str],
|
to: Union[Type[Model], str],
|
||||||
related_name: Optional[str] = ...,
|
related_name: Optional[str] = ...,
|
||||||
related_query_name: Optional[str] = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: Any = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
parent_link: bool = ...,
|
parent_link: bool = ...,
|
||||||
on_delete: Optional[Callable] = ...,
|
on_delete: Optional[Callable] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
@@ -86,7 +86,7 @@ class ManyToOneRel(ForeignObjectRel):
|
|||||||
field_name: Optional[str],
|
field_name: Optional[str],
|
||||||
related_name: Optional[str] = ...,
|
related_name: Optional[str] = ...,
|
||||||
related_query_name: Optional[str] = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: Optional[Union[Callable, Dict[str, Union[int, str]], Q]] = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
parent_link: bool = ...,
|
parent_link: bool = ...,
|
||||||
on_delete: Callable = ...,
|
on_delete: Callable = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|||||||
@@ -14,17 +14,10 @@ class Signal:
|
|||||||
sender_receivers_cache: Any = ...
|
sender_receivers_cache: Any = ...
|
||||||
def __init__(self, providing_args: List[str] = ..., use_caching: bool = ...) -> None: ...
|
def __init__(self, providing_args: List[str] = ..., use_caching: bool = ...) -> None: ...
|
||||||
def connect(
|
def connect(
|
||||||
self,
|
self, receiver: Callable, sender: Optional[object] = ..., weak: bool = ..., dispatch_uid: Optional[str] = ...
|
||||||
receiver: Callable,
|
|
||||||
sender: Optional[Union[Type[Model], AppConfig, str]] = ...,
|
|
||||||
weak: bool = ...,
|
|
||||||
dispatch_uid: Optional[str] = ...,
|
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def disconnect(
|
def disconnect(
|
||||||
self,
|
self, receiver: Optional[Callable] = ..., sender: Optional[object] = ..., dispatch_uid: Optional[str] = ...
|
||||||
receiver: Optional[Callable] = ...,
|
|
||||||
sender: Optional[Union[Type[Model], AppConfig, str]] = ...,
|
|
||||||
dispatch_uid: Optional[str] = ...,
|
|
||||||
) -> bool: ...
|
) -> bool: ...
|
||||||
def has_listeners(self, sender: Any = ...) -> bool: ...
|
def has_listeners(self, sender: Any = ...) -> bool: ...
|
||||||
def send(self, sender: Any, **named: Any) -> List[Tuple[Callable, Optional[str]]]: ...
|
def send(self, sender: Any, **named: Any) -> List[Tuple[Callable, Optional[str]]]: ...
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class ModelChoiceField(ChoiceField):
|
|||||||
iterator: Any = ...
|
iterator: Any = ...
|
||||||
empty_label: Optional[str] = ...
|
empty_label: Optional[str] = ...
|
||||||
queryset: Any = ...
|
queryset: Any = ...
|
||||||
limit_choices_to: None = ...
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...
|
||||||
to_field_name: None = ...
|
to_field_name: None = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -248,7 +248,7 @@ class ModelChoiceField(ChoiceField):
|
|||||||
initial: Optional[Any] = ...,
|
initial: Optional[Any] = ...,
|
||||||
help_text: str = ...,
|
help_text: str = ...,
|
||||||
to_field_name: Optional[Any] = ...,
|
to_field_name: Optional[Any] = ...,
|
||||||
limit_choices_to: Optional[Any] = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def get_limit_choices_to(self) -> Optional[Union[Dict[str, datetime], Q, MagicMock]]: ...
|
def get_limit_choices_to(self) -> Optional[Union[Dict[str, datetime], Q, MagicMock]]: ...
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from collections import UserList
|
from collections import UserList
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, Sequence
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.safestring import SafeText
|
from django.utils.safestring import SafeText
|
||||||
@@ -18,7 +18,9 @@ class ErrorDict(dict):
|
|||||||
class ErrorList(UserList):
|
class ErrorList(UserList):
|
||||||
data: List[Union[ValidationError, str]]
|
data: List[Union[ValidationError, str]]
|
||||||
error_class: str = ...
|
error_class: str = ...
|
||||||
def __init__(self, initlist: Optional[ErrorList] = ..., error_class: Optional[str] = ...) -> None: ...
|
def __init__(
|
||||||
|
self, initlist: Optional[Union[ErrorList, Sequence[str]]] = ..., error_class: Optional[str] = ...
|
||||||
|
) -> None: ...
|
||||||
def as_data(self) -> List[ValidationError]: ...
|
def as_data(self) -> List[ValidationError]: ...
|
||||||
def get_json_data(self, escape_html: bool = ...) -> List[Dict[str, str]]: ...
|
def get_json_data(self, escape_html: bool = ...) -> List[Dict[str, str]]: ...
|
||||||
def as_json(self, escape_html: bool = ...) -> str: ...
|
def as_json(self, escape_html: bool = ...) -> str: ...
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
from typing import Any, Optional, Type, Union
|
from typing import Any, Optional
|
||||||
|
|
||||||
from django.contrib.postgres.validators import KeysValidator
|
def deconstructible(*args: Any, path: Optional[Any] = ...) -> Any: ...
|
||||||
from django.core.validators import RegexValidator
|
|
||||||
|
|
||||||
def deconstructible(*args: Any, path: Optional[Any] = ...) -> Type[Union[KeysValidator, RegexValidator]]: ...
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from mypy.plugin import FunctionContext
|
from mypy.plugin import FunctionContext
|
||||||
from mypy.types import Type
|
from mypy.types import Type, Instance
|
||||||
|
|
||||||
|
|
||||||
def determine_type_of_array_field(ctx: FunctionContext) -> Type:
|
def determine_type_of_array_field(ctx: FunctionContext) -> Type:
|
||||||
@@ -7,5 +7,13 @@ def determine_type_of_array_field(ctx: FunctionContext) -> Type:
|
|||||||
return ctx.default_return_type
|
return ctx.default_return_type
|
||||||
|
|
||||||
base_field_arg_type = ctx.arg_types[ctx.callee_arg_names.index('base_field')][0]
|
base_field_arg_type = ctx.arg_types[ctx.callee_arg_names.index('base_field')][0]
|
||||||
|
if not isinstance(base_field_arg_type, Instance):
|
||||||
|
return ctx.default_return_type
|
||||||
|
|
||||||
|
get_method = base_field_arg_type.type.get_method('__get__')
|
||||||
|
if not get_method:
|
||||||
|
# not a method
|
||||||
|
return ctx.default_return_type
|
||||||
|
|
||||||
return ctx.api.named_generic_type(ctx.context.callee.fullname,
|
return ctx.api.named_generic_type(ctx.context.callee.fullname,
|
||||||
args=[base_field_arg_type.type.names['__get__'].type.ret_type])
|
args=[get_method.type.ret_type])
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ IGNORED_ERRORS = {
|
|||||||
# cookies private attribute
|
# cookies private attribute
|
||||||
'full_clean" of "Model" does not return a value',
|
'full_clean" of "Model" does not return a value',
|
||||||
# private members
|
# private members
|
||||||
re.compile(r'has no attribute "|\'_[a-z][a-z_]+"|\'')
|
re.compile(r'has no attribute "|\'_[a-z][a-z_]+"|\''),
|
||||||
|
'Invalid base class'
|
||||||
],
|
],
|
||||||
'admin_changelist': [
|
'admin_changelist': [
|
||||||
'Incompatible types in assignment (expression has type "FilteredChildAdmin", variable has type "ChildAdmin")'
|
'Incompatible types in assignment (expression has type "FilteredChildAdmin", variable has type "ChildAdmin")'
|
||||||
@@ -60,6 +61,19 @@ IGNORED_ERRORS = {
|
|||||||
'variable has type "AdminRadioSelect")',
|
'variable has type "AdminRadioSelect")',
|
||||||
'Incompatible types in assignment (expression has type "Widget", variable has type "AutocompleteSelect")'
|
'Incompatible types in assignment (expression has type "Widget", variable has type "AutocompleteSelect")'
|
||||||
],
|
],
|
||||||
|
'admin_utils': [
|
||||||
|
re.compile(r'Argument [0-9] to "lookup_field" has incompatible type'),
|
||||||
|
'MockModelAdmin',
|
||||||
|
'Incompatible types in assignment (expression has type "str", variable has type "Callable[..., Any]")',
|
||||||
|
'Dict entry 0 has incompatible type "str": "Tuple[str, str, List[str]]"; expected "str": '
|
||||||
|
+ '"Tuple[str, str, Tuple[str, str]]"',
|
||||||
|
'Incompatible types in assignment (expression has type "bytes", variable has type "str")'
|
||||||
|
],
|
||||||
|
'admin_views': [
|
||||||
|
'Argument 1 to "FileWrapper" has incompatible type "StringIO"; expected "IO[bytes]"',
|
||||||
|
'Incompatible types in assignment',
|
||||||
|
'"object" not callable'
|
||||||
|
],
|
||||||
'aggregation': [
|
'aggregation': [
|
||||||
'Incompatible types in assignment (expression has type "QuerySet[Any]", variable has type "List[Any]")',
|
'Incompatible types in assignment (expression has type "QuerySet[Any]", variable has type "List[Any]")',
|
||||||
'"as_sql" undefined in superclass'
|
'"as_sql" undefined in superclass'
|
||||||
@@ -108,6 +122,9 @@ IGNORED_ERRORS = {
|
|||||||
'defer': [
|
'defer': [
|
||||||
'Too many arguments for "refresh_from_db" of "Model"'
|
'Too many arguments for "refresh_from_db" of "Model"'
|
||||||
],
|
],
|
||||||
|
'dispatch': [
|
||||||
|
'Argument 1 to "connect" of "Signal" has incompatible type "object"; expected "Callable[..., Any]"'
|
||||||
|
],
|
||||||
'db_typecasts': [
|
'db_typecasts': [
|
||||||
'"object" has no attribute "__iter__"; maybe "__str__" or "__dir__"? (not iterable)'
|
'"object" has no attribute "__iter__"; maybe "__str__" or "__dir__"? (not iterable)'
|
||||||
],
|
],
|
||||||
@@ -131,6 +148,10 @@ IGNORED_ERRORS = {
|
|||||||
'httpwrappers': [
|
'httpwrappers': [
|
||||||
'Argument 2 to "appendlist" of "QueryDict" has incompatible type "List[str]"; expected "str"'
|
'Argument 2 to "appendlist" of "QueryDict" has incompatible type "List[str]"; expected "str"'
|
||||||
],
|
],
|
||||||
|
'invalid_models_tests': [
|
||||||
|
'Argument "max_length" to "CharField" has incompatible type "str"; expected "Optional[int]"',
|
||||||
|
'Argument "choices" to "CharField" has incompatible type "str"'
|
||||||
|
],
|
||||||
'model_inheritance_regress': [
|
'model_inheritance_regress': [
|
||||||
'Incompatible types in assignment (expression has type "List[Supplier]", variable has type "QuerySet[Supplier]")'
|
'Incompatible types in assignment (expression has type "List[Supplier]", variable has type "QuerySet[Supplier]")'
|
||||||
],
|
],
|
||||||
@@ -138,12 +159,37 @@ IGNORED_ERRORS = {
|
|||||||
'"object" has no attribute "items"',
|
'"object" has no attribute "items"',
|
||||||
'"Field" has no attribute "many_to_many"'
|
'"Field" has no attribute "many_to_many"'
|
||||||
],
|
],
|
||||||
|
'model_fields': [
|
||||||
|
'Incompatible types in assignment (expression has type "Type[Person]", variable has type',
|
||||||
|
'Unexpected keyword argument "name" for "Person"',
|
||||||
|
'Cannot assign multiple types to name "PersonTwoImages" without an explicit "Type[...]" annotation',
|
||||||
|
],
|
||||||
|
'modeladmin': [
|
||||||
|
'BandAdmin',
|
||||||
|
],
|
||||||
'migrate_signals': [
|
'migrate_signals': [
|
||||||
'Value of type "None" is not indexable',
|
'Value of type "None" is not indexable',
|
||||||
],
|
],
|
||||||
|
'migrations': [
|
||||||
|
'FakeMigration',
|
||||||
|
'Incompatible types in assignment (expression has type "TextField", base class "Model" '
|
||||||
|
+ 'defined the type as "Manager[Model]")',
|
||||||
|
'Incompatible types in assignment (expression has type "DeleteModel", variable has type "RemoveField")',
|
||||||
|
'Argument "bases" to "CreateModel" has incompatible type "Tuple[Type[Mixin], Type[Mixin]]"; '
|
||||||
|
+ 'expected "Optional[Sequence[Union[Type[Model], str]]]"',
|
||||||
|
'Argument 1 to "RunPython" has incompatible type "str"; expected "Callable[..., Any]"',
|
||||||
|
'FakeLoader',
|
||||||
|
],
|
||||||
'queryset_pickle': [
|
'queryset_pickle': [
|
||||||
'"None" has no attribute "somefield"'
|
'"None" has no attribute "somefield"'
|
||||||
],
|
],
|
||||||
|
'postgres_tests': [
|
||||||
|
'Cannot assign multiple types to name',
|
||||||
|
'Incompatible types in assignment (expression has type "Type[Field]',
|
||||||
|
'DummyArrayField',
|
||||||
|
'DummyJSONField',
|
||||||
|
'Argument "encoder" to "JSONField" has incompatible type "DjangoJSONEncoder"; expected "Optional[Type[JSONEncoder]]"'
|
||||||
|
],
|
||||||
'requests': [
|
'requests': [
|
||||||
'Incompatible types in assignment (expression has type "Dict[str, str]", variable has type "QueryDict")'
|
'Incompatible types in assignment (expression has type "Dict[str, str]", variable has type "QueryDict")'
|
||||||
],
|
],
|
||||||
@@ -242,8 +288,8 @@ TESTS_DIRS = [
|
|||||||
'admin_ordering',
|
'admin_ordering',
|
||||||
'admin_registration',
|
'admin_registration',
|
||||||
'admin_scripts',
|
'admin_scripts',
|
||||||
# TODO: 'admin_utils',
|
'admin_utils',
|
||||||
# TODO: 'admin_views',
|
'admin_views',
|
||||||
'admin_widgets',
|
'admin_widgets',
|
||||||
'aggregation',
|
'aggregation',
|
||||||
'aggregation_regress',
|
'aggregation_regress',
|
||||||
@@ -282,7 +328,7 @@ TESTS_DIRS = [
|
|||||||
'delete',
|
'delete',
|
||||||
'delete_regress',
|
'delete_regress',
|
||||||
# TODO: 'deprecation',
|
# TODO: 'deprecation',
|
||||||
# TODO: 'dispatch',
|
'dispatch',
|
||||||
'distinct_on_fields',
|
'distinct_on_fields',
|
||||||
'empty',
|
'empty',
|
||||||
'expressions',
|
'expressions',
|
||||||
@@ -321,7 +367,10 @@ TESTS_DIRS = [
|
|||||||
'inline_formsets',
|
'inline_formsets',
|
||||||
'inspectdb',
|
'inspectdb',
|
||||||
'introspection',
|
'introspection',
|
||||||
# TODO: 'invalid_models_tests',
|
|
||||||
|
# not practical
|
||||||
|
# 'invalid_models_tests',
|
||||||
|
|
||||||
'known_related_objects',
|
'known_related_objects',
|
||||||
# TODO: 'logging_tests',
|
# TODO: 'logging_tests',
|
||||||
'lookup',
|
'lookup',
|
||||||
@@ -345,8 +394,10 @@ TESTS_DIRS = [
|
|||||||
# TODO: 'middleware_exceptions',
|
# TODO: 'middleware_exceptions',
|
||||||
'migrate_signals',
|
'migrate_signals',
|
||||||
'migration_test_data_persistence',
|
'migration_test_data_persistence',
|
||||||
|
# wait for redefinitions
|
||||||
# TODO: 'migrations',
|
# TODO: 'migrations',
|
||||||
'migrations2',
|
'migrations2',
|
||||||
|
# waits for allow redefinitions
|
||||||
# TODO: 'model_fields',
|
# TODO: 'model_fields',
|
||||||
# TODO: 'model_forms',
|
# TODO: 'model_forms',
|
||||||
'model_formsets',
|
'model_formsets',
|
||||||
@@ -358,7 +409,8 @@ TESTS_DIRS = [
|
|||||||
'model_options',
|
'model_options',
|
||||||
'model_package',
|
'model_package',
|
||||||
'model_regress',
|
'model_regress',
|
||||||
# TODO: 'modeladmin',
|
# not practical
|
||||||
|
# 'modeladmin',
|
||||||
# TODO: 'multiple_database',
|
# TODO: 'multiple_database',
|
||||||
'mutually_referential',
|
'mutually_referential',
|
||||||
'nested_foreign_keys',
|
'nested_foreign_keys',
|
||||||
@@ -372,7 +424,7 @@ TESTS_DIRS = [
|
|||||||
'ordering',
|
'ordering',
|
||||||
'prefetch_related',
|
'prefetch_related',
|
||||||
'pagination',
|
'pagination',
|
||||||
# TODO: 'postgres_tests',
|
'postgres_tests',
|
||||||
'project_template',
|
'project_template',
|
||||||
'properties',
|
'properties',
|
||||||
'proxy_model_inheritance',
|
'proxy_model_inheritance',
|
||||||
|
|||||||
Reference in New Issue
Block a user