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

Fix AsyncClient.defaults attribute typing #1878

Merged
merged 3 commits into from
Mar 28, 2024
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
24 changes: 22 additions & 2 deletions django-stubs/test/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ from io import BytesIO, IOBase
from json import JSONEncoder
from re import Pattern
from types import TracebackType
from typing import Any, Generic, NoReturn, TypeVar, type_check_only
from typing import Any, Generic, Literal, NoReturn, TypedDict, TypeVar, type_check_only

from asgiref.typing import ASGIVersions
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.sessions.backends.base import SessionBase
from django.core.handlers.asgi import ASGIRequest
Expand Down Expand Up @@ -154,8 +155,27 @@ class _RequestFactory(Generic[_T]):

class RequestFactory(_RequestFactory[WSGIRequest]): ...

# A non total duplication of `asgiref.typing.HTTPScope`
@type_check_only
class _AsyncRequestFactory(_RequestFactory[_T]): ...
class _HTTPScope(TypedDict, total=False):
type: Literal["http"]
asgi: ASGIVersions
http_version: str
method: str
scheme: str
path: str
raw_path: bytes
query_string: bytes
root_path: str
headers: Iterable[tuple[bytes, bytes]]
client: tuple[str, int] | None
server: tuple[str, int | None] | None
state: dict[str, Any]
extensions: dict[str, dict[object, object]] | None

@type_check_only
class _AsyncRequestFactory(_RequestFactory[_T]):
defaults: _HTTPScope # type: ignore[assignment]

class AsyncRequestFactory(_AsyncRequestFactory[ASGIRequest]): ...

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def find_stub_files(name: str) -> List[str]:

dependencies = [
"django",
"asgiref",
"django-stubs-ext>=5.0.0.dev1",
"tomli; python_version < '3.11'",
# Types:
Expand Down
Loading