Skip to content
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

[5.0] Added many new a-prefixed asynchronous methods #1741

Merged
merged 7 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions django-stubs/contrib/auth/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ REDIRECT_FIELD_NAME: str
def load_backend(path: str) -> ModelBackend: ...
def get_backends() -> list[ModelBackend]: ...
def authenticate(request: HttpRequest | None = ..., **credentials: Any) -> AbstractBaseUser | None: ...
async def aauthenticate(request: HttpRequest | None = ..., **credentials: Any) -> AbstractBaseUser | None: ...
def login(
request: HttpRequest, user: AbstractBaseUser | None, backend: type[ModelBackend] | str | None = ...
) -> None: ...
async def alogin(
request: HttpRequest, user: AbstractBaseUser | None, backend: type[ModelBackend] | str | None = ...
) -> None: ...
def logout(request: HttpRequest) -> None: ...
async def alogout(request: HttpRequest) -> None: ...
def get_user_model() -> type[AbstractBaseUser]: ...
def get_user(request: HttpRequest | Client) -> AbstractBaseUser | AnonymousUser: ...
async def aget_user(request: HttpRequest | Client) -> AbstractBaseUser | AnonymousUser: ...
def get_permission_codename(action: str, opts: Options) -> str: ...
def update_session_auth_hash(request: HttpRequest, user: AbstractBaseUser) -> None: ...
async def aupdate_session_auth_hash(request: HttpRequest, user: AbstractBaseUser) -> None: ...

default_app_config: str
1 change: 1 addition & 0 deletions django-stubs/contrib/auth/base_user.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AbstractBaseUser(models.Model):
def is_authenticated(self) -> Literal[True]: ...
def set_password(self, raw_password: str | None) -> None: ...
def check_password(self, raw_password: str) -> bool: ...
async def acheck_password(self, raw_password: str) -> bool: ...
def set_unusable_password(self) -> None: ...
def has_usable_password(self) -> bool: ...
def get_session_auth_hash(self) -> str: ...
Expand Down
3 changes: 3 additions & 0 deletions django-stubs/contrib/auth/hashers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ UNUSABLE_PASSWORD_SUFFIX_LENGTH: int

def is_password_usable(encoded: str | None) -> bool: ...
def check_password(password: str | None, encoded: str, setter: Callable | None = ..., preferred: str = ...) -> bool: ...
async def acheck_password(
password: str | None, encoded: str, setter: Callable | None = ..., preferred: str = ...
) -> bool: ...
def make_password(password: str | None, salt: str | None = ..., hasher: str | BasePasswordHasher = ...) -> str: ...
def get_hashers() -> list[BasePasswordHasher]: ...
def get_hashers_by_algorithm() -> dict[str, BasePasswordHasher]: ...
Expand Down
1 change: 1 addition & 0 deletions django-stubs/db/models/query.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class Prefetch:
def get_current_queryset(self, level: int) -> QuerySet | None: ...

def prefetch_related_objects(model_instances: Iterable[_T], *related_lookups: str | Prefetch) -> None: ...
async def aprefetch_related_objects(model_instances: Iterable[_T], *related_lookups: str | Prefetch) -> None: ...
def get_prefetcher(instance: Model, through_attr: str, to_attr: str) -> tuple[Any, Any, bool, bool]: ...

class InstanceCheckMeta(type): ...
Expand Down
2 changes: 2 additions & 0 deletions django-stubs/shortcuts.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ def redirect(
_T = TypeVar("_T", bound=Model)

def get_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ...
async def aget_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ...
def get_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
async def aget_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
def resolve_url(to: Callable | Model | str, *args: Any, **kwargs: Any) -> str: ...
4 changes: 4 additions & 0 deletions django-stubs/test/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ class ClientMixin:
def check_exception(self, response: HttpResponseBase) -> NoReturn: ...
@property
def session(self) -> SessionBase: ...
async def asession(self) -> SessionBase: ...
def login(self, **credentials: Any) -> bool: ...
async def alogin(self, **credentials: Any) -> bool: ...
def force_login(self, user: AbstractBaseUser, backend: str | None = ...) -> None: ...
async def aforce_login(self, user: AbstractBaseUser, backend: str | None = ...) -> None: ...
def logout(self) -> None: ...
async def alogout(self) -> None: ...

class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
handler: ClientHandler
Expand Down
15 changes: 0 additions & 15 deletions scripts/stubtest/allowlist_todo_django50.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,10 @@ django.contrib.admin.sites.AdminSite.get_model_admin
django.contrib.admin.utils.build_q_object_from_lookup_parameters
django.contrib.admin.utils.get_last_value_from_parameters
django.contrib.admin.views.main.ChangeList.get_queryset
django.contrib.auth.aauthenticate
django.contrib.auth.admin.UserAdmin.lookup_allowed
django.contrib.auth.aget_user
django.contrib.auth.alogin
django.contrib.auth.alogout
django.contrib.auth.aupdate_session_auth_hash
django.contrib.auth.base_user.AbstractBaseUser.acheck_password
django.contrib.auth.hashers.CryptPasswordHasher
django.contrib.auth.hashers.acheck_password
django.contrib.auth.hashers.verify_password
django.contrib.auth.middleware.auser
django.contrib.auth.models.AbstractBaseUser.acheck_password
django.contrib.contenttypes.fields.GenericForeignKey.get_content_type
django.contrib.contenttypes.fields.GenericForeignKey.get_prefetch_querysets
django.contrib.contenttypes.prefetch
Expand Down Expand Up @@ -242,7 +234,6 @@ django.db.models.lookups.Lookup.allowed_default
django.db.models.query.Prefetch.get_current_querysets
django.db.models.query.QuerySet.aupdate_or_create
django.db.models.query.QuerySet.update_or_create
django.db.models.query.aprefetch_related_objects
django.db.models.query_utils.FilteredRelation.relabeled_clone
django.db.models.query_utils.FilteredRelation.resolve_expression
django.db.models.query_utils.Q.identity
Expand Down Expand Up @@ -278,8 +269,6 @@ django.forms.renderers.BaseRenderer.field_template_name
django.forms.renderers.Jinja2DivFormRenderer.__init__
django.forms.utils.RenderableFieldMixin
django.forms.widgets.ClearableFileInput.checked
django.shortcuts.aget_list_or_404
django.shortcuts.aget_object_or_404
django.template.Template.__iter__
django.template.autoreload
django.template.base.Template.__iter__
Expand All @@ -300,10 +289,6 @@ django.test.client.AsyncClient.patch
django.test.client.AsyncClient.post
django.test.client.AsyncClient.put
django.test.client.AsyncClient.trace
django.test.client.ClientMixin.aforce_login
django.test.client.ClientMixin.alogin
django.test.client.ClientMixin.alogout
django.test.client.ClientMixin.asession
django.test.runner.DiscoverRunner.__init__
django.test.runner.DiscoverRunner.run_tests
django.test.runner.RemoteTestResult.addDuration
Expand Down