diff --git a/django-stubs/http/cookie.pyi b/django-stubs/http/cookie.pyi index 9f0d37d..e2dc91d 100644 --- a/django-stubs/http/cookie.pyi +++ b/django-stubs/http/cookie.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict SimpleCookie: Any diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index e9b2eb1..95c8203 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -2,7 +2,6 @@ from datetime import datetime from io import BufferedReader, BytesIO from tempfile import _TemporaryFileWrapper from typing import Any, Dict, List, Optional, Tuple, Type, Union -from uuid import UUID from django.core.files.base import ContentFile from django.core.serializers.json import DjangoJSONEncoder diff --git a/django-stubs/template/context_processors.pyi b/django-stubs/template/context_processors.pyi index 96ff767..30607e0 100644 --- a/django-stubs/template/context_processors.pyi +++ b/django-stubs/template/context_processors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, List, Tuple, Union from django.core.handlers.wsgi import WSGIRequest from django.http.request import HttpRequest diff --git a/django-stubs/template/defaultfilters.pyi b/django-stubs/template/defaultfilters.pyi index 8b59a15..0a20b54 100644 --- a/django-stubs/template/defaultfilters.pyi +++ b/django-stubs/template/defaultfilters.pyi @@ -4,8 +4,8 @@ from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union from django.utils.safestring import SafeText -from .base import Variable, VariableDoesNotExist -from .library import Library +from .base import Variable as Variable, VariableDoesNotExist as VariableDoesNotExist +from .library import Library as Library register: Any diff --git a/django-stubs/template/library.pyi b/django-stubs/template/library.pyi index 803f746..f04b22f 100644 --- a/django-stubs/template/library.pyi +++ b/django-stubs/template/library.pyi @@ -4,8 +4,8 @@ from django.template.base import FilterExpression, Parser, Template from django.template.context import Context from django.utils.safestring import SafeText -from .base import Node, Template, token_kwargs -from .exceptions import TemplateSyntaxError +from .base import Node, Template +from .exceptions import TemplateSyntaxError as TemplateSyntaxError class InvalidTemplateLibrary(Exception): ... @@ -58,9 +58,9 @@ class TagHelperNode(Node): ) -> Tuple[List[int], Dict[str, Union[SafeText, int]]]: ... class SimpleNode(TagHelperNode): - args: List[django.template.base.FilterExpression] + args: List[FilterExpression] func: Callable - kwargs: Dict[str, django.template.base.FilterExpression] + kwargs: Dict[str, FilterExpression] origin: django.template.base.Origin takes_context: Optional[bool] token: django.template.base.Token @@ -76,9 +76,9 @@ class SimpleNode(TagHelperNode): def render(self, context: Context) -> str: ... class InclusionNode(TagHelperNode): - args: List[django.template.base.FilterExpression] + args: List[FilterExpression] func: Callable - kwargs: Dict[str, django.template.base.FilterExpression] + kwargs: Dict[str, FilterExpression] origin: django.template.base.Origin takes_context: Optional[bool] token: django.template.base.Token diff --git a/django-stubs/template/loader.pyi b/django-stubs/template/loader.pyi index 9e7cc78..9ae3007 100644 --- a/django-stubs/template/loader.pyi +++ b/django-stubs/template/loader.pyi @@ -1,19 +1,17 @@ -from typing import Any, Dict, List, Optional, Union +from typing import Dict, List, Optional, Union from django.core.handlers.wsgi import WSGIRequest -from django.template.backends.django import Template -from django.template.backends.dummy import Template -from django.template.backends.jinja2 import Template - -from .exceptions import TemplateDoesNotExist +from django.template.backends.django import Template as DjangoTemplate +from django.template.backends.dummy import Template as DummyTemplate +from django.template.backends.jinja2 import Template as Jinja2Template def get_template( template_name: str, using: Optional[str] = ... -) -> Union[Template, Template, Template]: ... +) -> Union[DjangoTemplate, DummyTemplate, Jinja2Template]: ... def select_template( template_name_list: Union[List[str], str], using: Optional[str] = ... -) -> Union[Template, Template, Template]: ... +) -> Union[DjangoTemplate, DummyTemplate, Jinja2Template]: ... def render_to_string( template_name: Union[List[str], str], context: Optional[Union[Dict[str, bool], Dict[str, str]]] = ..., diff --git a/django-stubs/template/loaders/app_directories.pyi b/django-stubs/template/loaders/app_directories.pyi index 21f847a..d21623e 100644 --- a/django-stubs/template/loaders/app_directories.pyi +++ b/django-stubs/template/loaders/app_directories.pyi @@ -1,9 +1,11 @@ from typing import Optional, Tuple +from django.template import Engine + from .filesystem import Loader as FilesystemLoader class Loader(FilesystemLoader): dirs: None - engine: django.template.engine.Engine + engine: Engine def get_dirs(self) -> Tuple: ... diff --git a/django-stubs/template/loaders/locmem.pyi b/django-stubs/template/loaders/locmem.pyi index a67bdd6..5b36242 100644 --- a/django-stubs/template/loaders/locmem.pyi +++ b/django-stubs/template/loaders/locmem.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterator, Optional +from typing import Dict, Iterator from django.template.base import Origin from django.template.engine import Engine @@ -7,7 +7,7 @@ from .base import Loader as BaseLoader class Loader(BaseLoader): - engine: django.template.engine.Engine + engine: Engine templates_dict: Dict[str, str] = ... def __init__( self, engine: Engine, templates_dict: Dict[str, str] diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index f7bebfc..8eac7cf 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -10,36 +10,25 @@ from django.template.backends.django import Template from django.template.backends.jinja2 import Template from django.views.generic.base import TemplateResponseMixin -from .loader import get_template, select_template +from .loader import get_template as get_template, select_template as select_template class ContentNotRenderedError(Exception): ... class SimpleTemplateResponse(HttpResponse): closed: bool - cookies: http.cookies.SimpleCookie + cookies: SimpleCookie status_code: int rendering_attrs: Any = ... template_name: Union[ - List[str], django.template.backends.django.Template, str + List[str], Template, str ] = ... context_data: Optional[Dict[str, str]] = ... using: Optional[str] = ... def __init__( self, template: Union[List[str], Template, str], - context: Optional[ - Union[ - Dict[ - str, List[Dict[str, Optional[Union[datetime, Model, str]]]] - ], - Dict[str, List[str]], - Dict[str, Model], - Dict[str, TemplateResponseMixin], - Dict[str, str], - MagicMock, - ] - ] = ..., + context: Optional[Dict[str, Any]] = ..., content_type: Optional[str] = ..., status: Optional[int] = ..., charset: Optional[str] = ..., @@ -50,28 +39,8 @@ class SimpleTemplateResponse(HttpResponse): ) -> Union[Template, Template]: ... def resolve_context( self, - context: Optional[ - Union[ - Dict[ - str, List[Dict[str, Optional[Union[datetime, Model, str]]]] - ], - Dict[str, List[str]], - Dict[str, Model], - Dict[str, TemplateResponseMixin], - Dict[str, str], - MagicMock, - ] - ], - ) -> Optional[ - Union[ - Dict[str, List[Dict[str, Optional[Union[datetime, Model, str]]]]], - Dict[str, List[str]], - Dict[str, Model], - Dict[str, TemplateResponseMixin], - Dict[str, str], - MagicMock, - ] - ]: ... + context: Optional[Dict[str, Any]], + ) -> Optional[Dict[str, Any]]: ... @property def rendered_content(self) -> str: ... def add_post_render_callback(self, callback: Callable) -> None: ... @@ -89,31 +58,8 @@ class TemplateResponse(SimpleTemplateResponse): client: django.test.client.Client closed: bool context: django.template.context.RequestContext - context_data: Optional[ - Union[ - Dict[ - str, - List[ - Dict[ - str, - Optional[ - Union[ - datetime.datetime, - django.db.models.base.Model, - str, - ] - ], - ] - ], - ], - Dict[str, List[str]], - Dict[str, django.db.models.base.Model], - Dict[str, django.views.generic.base.TemplateResponseMixin], - Dict[str, str], - unittest.mock.MagicMock, - ] - ] - cookies: http.cookies.SimpleCookie + context_data: Optional[Dict[str, Any]] + cookies: SimpleCookie csrf_cookie_set: bool json: functools.partial redirect_chain: List[Tuple[str, int]] diff --git a/django-stubs/template/utils.pyi b/django-stubs/template/utils.pyi index 0336185..8483e19 100644 --- a/django-stubs/template/utils.pyi +++ b/django-stubs/template/utils.pyi @@ -1,5 +1,6 @@ +import collections from collections import OrderedDict -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, Tuple, Union from django.core.exceptions import ImproperlyConfigured from django.template.backends.base import BaseEngine