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

Fixed TemplateResponse.cookies attribute and SimpleCookie type #1702

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions django-stubs/http/cookie.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Any

SimpleCookie: Any
from http.cookies import SimpleCookie as SimpleCookie
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep this or simply remove it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it as long as Django has this alias.


def parse_cookie(cookie: str) -> dict[str, str]: ...
2 changes: 1 addition & 1 deletion django-stubs/http/response.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import datetime
from collections.abc import AsyncIterable, AsyncIterator, Iterable, Iterator
from http.cookies import SimpleCookie
from io import BytesIO
from json import JSONEncoder
from typing import Any, Literal, TypeVar, overload, type_check_only

from django.http.cookie import SimpleCookie
from django.utils.datastructures import CaseInsensitiveMapping, _PropertyDescriptor

class BadHeaderError(ValueError): ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/template/response.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ContentNotRenderedError(Exception): ...
class SimpleTemplateResponse(HttpResponse):
content: Any
closed: bool
cookies: SimpleCookie[str]
cookies: SimpleCookie
status_code: int
rendering_attrs: Any
template_name: _TemplateForResponseT
Expand Down Expand Up @@ -51,7 +51,7 @@ class TemplateResponse(SimpleTemplateResponse):
closed: bool
context: RequestContext
context_data: dict[str, Any] | None
cookies: SimpleCookie[str]
cookies: SimpleCookie
csrf_cookie_set: bool
json: functools.partial
_request: HttpRequest
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/test/client.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Awaitable, Callable, Iterable, Iterator, Mapping
from http.cookies import SimpleCookie
from io import BytesIO
from json import JSONEncoder
from re import Pattern
Expand All @@ -10,7 +11,6 @@ from django.contrib.sessions.backends.base import SessionBase
from django.core.handlers.asgi import ASGIRequest
from django.core.handlers.base import BaseHandler
from django.core.handlers.wsgi import WSGIRequest
from django.http.cookie import SimpleCookie
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase
from django.template.base import Template
Expand Down