Skip to content

Commit

Permalink
Properly type SimpleCookie.
Browse files Browse the repository at this point in the history
This definition makes it usable even in pyright's strict mode.
See microsoft/pyright#5927 for details.
  • Loading branch information
apollo13 committed Sep 22, 2023
1 parent f5e65d2 commit b6482f1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
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

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

0 comments on commit b6482f1

Please sign in to comment.