mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 22:11:54 +08:00
Change InlineModelAdmin.formset to Type[BaseInlineFormSet] (#521)
* Change InlineModelAdmin.formset to Type[BaseInlineFormSet] * More exact annotations + add NaturalTimeFormatter * Correction: cls type is Type[...] * Complete annotations for PasswordResetTokenGenerator * fix *gettext*_lazy annotations
This commit is contained in:
@@ -17,7 +17,7 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from django.forms.forms import BaseForm
|
from django.forms.forms import BaseForm
|
||||||
from django.forms.formsets import BaseFormSet
|
from django.forms.models import BaseInlineFormSet
|
||||||
from typing_extensions import Literal, TypedDict
|
from typing_extensions import Literal, TypedDict
|
||||||
|
|
||||||
from django.contrib.admin.filters import ListFilter
|
from django.contrib.admin.filters import ListFilter
|
||||||
@@ -268,7 +268,7 @@ class ModelAdmin(BaseModelAdmin[_ModelT]):
|
|||||||
class InlineModelAdmin(BaseModelAdmin[_ModelT]):
|
class InlineModelAdmin(BaseModelAdmin[_ModelT]):
|
||||||
model: Type[_ModelT] = ...
|
model: Type[_ModelT] = ...
|
||||||
fk_name: str = ...
|
fk_name: str = ...
|
||||||
formset: BaseFormSet = ...
|
formset: Type[BaseInlineFormSet] = ...
|
||||||
extra: int = ...
|
extra: int = ...
|
||||||
min_num: Optional[int] = ...
|
min_num: Optional[int] = ...
|
||||||
max_num: Optional[int] = ...
|
max_num: Optional[int] = ...
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from datetime import date
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from django.contrib.auth.base_user import AbstractBaseUser
|
from django.contrib.auth.base_user import AbstractBaseUser
|
||||||
@@ -7,5 +8,10 @@ class PasswordResetTokenGenerator:
|
|||||||
secret: Any = ...
|
secret: Any = ...
|
||||||
def make_token(self, user: AbstractBaseUser) -> str: ...
|
def make_token(self, user: AbstractBaseUser) -> str: ...
|
||||||
def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ...
|
def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ...
|
||||||
|
def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int) -> str: ...
|
||||||
|
def _make_hash_value(self, user: AbstractBaseUser, timestamp: int) -> str: ...
|
||||||
|
def _num_days(self, dt: date) -> float: ...
|
||||||
|
def _today(self) -> date: ...
|
||||||
|
|
||||||
|
|
||||||
default_token_generator: Any
|
default_token_generator: Any
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
from datetime import date, datetime as datetime
|
from datetime import date, datetime as datetime
|
||||||
from typing import Any, Optional, SupportsInt, Union
|
from typing import Any, Callable, Dict, Optional, SupportsInt, Tuple, Type, Union
|
||||||
|
from django import template
|
||||||
|
|
||||||
register: Any
|
register: template.Library
|
||||||
|
|
||||||
def ordinal(value: Optional[Union[str, SupportsInt]]) -> Optional[str]: ...
|
def ordinal(value: Optional[Union[str, SupportsInt]]) -> Optional[str]: ...
|
||||||
def intcomma(value: Optional[Union[str, SupportsInt]], use_l10n: bool = ...) -> str: ...
|
def intcomma(value: Optional[Union[str, SupportsInt]], use_l10n: bool = ...) -> str: ...
|
||||||
|
|
||||||
intword_converters: Any
|
intword_converters: Tuple[Tuple[int, Callable]]
|
||||||
|
|
||||||
def intword(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
def intword(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
||||||
def apnumber(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
def apnumber(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
||||||
def naturalday(value: Optional[Union[date, str]], arg: None = ...) -> Optional[str]: ...
|
def naturalday(value: Optional[Union[date, str]], arg: None = ...) -> Optional[str]: ...
|
||||||
def naturaltime(value: datetime) -> str: ...
|
def naturaltime(value: datetime) -> str: ...
|
||||||
|
|
||||||
|
class NaturalTimeFormatter:
|
||||||
|
time_strings: Dict[str, str]
|
||||||
|
past_substrings: Dict[str, str]
|
||||||
|
future_substrings: Dict[str, str]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def string_for(cls: Type[NaturalTimeFormatter], value: Any) -> Any: ...
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import functools
|
import functools
|
||||||
from contextlib import ContextDecorator
|
from contextlib import ContextDecorator
|
||||||
from typing import Any, Optional, Callable
|
from typing import Any, Optional, Callable, Union
|
||||||
|
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
|
|
||||||
@@ -42,9 +42,12 @@ def npgettext(context: str, singular: str, plural: str, number: int) -> str: ...
|
|||||||
gettext_lazy = gettext
|
gettext_lazy = gettext
|
||||||
ugettext_lazy = ugettext
|
ugettext_lazy = ugettext
|
||||||
pgettext_lazy = pgettext
|
pgettext_lazy = pgettext
|
||||||
ngettext_lazy = ngettext
|
|
||||||
ungettext_lazy = ungettext
|
def ngettext_lazy(singular: str, plural: str, number: Union[int, str, None]) -> str: ...
|
||||||
npgettext_lazy = npgettext
|
|
||||||
|
ungettext_lazy = ngettext_lazy
|
||||||
|
|
||||||
|
def npgettext_lazy(context: str, singular: str, plural: str, number: Union[int, str, None]) -> str: ...
|
||||||
|
|
||||||
def activate(language: str) -> None: ...
|
def activate(language: str) -> None: ...
|
||||||
def deactivate() -> None: ...
|
def deactivate() -> None: ...
|
||||||
|
|||||||
Reference in New Issue
Block a user