-
-
Notifications
You must be signed in to change notification settings - Fork 493
Add lots of missing argument & return type hints #1204
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
Changes from all commits
6dfbade
82cab08
5b73ab0
f1f1543
652da0c
3200100
6293ce7
9c51562
e7c5585
78c70cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
from typing import Any, Optional, Sequence | ||
from typing import Any, List, Optional, Sequence | ||
|
||
from django.apps.config import AppConfig | ||
from django.contrib.admin.options import BaseModelAdmin | ||
from django.core.checks.messages import CheckMessage, Error | ||
|
||
def check_admin_app(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[CheckMessage]: ... | ||
def check_dependencies(**kwargs: Any) -> Sequence[CheckMessage]: ... | ||
def check_admin_app(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> List[CheckMessage]: ... | ||
def check_dependencies(**kwargs: Any) -> List[CheckMessage]: ... | ||
|
||
class BaseModelAdminChecks: | ||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> Sequence[CheckMessage]: ... | ||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ... | ||
|
||
class ModelAdminChecks(BaseModelAdminChecks): | ||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> Sequence[CheckMessage]: ... | ||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ... | ||
|
||
class InlineModelAdminChecks(BaseModelAdminChecks): | ||
def check(self, inline_obj: BaseModelAdmin, **kwargs: Any) -> Sequence[CheckMessage]: ... # type: ignore | ||
def check(self, inline_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ... # type: ignore | ||
|
||
def must_be(type: Any, option: Any, obj: Any, id: Any): ... | ||
def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any): ... | ||
def refer_to_missing_field(field: Any, option: Any, obj: Any, id: Any): ... | ||
def must_be(type: Any, option: Any, obj: Any, id: Any) -> List[CheckMessage]: ... | ||
def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any) -> List[CheckMessage]: ... | ||
def refer_to_missing_field(field: Any, option: Any, obj: Any, id: Any) -> List[CheckMessage]: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ from typing import Any, Optional, Set, TypeVar, Union | |
|
||
from django.contrib.auth.base_user import AbstractBaseUser | ||
from django.contrib.auth.models import AnonymousUser, Permission | ||
from django.db.models import QuerySet | ||
from django.db.models.base import Model | ||
from django.http.request import HttpRequest | ||
|
||
|
@@ -33,7 +34,7 @@ class ModelBackend(BaseBackend): | |
is_active: bool = ..., | ||
include_superusers: bool = ..., | ||
obj: Optional[Model] = ..., | ||
): ... | ||
) -> QuerySet[AbstractBaseUser]: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't work
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method does a DB query, so it only returns user models -- it can't return Similar to how |
||
|
||
class AllowAllUsersModelBackend(ModelBackend): ... | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
from typing import Any, Optional | ||
from typing import Any, Optional, Type, TypeVar | ||
|
||
from django.forms.models import BaseModelFormSet | ||
from django.db.models import Model | ||
from django.forms.models import BaseModelFormSet, ModelForm | ||
|
||
class BaseGenericInlineFormSet(BaseModelFormSet): | ||
_M = TypeVar("_M", bound=Model) | ||
_ModelFormT = TypeVar("_ModelFormT", bound=ModelForm) | ||
|
||
class BaseGenericInlineFormSet(BaseModelFormSet[_M, _ModelFormT]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add it to our monkeypatching? Since it is generic now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
instance: Any = ... | ||
rel_name: Any = ... | ||
save_as_new: Any = ... | ||
|
@@ -16,14 +20,14 @@ class BaseGenericInlineFormSet(BaseModelFormSet): | |
queryset: Optional[Any] = ..., | ||
**kwargs: Any | ||
) -> None: ... | ||
def initial_form_count(self): ... | ||
def initial_form_count(self) -> int: ... | ||
@classmethod | ||
def get_default_prefix(cls): ... | ||
def save_new(self, form: Any, commit: bool = ...): ... | ||
def get_default_prefix(cls) -> str: ... | ||
def save_new(self, form: Any, commit: bool = ...) -> _M: ... | ||
|
||
def generic_inlineformset_factory( | ||
model: Any, | ||
form: Any = ..., | ||
model: Type[_M], | ||
form: Type[_ModelFormT] = ..., | ||
formset: Any = ..., | ||
ct_field: str = ..., | ||
fk_field: str = ..., | ||
|
@@ -40,4 +44,4 @@ def generic_inlineformset_factory( | |
validate_min: bool = ..., | ||
absolute_max: Optional[int] = ..., | ||
can_delete_extra: bool = ..., | ||
): ... | ||
) -> Type[BaseGenericInlineFormSet[_M, _ModelFormT]]: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from typing import Set, Tuple | ||
|
||
from django.db.migrations.serializer import BaseSerializer as BaseSerializer | ||
|
||
class RangeSerializer(BaseSerializer): | ||
def serialize(self): ... | ||
def serialize(self) -> Tuple[str, Set[str]]: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from typing import Any | ||
|
||
def prefix_validation_error(error: Any, prefix: Any, code: Any, params: Any): ... | ||
from django.core.exceptions import ValidationError | ||
|
||
def prefix_validation_error(error: Any, prefix: Any, code: Any, params: Any) -> ValidationError: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
from types import ModuleType | ||
from typing import Any, Dict, Sequence, Type, Union | ||
|
||
from django.core.cache.backends.base import BaseCache | ||
|
||
class BaseMemcachedCache(BaseCache): | ||
def __init__(self, server, params, library, value_not_found_exception) -> None: ... | ||
def __init__( | ||
self, | ||
server: Union[str, Sequence[str]], | ||
params: Dict[str, Any], | ||
library: ModuleType, | ||
value_not_found_exception: Type[BaseException], | ||
) -> None: ... | ||
|
||
class MemcachedCache(BaseMemcachedCache): | ||
def __init__(self, server, params): ... | ||
def __init__(self, server: Union[str, Sequence[str]], params: Dict[str, Any]) -> None: ... | ||
|
||
class PyLibMCCache(BaseMemcachedCache): | ||
def __init__(self, server, params): ... | ||
def __init__(self, server: Union[str, Sequence[str]], params: Dict[str, Any]) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this does not exist in django, so it is
_ModelFormatDict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, sorry! I pushed this fix to the wrong branch. Will be fixed in #1206.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, no problem!