add stubs for admin_changeset tests

This commit is contained in:
Maxim Kurnikov
2019-01-29 20:29:19 +03:00
parent ece2b87318
commit 978379c454
8 changed files with 28 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
from collections import OrderedDict from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union, Sequence
from django.contrib.admin.filters import SimpleListFilter from django.contrib.admin.filters import SimpleListFilter
from django.contrib.admin.models import LogEntry from django.contrib.admin.models import LogEntry
@@ -94,13 +94,13 @@ class BaseModelAdmin:
class ModelAdmin(BaseModelAdmin): class ModelAdmin(BaseModelAdmin):
formfield_overrides: Any formfield_overrides: Any
list_display: Any = ... list_display: Sequence[str] = ...
list_display_links: Any = ... list_display_links: Sequence[str] = ...
list_filter: Any = ... list_filter: Sequence[str] = ...
list_select_related: bool = ... list_select_related: Sequence[str] = ...
list_per_page: int = ... list_per_page: int = ...
list_max_show_all: int = ... list_max_show_all: int = ...
list_editable: Any = ... list_editable: Sequence[str] = ...
search_fields: Any = ... search_fields: Any = ...
date_hierarchy: Any = ... date_hierarchy: Any = ...
save_as: bool = ... save_as: bool = ...
@@ -167,17 +167,17 @@ class ModelAdmin(BaseModelAdmin):
self, request: WSGIRequest, default_choices: List[Tuple[str, str]] = ... self, request: WSGIRequest, default_choices: List[Tuple[str, str]] = ...
) -> List[Tuple[str, str]]: ... ) -> List[Tuple[str, str]]: ...
def get_action(self, action: Union[Callable, str]) -> Tuple[Callable, str, str]: ... def get_action(self, action: Union[Callable, str]) -> Tuple[Callable, str, str]: ...
def get_list_display(self, request: WSGIRequest) -> Union[List[Callable], List[str], Tuple[str]]: ... def get_list_display(self, request: WSGIRequest) -> Sequence[str]: ...
def get_list_display_links( def get_list_display_links(self, request: WSGIRequest, list_display: Sequence[str]) -> Optional[Sequence[str]]: ...
self, request: WSGIRequest, list_display: Union[List[Callable], List[str], Tuple[str]] def get_list_filter(self, request: WSGIRequest) -> Sequence[str]: ...
) -> Optional[Union[List[Callable], List[str], Tuple[str]]]: ... def get_list_select_related(self, request: WSGIRequest) -> Sequence[str]: ...
def get_list_filter(self, request: WSGIRequest) -> Union[List[Type[SimpleListFilter]], List[str], Tuple]: ... def get_search_fields(self, request: WSGIRequest) -> List[str]: ...
def get_list_select_related(self, request: WSGIRequest) -> Union[Tuple, bool]: ...
def get_search_fields(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
def get_search_results( def get_search_results(
self, request: WSGIRequest, queryset: QuerySet, search_term: str self, request: WSGIRequest, queryset: QuerySet, search_term: str
) -> Tuple[QuerySet, bool]: ... ) -> Tuple[QuerySet, bool]: ...
def get_preserved_filters(self, request: WSGIRequest) -> str: ... def get_preserved_filters(self, request: WSGIRequest) -> str: ...
def _get_edited_object_pks(self, request: WSGIRequest, prefix: str) -> List[str]: ...
def _get_list_editable_queryset(self, request: WSGIRequest, prefix: str) -> QuerySet: ...
def construct_change_message( def construct_change_message(
self, request: WSGIRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ... self, request: WSGIRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ...
) -> List[Dict[str, Dict[str, List[str]]]]: ... ) -> List[Dict[str, Dict[str, List[str]]]]: ...

View File

@@ -26,6 +26,7 @@ class AdminSite:
password_change_template: Any = ... password_change_template: Any = ...
password_change_done_template: Any = ... password_change_done_template: Any = ...
name: str = ... name: str = ...
_registry: Dict[Type[Model], ModelAdmin]
def __init__(self, name: str = ...) -> None: ... def __init__(self, name: str = ...) -> None: ...
def check(self, app_configs: None) -> List[str]: ... def check(self, app_configs: None) -> List[str]: ...
def register( def register(

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Iterator, List, Optional, Union from typing import Any, Dict, Iterator, List, Optional, Union, Iterable
from django.contrib.admin.filters import FieldListFilter from django.contrib.admin.filters import FieldListFilter
from django.contrib.admin.templatetags.base import InclusionAdminNode from django.contrib.admin.templatetags.base import InclusionAdminNode
@@ -15,7 +15,7 @@ register: Any
DOT: str DOT: str
def paginator_number(cl: ChangeList, i: int) -> SafeText: ... def paginator_number(cl: ChangeList, i: int) -> SafeText: ...
def pagination(cl: ChangeList) -> Dict[str, Union[List[Union[int, str]], ChangeList, int, range, str]]: ... def pagination(cl: ChangeList) -> Dict[str, Iterable[Any]]: ...
def pagination_tag(parser: Parser, token: Token) -> InclusionAdminNode: ... def pagination_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def result_headers(cl: ChangeList) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ... def result_headers(cl: ChangeList) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ...
def items_for_result(cl: ChangeList, result: Model, form: None) -> Iterator[SafeText]: ... def items_for_result(cl: ChangeList, result: Model, form: None) -> Iterator[SafeText]: ...

View File

@@ -9,6 +9,7 @@ from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.db.models.options import Options from django.db.models.options import Options
from django.forms.formsets import BaseFormSet
ALL_VAR: str ALL_VAR: str
ORDER_VAR: str ORDER_VAR: str
@@ -44,6 +45,7 @@ class ChangeList:
queryset: Any = ... queryset: Any = ...
title: Any = ... title: Any = ...
pk_attname: Any = ... pk_attname: Any = ...
formset: Optional[BaseFormSet]
def __init__( def __init__(
self, self,
request: WSGIRequest, request: WSGIRequest,

View File

@@ -111,6 +111,8 @@ class F(Combinable):
summarize: bool = ..., summarize: bool = ...,
for_save: bool = ..., for_save: bool = ...,
) -> Expression: ... ) -> Expression: ...
def asc(self, **kwargs) -> OrderBy: ...
def desc(self, **kwargs) -> OrderBy: ...
class OuterRef(F): ... class OuterRef(F): ...

View File

@@ -1 +1 @@
from .text import Lower as Lower from .text import Lower as Lower, Upper as Upper

View File

@@ -58,6 +58,8 @@ class RegisterLookupMixin:
def merge_dicts(dicts: List[Dict[str, Any]]) -> Dict[str, Any]: ... def merge_dicts(dicts: List[Dict[str, Any]]) -> Dict[str, Any]: ...
@classmethod @classmethod
def register_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...) -> Type[Any]: ... def register_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...) -> Type[Any]: ...
@classmethod
def _unregister_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...): ...
def select_related_descend( def select_related_descend(
field: Field, field: Field,

View File

@@ -21,12 +21,16 @@ IGNORED_ERROR_PATTERNS = [
'Cannot infer type of lambda', 'Cannot infer type of lambda',
'Incompatible types in assignment (expression has type "Callable[', 'Incompatible types in assignment (expression has type "Callable[',
'Invalid value for a to= parameter', 'Invalid value for a to= parameter',
'Incompatible types in assignment (expression has type "FilteredChildAdmin", variable has type "ChildAdmin")',
re.compile(r'"Callable\[\[(Any(, )?)+\], Any\]" has no attribute'), re.compile(r'"Callable\[\[(Any(, )?)+\], Any\]" has no attribute'),
re.compile(r'"HttpResponseBase" has no attribute "[A-Za-z_]+"'), re.compile(r'"HttpResponseBase" has no attribute "[A-Za-z_]+"'),
re.compile(r'Incompatible types in assignment \(expression has type "Tuple\[\]", '
r'variable has type "Tuple\[[A-Za-z, ]+\]"'),
] ]
TESTS_DIRS = [ TESTS_DIRS = [
'absolute_url_overrides', 'absolute_url_overrides',
'admin_autodiscover' 'admin_autodiscover',
'admin_changelist',
] ]