Skip to content

Commit b6482f1

Browse files
committed
Properly type SimpleCookie.
This definition makes it usable even in pyright's strict mode. See microsoft/pyright#5927 for details.
1 parent f5e65d2 commit b6482f1

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

django-stubs/http/cookie.pyi

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Any
2-
3-
SimpleCookie: Any
1+
from http.cookies import SimpleCookie as SimpleCookie
42

53
def parse_cookie(cookie: str) -> dict[str, str]: ...

django-stubs/http/response.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import datetime
22
from collections.abc import AsyncIterable, AsyncIterator, Iterable, Iterator
3+
from http.cookies import SimpleCookie
34
from io import BytesIO
45
from json import JSONEncoder
56
from typing import Any, Literal, TypeVar, overload, type_check_only
67

7-
from django.http.cookie import SimpleCookie
88
from django.utils.datastructures import CaseInsensitiveMapping, _PropertyDescriptor
99

1010
class BadHeaderError(ValueError): ...

django-stubs/template/response.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ContentNotRenderedError(Exception): ...
2020
class SimpleTemplateResponse(HttpResponse):
2121
content: Any
2222
closed: bool
23-
cookies: SimpleCookie[str]
23+
cookies: SimpleCookie
2424
status_code: int
2525
rendering_attrs: Any
2626
template_name: _TemplateForResponseT
@@ -51,7 +51,7 @@ class TemplateResponse(SimpleTemplateResponse):
5151
closed: bool
5252
context: RequestContext
5353
context_data: dict[str, Any] | None
54-
cookies: SimpleCookie[str]
54+
cookies: SimpleCookie
5555
csrf_cookie_set: bool
5656
json: functools.partial
5757
_request: HttpRequest

django-stubs/test/client.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections.abc import Awaitable, Callable, Iterable, Iterator, Mapping
2+
from http.cookies import SimpleCookie
23
from io import BytesIO
34
from json import JSONEncoder
45
from re import Pattern
@@ -10,7 +11,6 @@ from django.contrib.sessions.backends.base import SessionBase
1011
from django.core.handlers.asgi import ASGIRequest
1112
from django.core.handlers.base import BaseHandler
1213
from django.core.handlers.wsgi import WSGIRequest
13-
from django.http.cookie import SimpleCookie
1414
from django.http.request import HttpRequest
1515
from django.http.response import HttpResponseBase
1616
from django.template.base import Template

0 commit comments

Comments
 (0)