mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-09 05:24:53 +08:00
make pep561 compliant
This commit is contained in:
67
django-stubs/contrib/auth/__init__.pyi
Normal file
67
django-stubs/contrib/auth/__init__.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.models import (
|
||||
AnonymousUser,
|
||||
User,
|
||||
)
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.options import Options
|
||||
from django.http.request import HttpRequest
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def _clean_credentials(credentials: Dict[str, Optional[str]]) -> Dict[str, Optional[str]]: ...
|
||||
|
||||
|
||||
def _get_backends(return_tuples: bool = ...) -> Any: ...
|
||||
|
||||
|
||||
def _get_user_session_key(request: HttpRequest) -> int: ...
|
||||
|
||||
|
||||
def authenticate(
|
||||
request: Optional[HttpRequest] = ...,
|
||||
**credentials
|
||||
) -> Optional[AbstractBaseUser]: ...
|
||||
|
||||
|
||||
def get_backends() -> List[ModelBackend]: ...
|
||||
|
||||
|
||||
def get_permission_codename(action: str, opts: Options) -> str: ...
|
||||
|
||||
|
||||
def get_user(
|
||||
request: HttpRequest
|
||||
) -> Union[AnonymousUser, AbstractBaseUser]: ...
|
||||
|
||||
|
||||
def get_user_model() -> Type[Model]: ...
|
||||
|
||||
|
||||
def load_backend(path: str) -> object: ...
|
||||
|
||||
|
||||
def login(
|
||||
request: HttpRequest,
|
||||
user: User,
|
||||
backend: Optional[Union[str, Type[ModelBackend]]] = ...
|
||||
) -> None: ...
|
||||
|
||||
|
||||
def logout(request: HttpRequest) -> None: ...
|
||||
|
||||
|
||||
def update_session_auth_hash(
|
||||
request: WSGIRequest,
|
||||
user: SimpleLazyObject
|
||||
) -> None: ...
|
||||
56
django-stubs/contrib/auth/admin.pyi
Normal file
56
django-stubs/contrib/auth/admin.pyi
Normal file
@@ -0,0 +1,56 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.fields.related import ManyToManyField
|
||||
from django.forms.models import ModelMultipleChoiceField
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.urls.resolvers import URLPattern
|
||||
from typing import (
|
||||
Dict,
|
||||
List,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class GroupAdmin:
|
||||
def formfield_for_manytomany(
|
||||
self,
|
||||
db_field: ManyToManyField,
|
||||
request: WSGIRequest = ...,
|
||||
**kwargs
|
||||
) -> ModelMultipleChoiceField: ...
|
||||
|
||||
|
||||
class UserAdmin:
|
||||
def _add_view(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
form_url: str = ...,
|
||||
extra_context: None = ...
|
||||
) -> Union[TemplateResponse, HttpResponseRedirect]: ...
|
||||
def add_view(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
form_url: str = ...,
|
||||
extra_context: None = ...
|
||||
): ...
|
||||
def get_fieldsets(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
obj: None = ...
|
||||
) -> Tuple[Tuple[None, Dict[str, Union[Tuple[str], Tuple[str, str, str]]]]]: ...
|
||||
def get_urls(self) -> List[URLPattern]: ...
|
||||
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
|
||||
def response_add(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
obj: User,
|
||||
post_url_continue: None = ...
|
||||
) -> HttpResponseRedirect: ...
|
||||
def user_change_password(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
id: str,
|
||||
form_url: str = ...
|
||||
) -> Union[TemplateResponse, HttpResponseRedirect]: ...
|
||||
2
django-stubs/contrib/auth/apps.pyi
Normal file
2
django-stubs/contrib/auth/apps.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
class AuthConfig:
|
||||
def ready(self) -> None: ...
|
||||
60
django-stubs/contrib/auth/backends.pyi
Normal file
60
django-stubs/contrib/auth/backends.pyi
Normal file
@@ -0,0 +1,60 @@
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.models import (
|
||||
AnonymousUser,
|
||||
User,
|
||||
)
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.query import QuerySet
|
||||
from django.http.request import HttpRequest
|
||||
from typing import (
|
||||
Optional,
|
||||
Set,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class AllowAllUsersModelBackend:
|
||||
def user_can_authenticate(self, user: User) -> bool: ...
|
||||
|
||||
|
||||
class AllowAllUsersRemoteUserBackend:
|
||||
def user_can_authenticate(self, user: User) -> bool: ...
|
||||
|
||||
|
||||
class ModelBackend:
|
||||
def _get_group_permissions(self, user_obj: User) -> QuerySet: ...
|
||||
def _get_permissions(self, user_obj: User, obj: None, from_name: str) -> Set[str]: ...
|
||||
def _get_user_permissions(self, user_obj: User) -> QuerySet: ...
|
||||
def authenticate(
|
||||
self,
|
||||
request: Optional[HttpRequest],
|
||||
username: Optional[str] = ...,
|
||||
password: Optional[str] = ...,
|
||||
**kwargs
|
||||
) -> Optional[User]: ...
|
||||
def get_all_permissions(self, user_obj: User, obj: Optional[str] = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, user_obj: User, obj: None = ...) -> Set[str]: ...
|
||||
def get_user(self, user_id: int) -> User: ...
|
||||
def get_user_permissions(self, user_obj: User, obj: None = ...) -> Set[str]: ...
|
||||
def has_module_perms(
|
||||
self,
|
||||
user_obj: Union[AnonymousUser, User],
|
||||
app_label: str
|
||||
) -> bool: ...
|
||||
def has_perm(
|
||||
self,
|
||||
user_obj: Union[AnonymousUser, User],
|
||||
perm: str,
|
||||
obj: None = ...
|
||||
) -> bool: ...
|
||||
def user_can_authenticate(self, user: Optional[AbstractBaseUser]) -> bool: ...
|
||||
|
||||
|
||||
class RemoteUserBackend:
|
||||
def authenticate(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
remote_user: Optional[str]
|
||||
) -> Optional[User]: ...
|
||||
def clean_username(self, username: str) -> str: ...
|
||||
def configure_user(self, user: User) -> User: ...
|
||||
27
django-stubs/contrib/auth/base_user.pyi
Normal file
27
django-stubs/contrib/auth/base_user.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class AbstractBaseUser:
|
||||
def __str__(self) -> str: ...
|
||||
def check_password(self, raw_password: str) -> bool: ...
|
||||
def clean(self) -> None: ...
|
||||
@classmethod
|
||||
def get_email_field_name(cls) -> str: ...
|
||||
def get_session_auth_hash(self) -> str: ...
|
||||
def get_username(self) -> str: ...
|
||||
def has_usable_password(self) -> bool: ...
|
||||
@property
|
||||
def is_anonymous(self) -> bool: ...
|
||||
@property
|
||||
def is_authenticated(self) -> bool: ...
|
||||
@classmethod
|
||||
def normalize_username(cls, username: str) -> str: ...
|
||||
def save(self, *args, **kwargs) -> None: ...
|
||||
def set_password(self, raw_password: Optional[str]) -> None: ...
|
||||
def set_unusable_password(self) -> None: ...
|
||||
|
||||
|
||||
class BaseUserManager:
|
||||
def get_by_natural_key(self, username: Optional[str]) -> AbstractBaseUser: ...
|
||||
@classmethod
|
||||
def normalize_email(cls, email: Optional[str]) -> str: ...
|
||||
10
django-stubs/contrib/auth/checks.pyi
Normal file
10
django-stubs/contrib/auth/checks.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
from typing import (
|
||||
Any,
|
||||
List,
|
||||
)
|
||||
|
||||
|
||||
def check_models_permissions(app_configs: None = ..., **kwargs) -> List[Any]: ...
|
||||
|
||||
|
||||
def check_user_model(app_configs: None = ..., **kwargs) -> List[Any]: ...
|
||||
27
django-stubs/contrib/auth/context_processors.pyi
Normal file
27
django-stubs/contrib/auth/context_processors.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
from django.contrib.auth.models import (
|
||||
AnonymousUser,
|
||||
User,
|
||||
)
|
||||
from django.http.request import HttpRequest
|
||||
from typing import (
|
||||
Dict,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def auth(
|
||||
request: HttpRequest
|
||||
) -> Dict[str, Union[PermWrapper, AnonymousUser, User]]: ...
|
||||
|
||||
|
||||
class PermLookupDict:
|
||||
def __bool__(self) -> bool: ...
|
||||
def __getitem__(self, perm_name: str) -> bool: ...
|
||||
def __init__(self, user: object, app_label: str) -> None: ...
|
||||
|
||||
|
||||
class PermWrapper:
|
||||
def __contains__(self, perm_name: str) -> bool: ...
|
||||
def __getitem__(self, app_label: str) -> PermLookupDict: ...
|
||||
def __init__(self, user: object) -> None: ...
|
||||
def __iter__(self): ...
|
||||
27
django-stubs/contrib/auth/decorators.pyi
Normal file
27
django-stubs/contrib/auth/decorators.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import (
|
||||
Callable,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def login_required(
|
||||
function: Optional[Callable] = ...,
|
||||
redirect_field_name: str = ...,
|
||||
login_url: None = ...
|
||||
) -> Callable: ...
|
||||
|
||||
|
||||
def permission_required(
|
||||
perm: Union[str, List[str]],
|
||||
login_url: None = ...,
|
||||
raise_exception: bool = ...
|
||||
) -> Callable: ...
|
||||
|
||||
|
||||
def user_passes_test(
|
||||
test_func: Callable,
|
||||
login_url: Optional[str] = ...,
|
||||
redirect_field_name: str = ...
|
||||
) -> Callable: ...
|
||||
93
django-stubs/contrib/auth/forms.pyi
Normal file
93
django-stubs/contrib/auth/forms.pyi
Normal file
@@ -0,0 +1,93 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class AdminPasswordChangeForm:
|
||||
def __init__(self, user: User, *args, **kwargs) -> None: ...
|
||||
@property
|
||||
def changed_data(self) -> List[str]: ...
|
||||
def clean_password2(self) -> str: ...
|
||||
def save(self, commit: bool = ...) -> User: ...
|
||||
|
||||
|
||||
class AuthenticationForm:
|
||||
def __init__(self, request: object = ..., *args, **kwargs) -> None: ...
|
||||
def clean(self) -> Dict[str, str]: ...
|
||||
def confirm_login_allowed(self, user: User) -> None: ...
|
||||
def get_invalid_login_error(self) -> ValidationError: ...
|
||||
def get_user(self) -> User: ...
|
||||
|
||||
|
||||
class PasswordChangeForm:
|
||||
def clean_old_password(self) -> str: ...
|
||||
|
||||
|
||||
class PasswordResetForm:
|
||||
def get_users(self, email: str) -> Iterator[Any]: ...
|
||||
def save(
|
||||
self,
|
||||
domain_override: None = ...,
|
||||
subject_template_name: str = ...,
|
||||
email_template_name: str = ...,
|
||||
use_https: bool = ...,
|
||||
token_generator: PasswordResetTokenGenerator = ...,
|
||||
from_email: None = ...,
|
||||
request: Optional[WSGIRequest] = ...,
|
||||
html_email_template_name: None = ...,
|
||||
extra_email_context: Optional[Dict[str, str]] = ...
|
||||
) -> None: ...
|
||||
def send_mail(
|
||||
self,
|
||||
subject_template_name: str,
|
||||
email_template_name: str,
|
||||
context: Dict[str, Union[str, User]],
|
||||
from_email: Optional[str],
|
||||
to_email: str,
|
||||
html_email_template_name: None = ...
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class ReadOnlyPasswordHashField:
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def has_changed(self, initial: str, data: None) -> bool: ...
|
||||
|
||||
|
||||
class ReadOnlyPasswordHashWidget:
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: str,
|
||||
attrs: Dict[str, str]
|
||||
) -> Dict[str, Union[Dict[str, Union[str, bool, Dict[str, str]]], List[Dict[str, str]]]]: ...
|
||||
|
||||
|
||||
class SetPasswordForm:
|
||||
def __init__(self, user: Optional[User], *args, **kwargs) -> None: ...
|
||||
def clean_new_password2(self) -> str: ...
|
||||
def save(self, commit: bool = ...) -> User: ...
|
||||
|
||||
|
||||
class UserChangeForm:
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def clean_password(self) -> str: ...
|
||||
|
||||
|
||||
class UserCreationForm:
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def _post_clean(self) -> None: ...
|
||||
def clean_password2(self) -> str: ...
|
||||
def save(self, commit: bool = ...) -> User: ...
|
||||
|
||||
|
||||
class UsernameField:
|
||||
def to_python(self, value: Optional[str]) -> str: ...
|
||||
10
django-stubs/contrib/auth/handlers/modwsgi.pyi
Normal file
10
django-stubs/contrib/auth/handlers/modwsgi.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
)
|
||||
|
||||
|
||||
def check_password(environ: Dict[Any, Any], username: str, password: str): ...
|
||||
|
||||
|
||||
def groups_for_user(environ: Dict[Any, Any], username: str): ...
|
||||
76
django-stubs/contrib/auth/hashers.pyi
Normal file
76
django-stubs/contrib/auth/hashers.pyi
Normal file
@@ -0,0 +1,76 @@
|
||||
from collections import OrderedDict
|
||||
from typing import (
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def check_password(
|
||||
password: str,
|
||||
encoded: str,
|
||||
setter: Optional[Callable] = ...,
|
||||
preferred: str = ...
|
||||
) -> bool: ...
|
||||
|
||||
|
||||
def get_hasher(algorithm: str = ...) -> BasePasswordHasher: ...
|
||||
|
||||
|
||||
def get_hashers(
|
||||
) -> Union[List[UnsaltedMD5PasswordHasher], List[MD5PasswordHasher], List[BasePasswordHasher], List[PBKDF2PasswordHasher]]: ...
|
||||
|
||||
|
||||
def get_hashers_by_algorithm() -> Dict[str, BasePasswordHasher]: ...
|
||||
|
||||
|
||||
def identify_hasher(encoded: str) -> BasePasswordHasher: ...
|
||||
|
||||
|
||||
def is_password_usable(encoded: Optional[str]) -> bool: ...
|
||||
|
||||
|
||||
def make_password(password: Optional[str], salt: Optional[str] = ..., hasher: str = ...) -> str: ...
|
||||
|
||||
|
||||
def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ...
|
||||
|
||||
|
||||
def reset_hashers(**kwargs) -> None: ...
|
||||
|
||||
|
||||
class BasePasswordHasher:
|
||||
def harden_runtime(self, password: str, encoded: str) -> None: ...
|
||||
def must_update(self, encoded: str) -> bool: ...
|
||||
def safe_summary(self, encoded: str): ...
|
||||
def salt(self) -> str: ...
|
||||
|
||||
|
||||
class MD5PasswordHasher:
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def safe_summary(self, encoded: str) -> OrderedDict: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
|
||||
|
||||
class PBKDF2PasswordHasher:
|
||||
def encode(self, password: str, salt: str, iterations: Optional[int] = ...) -> str: ...
|
||||
def must_update(self, encoded: str) -> bool: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
|
||||
|
||||
class SHA1PasswordHasher:
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
|
||||
|
||||
class UnsaltedMD5PasswordHasher:
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
|
||||
|
||||
class UnsaltedSHA1PasswordHasher:
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def salt(self) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
29
django-stubs/contrib/auth/management/__init__.pyi
Normal file
29
django-stubs/contrib/auth/management/__init__.pyi
Normal file
@@ -0,0 +1,29 @@
|
||||
from django.apps.config import AppConfig
|
||||
from django.apps.registry import Apps
|
||||
from django.db.models.options import Options
|
||||
from typing import (
|
||||
List,
|
||||
Tuple,
|
||||
)
|
||||
|
||||
|
||||
def _get_all_permissions(opts: Options) -> List[Tuple[str, str]]: ...
|
||||
|
||||
|
||||
def _get_builtin_permissions(opts: Options) -> List[Tuple[str, str]]: ...
|
||||
|
||||
|
||||
def create_permissions(
|
||||
app_config: AppConfig,
|
||||
verbosity: int = ...,
|
||||
interactive: bool = ...,
|
||||
using: str = ...,
|
||||
apps: Apps = ...,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
|
||||
|
||||
def get_default_username(check_db: bool = ...) -> str: ...
|
||||
|
||||
|
||||
def get_system_username() -> str: ...
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.core.management.base import CommandParser
|
||||
|
||||
|
||||
class Command:
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def handle(self, *args, **options) -> str: ...
|
||||
@@ -0,0 +1,20 @@
|
||||
from django.core.management.base import CommandParser
|
||||
from django.db.models.fields import CharField
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
from typing import (
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class Command:
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def execute(self, *args, **options) -> None: ...
|
||||
def get_input_data(
|
||||
self,
|
||||
field: Union[CharField, related.ForeignKey],
|
||||
message: str,
|
||||
default: Optional[str] = ...
|
||||
) -> Optional[str]: ...
|
||||
def handle(self, *args, **options) -> None: ...
|
||||
22
django-stubs/contrib/auth/middleware.pyi
Normal file
22
django-stubs/contrib/auth/middleware.pyi
Normal file
@@ -0,0 +1,22 @@
|
||||
from django.contrib.auth.models import (
|
||||
AnonymousUser,
|
||||
User,
|
||||
)
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.request import HttpRequest
|
||||
from typing import Union
|
||||
|
||||
|
||||
def get_user(
|
||||
request: HttpRequest
|
||||
) -> Union[AnonymousUser, User]: ...
|
||||
|
||||
|
||||
class AuthenticationMiddleware:
|
||||
def process_request(self, request: HttpRequest) -> None: ...
|
||||
|
||||
|
||||
class RemoteUserMiddleware:
|
||||
def _remove_invalid_user(self, request: WSGIRequest) -> None: ...
|
||||
def clean_username(self, username: str, request: WSGIRequest) -> str: ...
|
||||
def process_request(self, request: WSGIRequest) -> None: ...
|
||||
30
django-stubs/contrib/auth/mixins.pyi
Normal file
30
django-stubs/contrib/auth/mixins.pyi
Normal file
@@ -0,0 +1,30 @@
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.response import HttpResponse
|
||||
from typing import (
|
||||
Callable,
|
||||
List,
|
||||
)
|
||||
|
||||
|
||||
class AccessMixin:
|
||||
def get_permission_denied_message(self) -> str: ...
|
||||
def get_redirect_field_name(self) -> str: ...
|
||||
def handle_no_permission(self): ...
|
||||
|
||||
|
||||
class LoginRequiredMixin:
|
||||
def dispatch(self, request: WSGIRequest, *args, **kwargs): ...
|
||||
|
||||
|
||||
class PermissionRequiredMixin:
|
||||
def dispatch(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> HttpResponse: ...
|
||||
def get_permission_required(self) -> List[str]: ...
|
||||
|
||||
|
||||
class UserPassesTestMixin:
|
||||
def get_test_func(self) -> Callable: ...
|
||||
98
django-stubs/contrib/auth/models.pyi
Normal file
98
django-stubs/contrib/auth/models.pyi
Normal file
@@ -0,0 +1,98 @@
|
||||
from typing import (
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def _user_get_all_permissions(user: User, obj: Optional[str]) -> Set[str]: ...
|
||||
|
||||
|
||||
def _user_has_module_perms(
|
||||
user: Union[AnonymousUser, User],
|
||||
app_label: str
|
||||
) -> bool: ...
|
||||
|
||||
|
||||
def _user_has_perm(
|
||||
user: Union[AnonymousUser, User],
|
||||
perm: str,
|
||||
obj: Optional[str]
|
||||
) -> bool: ...
|
||||
|
||||
|
||||
def update_last_login(
|
||||
sender: Type[User],
|
||||
user: User,
|
||||
**kwargs
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class AbstractUser:
|
||||
def clean(self) -> None: ...
|
||||
def get_short_name(self) -> str: ...
|
||||
|
||||
|
||||
class AnonymousUser:
|
||||
def __str__(self) -> str: ...
|
||||
def delete(self): ...
|
||||
def get_username(self) -> str: ...
|
||||
def has_module_perms(self, module: str) -> bool: ...
|
||||
def has_perm(self, perm: str, obj: None = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Union[List[str], Tuple[str]], obj: None = ...) -> bool: ...
|
||||
@property
|
||||
def is_anonymous(self) -> bool: ...
|
||||
@property
|
||||
def is_authenticated(self) -> bool: ...
|
||||
def set_password(self, raw_password: str): ...
|
||||
|
||||
|
||||
class Group:
|
||||
def __str__(self) -> str: ...
|
||||
|
||||
|
||||
class GroupManager:
|
||||
def get_by_natural_key(self, name: str) -> Group: ...
|
||||
|
||||
|
||||
class Permission:
|
||||
def __str__(self) -> str: ...
|
||||
def natural_key(self) -> Tuple[str, str, str]: ...
|
||||
|
||||
|
||||
class PermissionManager:
|
||||
def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ...
|
||||
|
||||
|
||||
class PermissionsMixin:
|
||||
def get_all_permissions(self, obj: None = ...) -> Set[str]: ...
|
||||
def has_module_perms(self, app_label: str) -> bool: ...
|
||||
def has_perm(self, perm: str, obj: None = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Union[List[str], Tuple[str]], obj: None = ...) -> bool: ...
|
||||
|
||||
|
||||
class UserManager:
|
||||
def _create_user(
|
||||
self,
|
||||
username: str,
|
||||
email: Optional[str],
|
||||
password: Optional[str],
|
||||
**extra_fields
|
||||
) -> User: ...
|
||||
def create_superuser(
|
||||
self,
|
||||
username: str,
|
||||
email: str,
|
||||
password: Optional[str],
|
||||
**extra_fields
|
||||
) -> User: ...
|
||||
def create_user(
|
||||
self,
|
||||
username: str,
|
||||
email: Optional[str] = ...,
|
||||
password: Optional[str] = ...,
|
||||
**extra_fields
|
||||
) -> User: ...
|
||||
60
django-stubs/contrib/auth/password_validation.pyi
Normal file
60
django-stubs/contrib/auth/password_validation.pyi
Normal file
@@ -0,0 +1,60 @@
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.models import User
|
||||
from pathlib import PosixPath
|
||||
from typing import (
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def _password_validators_help_text_html(password_validators: None = ...) -> str: ...
|
||||
|
||||
|
||||
def get_default_password_validators(
|
||||
) -> Union[List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]]: ...
|
||||
|
||||
|
||||
def get_password_validators(
|
||||
validator_config: List[Dict[str, str]]
|
||||
) -> Union[List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]]: ...
|
||||
|
||||
|
||||
def password_changed(
|
||||
password: str,
|
||||
user: AbstractBaseUser = ...,
|
||||
password_validators: None = ...
|
||||
) -> None: ...
|
||||
|
||||
|
||||
def password_validators_help_texts(password_validators: None = ...) -> List[str]: ...
|
||||
|
||||
|
||||
def validate_password(
|
||||
password: str,
|
||||
user: Optional[User] = ...,
|
||||
password_validators: None = ...
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class CommonPasswordValidator:
|
||||
def __init__(self, password_list_path: PosixPath = ...) -> None: ...
|
||||
def validate(self, password: str, user: None = ...) -> None: ...
|
||||
|
||||
|
||||
class MinimumLengthValidator:
|
||||
def __init__(self, min_length: int = ...) -> None: ...
|
||||
def get_help_text(self) -> str: ...
|
||||
def validate(self, password: str, user: None = ...) -> None: ...
|
||||
|
||||
|
||||
class NumericPasswordValidator:
|
||||
def validate(self, password: str, user: User = ...) -> None: ...
|
||||
|
||||
|
||||
class UserAttributeSimilarityValidator:
|
||||
def __init__(self, user_attributes: Tuple[str, str, str, str] = ..., max_similarity: float = ...) -> None: ...
|
||||
def get_help_text(self) -> str: ...
|
||||
def validate(self, password: str, user: None = ...) -> None: ...
|
||||
12
django-stubs/contrib/auth/tokens.pyi
Normal file
12
django-stubs/contrib/auth/tokens.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
from datetime import date
|
||||
from django.contrib.auth.models import User
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class PasswordResetTokenGenerator:
|
||||
def _make_hash_value(self, user: User, timestamp: int) -> str: ...
|
||||
def _make_token_with_timestamp(self, user: User, timestamp: int) -> str: ...
|
||||
def _num_days(self, dt: date) -> int: ...
|
||||
def _today(self) -> date: ...
|
||||
def check_token(self, user: User, token: Optional[str]) -> bool: ...
|
||||
def make_token(self, user: User) -> str: ...
|
||||
108
django-stubs/contrib/auth/views.pyi
Normal file
108
django-stubs/contrib/auth/views.pyi
Normal file
@@ -0,0 +1,108 @@
|
||||
from django.contrib.auth.forms import (
|
||||
AuthenticationForm,
|
||||
PasswordChangeForm,
|
||||
PasswordResetForm,
|
||||
SetPasswordForm,
|
||||
)
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.request import HttpRequest
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Optional,
|
||||
Set,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def redirect_to_login(
|
||||
next: str,
|
||||
login_url: Optional[str] = ...,
|
||||
redirect_field_name: Optional[str] = ...
|
||||
) -> HttpResponseRedirect: ...
|
||||
|
||||
|
||||
class LoginView:
|
||||
def dispatch(
|
||||
self,
|
||||
request: HttpRequest,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> Union[TemplateResponse, HttpResponseRedirect]: ...
|
||||
def form_valid(
|
||||
self,
|
||||
form: AuthenticationForm
|
||||
) -> HttpResponseRedirect: ...
|
||||
def get_context_data(self, **kwargs) -> Dict[str, Any]: ...
|
||||
def get_form_class(self) -> Type[AuthenticationForm]: ...
|
||||
def get_form_kwargs(
|
||||
self
|
||||
) -> Dict[str, Optional[Union[MultiValueDict, WSGIRequest]]]: ...
|
||||
def get_redirect_url(self) -> str: ...
|
||||
def get_success_url(self) -> str: ...
|
||||
|
||||
|
||||
class LogoutView:
|
||||
def dispatch(
|
||||
self,
|
||||
request: HttpRequest,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> Union[TemplateResponse, HttpResponseRedirect]: ...
|
||||
def get_next_page(self) -> Optional[str]: ...
|
||||
def post(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> TemplateResponse: ...
|
||||
|
||||
|
||||
class PasswordChangeDoneView:
|
||||
def dispatch(self, *args, **kwargs) -> TemplateResponse: ...
|
||||
|
||||
|
||||
class PasswordChangeView:
|
||||
def dispatch(
|
||||
self,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> Union[TemplateResponse, HttpResponseRedirect]: ...
|
||||
def form_valid(
|
||||
self,
|
||||
form: PasswordChangeForm
|
||||
) -> HttpResponseRedirect: ...
|
||||
def get_form_kwargs(
|
||||
self
|
||||
) -> Dict[str, Optional[Union[MultiValueDict, User]]]: ...
|
||||
|
||||
|
||||
class PasswordResetConfirmView:
|
||||
def dispatch(
|
||||
self,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> Union[TemplateResponse, HttpResponseRedirect]: ...
|
||||
def form_valid(self, form: SetPasswordForm) -> HttpResponseRedirect: ...
|
||||
def get_form_kwargs(
|
||||
self
|
||||
) -> Dict[str, Optional[Union[MultiValueDict, User]]]: ...
|
||||
def get_user(self, uidb64: str) -> Optional[User]: ...
|
||||
|
||||
|
||||
class PasswordResetView:
|
||||
def dispatch(
|
||||
self,
|
||||
*args,
|
||||
**kwargs
|
||||
) -> Union[TemplateResponse, HttpResponseRedirect]: ...
|
||||
def form_valid(self, form: PasswordResetForm) -> HttpResponseRedirect: ...
|
||||
|
||||
|
||||
class SuccessURLAllowedHostsMixin:
|
||||
def get_success_url_allowed_hosts(self) -> Set[str]: ...
|
||||
Reference in New Issue
Block a user