fifth iteration

This commit is contained in:
Maxim Kurnikov
2018-08-14 12:01:01 +03:00
parent 8cc446150c
commit a13d4c352a
124 changed files with 1455 additions and 5681 deletions

View File

@@ -1,24 +1,9 @@
from datetime import datetime, time
from decimal import Decimal
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Union)
from unittest.mock import MagicMock
from typing import Any, Dict, Iterator, Optional
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.views import LoginView
from django.contrib.sites.requests import RequestSite
from django.core.paginator import Page, Paginator
from django.db.models.base import Model
from django.db.models.manager import Manager
from django.db.models.query import QuerySet
from django.forms.forms import BaseForm
from django.http.request import HttpRequest
from django.template.base import Origin, Template
from django.template.context import Context
from django.template.exceptions import TemplateDoesNotExist
from django.utils.safestring import SafeText
from django.views.generic.base import TemplateResponseMixin
from django.views.generic.list import ListView
from .base import BaseEngine
@@ -29,25 +14,7 @@ class DjangoTemplates(BaseEngine):
name: str
app_dirname: str = ...
engine: django.template.engine.Engine = ...
def __init__(
self,
params: Union[
Dict[str, Union[Dict[str, Dict[str, str]], List[Any], bool, str]],
Dict[
str,
Union[
Dict[str, List[Tuple[str, Dict[str, str]]]],
List[Any],
bool,
str,
],
],
Dict[str, Union[Dict[str, List[str]], List[str], bool, str]],
Dict[str, Union[Dict[str, Tuple[str]], List[str], bool, str]],
Dict[str, Union[Dict[str, bool], List[Any], bool, str]],
Dict[str, Union[Dict[str, str], List[Any], bool, str]],
],
) -> None: ...
def __init__(self, params: Dict[str, Any]) -> None: ...
def from_string(self, template_code: str) -> Template: ...
def get_template(self, template_name: str) -> Template: ...
def get_templatetag_libraries(
@@ -63,829 +30,7 @@ class Template:
@property
def origin(self) -> Origin: ...
def render(
self,
context: Optional[
Union[
Dict[str, Any],
Dict[
str,
Dict[
str,
Optional[
Union[Dict[str, Union[bool, float, str]], bool, str]
],
],
],
Dict[
str,
Dict[
str,
Optional[
Union[
Dict[str, Union[Decimal, int, str]],
List[
Union[
Dict[
str,
Optional[
Union[
Dict[str, Union[bool, str]],
List[
Dict[
str,
Optional[
Union[
Dict[
str,
Union[
bool,
str,
],
],
bool,
str,
]
],
]
],
bool,
str,
]
],
],
Dict[
str,
Union[
Dict[str, Union[bool, str]],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[
Any, Any
],
bool,
str,
],
]
],
int,
]
],
bool,
str,
],
],
]
],
bool,
str,
]
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[Any, Any],
List[
Tuple[
List[
Dict[
str,
Union[Dict[Any, Any], bool, str],
]
],
int,
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[Any, Any],
List[
Union[
Dict[
str,
Union[
Dict[Any, Any],
List[
Dict[
str,
Union[
Dict[Any, Any],
bool,
str,
],
]
],
bool,
str,
],
],
Dict[
str,
Union[
Dict[str, bool],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, bool],
bool,
str,
],
]
],
int,
]
],
List[str],
bool,
str,
],
],
]
],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[Any, Any],
List[
Union[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[Any, Any], bool, str
],
]
],
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[str, bool], bool, str
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, Union[bool, str]],
List[
Union[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
List[
Dict[
str,
Union[
Dict[
str,
Union[bool, str],
],
bool,
str,
],
]
],
bool,
str,
],
],
Dict[
str,
Union[
Dict[str, Union[bool, str]],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, bool],
bool,
str,
],
]
],
int,
]
],
List[str],
bool,
str,
],
],
]
],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, Union[bool, str]],
List[
Union[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, bool], bool, str
],
]
],
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[Any, Any], bool, str
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, Union[int, str]],
List[
Dict[
str,
Union[
Dict[str, Union[bool, str]], bool, str
],
]
],
int,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, Union[int, str]],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[Any, Any], time, int, str
],
]
],
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, Union[int, str]],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, bool],
Set[str],
int,
str,
],
]
],
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, bool],
List[
Tuple[
List[
Dict[
str,
Union[Dict[str, bool], bool, str],
]
],
int,
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[Dict[str, Union[Dict[str, str], bool, str]]],
List[int],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[
Tuple[
None,
List[
Dict[
str, Union[Dict[str, str], int, str]
]
],
int,
]
],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[
Union[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, str], bool, str
],
]
],
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
bool,
str,
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
],
Dict[
str, Optional[Union[List[Dict[str, str]], bool, ListView]]
],
Dict[str, Optional[str]],
Dict[str, Union[Callable, int]],
Dict[
str,
Union[
Dict[
str,
Optional[
Union[
Dict[Any, Any],
List[
Dict[
str,
Optional[
Union[Dict[Any, Any], bool, str]
],
]
],
bool,
str,
]
],
],
List[Dict[str, Optional[Union[datetime, Model, str]]]],
],
],
Dict[
str,
Union[
Dict[
str,
Optional[
Union[
Dict[str, Union[bool, str]],
List[
Dict[
str,
Optional[
Union[
Dict[str, Union[bool, str]],
bool,
str,
]
],
]
],
bool,
str,
]
],
],
str,
],
],
Dict[
str,
Union[
Dict[
str,
Optional[
Union[
Dict[str, Union[bool, str]],
List[
Dict[
str,
Optional[
Union[Dict[str, str], bool, str]
],
]
],
int,
str,
]
],
],
TemplateResponseMixin,
],
],
Dict[
str,
Union[
Dict[
str,
Optional[
Union[
Dict[str, str],
List[
Dict[
str,
Optional[
Union[Dict[str, str], bool, str]
],
]
],
bool,
str,
]
],
],
str,
],
],
Dict[
str,
Union[
Dict[str, Optional[Union[Dict[str, str], bool, str]]],
List[Dict[str, str]],
],
],
Dict[
str,
Union[
Dict[
str,
Union[
Dict[Any, Any],
List[
Dict[
str,
Union[
Dict[Any, Any],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, bool],
bool,
str,
],
]
],
int,
]
],
List[str],
bool,
str,
],
]
],
List[str],
bool,
str,
],
],
str,
],
],
Dict[
str,
Union[
Dict[
str,
Union[
Dict[Any, Any],
List[
Dict[str, Union[Dict[str, str], bool, str]]
],
bool,
str,
],
],
str,
],
],
Dict[
str,
Union[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
List[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
bool,
str,
],
]
],
bool,
str,
],
],
str,
],
],
Dict[
str,
Union[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
int,
str,
],
]
],
int,
]
],
List[str],
bool,
str,
],
],
str,
],
],
Dict[
str,
Union[
Dict[
str,
Union[
Dict[str, str],
List[
Dict[str, Union[Dict[str, str], bool, str]]
],
List[str],
bool,
str,
],
],
str,
],
],
Dict[
str,
Union[
Dict[
str,
Union[
Dict[str, str],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, str], bool, str
],
]
],
int,
]
],
bool,
str,
],
],
str,
],
],
Dict[
str,
Union[
Dict[
str,
Union[
Dict[str, str],
List[
Union[
Tuple[
List[
Dict[
str,
Union[
Dict[str, str],
bool,
str,
],
]
],
int,
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[
str,
Union[bool, str],
],
bool,
str,
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
List[Dict[str, str]],
],
],
Dict[
str,
Union[
List[Dict[str, str]], bool, Page, Paginator, ListView
],
],
Dict[str, Union[List[str], str]],
Dict[str, Union[bool, str]],
Dict[
str, Union[AuthenticationForm, LoginView, RequestSite, str]
],
Dict[str, Union[Model, BaseForm, TemplateResponseMixin, str]],
Dict[str, Union[Manager, QuerySet]],
Dict[str, Template],
Context,
MagicMock,
]
] = ...,
request: Optional[HttpRequest] = ...,
self, context: Any = ..., request: Optional[HttpRequest] = ...
) -> SafeText: ...
def copy_exception(

View File

@@ -52,7 +52,7 @@ class Template:
Dict[
str,
Optional[
Union[Dict[Any, Any], bool, str]
Union[Dict[str, str], bool, str]
],
]
],
@@ -67,12 +67,36 @@ class Template:
Dict[
str,
Union[
Dict[Any, Any],
Dict[str, int],
List[
Tuple[
Optional[str],
List[
Dict[
str,
Union[Dict[str, bool], bool, str],
]
],
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[
Dict[
str,
Union[
Dict[Any, Any],
Dict[str, str],
List[
Tuple[
None,
@@ -101,215 +125,6 @@ class Template:
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[Any, Any],
List[
Tuple[
List[
Dict[
str,
Union[Dict[Any, Any], bool, str],
]
],
int,
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[Any, Any],
List[
Union[
Dict[
str,
Union[
Dict[Any, Any],
List[
Dict[
str,
Union[
Dict[Any, Any],
bool,
str,
],
]
],
bool,
str,
],
],
Dict[
str,
Union[
Dict[str, bool],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, bool],
bool,
str,
],
]
],
int,
]
],
List[str],
bool,
str,
],
],
]
],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[Any, Any],
List[
Union[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, bool], bool, str
],
]
],
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[Any, Any], bool, str
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, bool],
List[
Tuple[
List[
Dict[
str,
Union[Dict[str, bool], bool, str],
]
],
int,
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, bool],
List[
Tuple[
None,
List[
Dict[
str,
Union[Dict[str, bool], int, str],
]
],
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, int],
List[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[Any, Any], time, int, str
],
]
],
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[Dict[str, Union[Dict[str, str], bool, str]]],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
@@ -318,13 +133,14 @@ class Template:
Dict[str, str],
List[
Tuple[
None,
Optional[str],
List[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
bool,
time,
int,
str,
],
]
@@ -338,154 +154,6 @@ class Template:
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[
Tuple[
None,
List[
Dict[
str,
Union[Dict[str, bool], int, str],
]
],
int,
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[
Union[
Tuple[
List[
Dict[
str,
Union[
Dict[str, str], bool, str
],
]
],
int,
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
bool,
str,
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[
Union[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[Any, Any], bool, str
],
]
],
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[str, bool], bool, str
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
],
Dict[
str,
Dict[
str,
Union[
Dict[str, str],
List[
Union[
Tuple[
None,
List[
Dict[
str,
Union[
Dict[str, str], bool, str
],
]
],
int,
],
Tuple[
str,
List[
Dict[
str,
Union[
Dict[str, Union[bool, str]],
bool,
str,
],
]
],
int,
],
]
],
List[str],
bool,
str,
],
],
],
Dict[str, TemplateView],
Dict[str, str],
]

View File

@@ -35,11 +35,9 @@ class TokenType(Enum):
class VariableDoesNotExist(Exception):
msg: str = ...
params: Union[Tuple[Dict[str, str]], Tuple[str, Any]] = ...
params: Tuple[Union[Dict[str, str], str]] = ...
def __init__(
self,
msg: str,
params: Union[Tuple[Dict[str, str]], Tuple[str, Any]] = ...,
self, msg: str, params: Tuple[Union[Dict[str, str], str]] = ...
) -> None: ...
class Origin:
@@ -158,10 +156,14 @@ class FilterExpression:
filters: List[
Tuple[
Callable,
Union[
List[Any],
List[Tuple[bool, django.template.base.Variable]],
List[Tuple[bool, django.utils.safestring.SafeText]],
List[
Tuple[
bool,
Union[
django.template.base.Variable,
django.utils.safestring.SafeText,
],
]
],
]
] = ...
@@ -191,11 +193,7 @@ class Variable:
def resolve(
self,
context: Union[
Dict[str, Dict[str, Union[int, str]]],
Dict[str, Union[int, str]],
Context,
int,
str,
Dict[str, Dict[str, Union[int, str]]], Context, int, str
],
) -> Any: ...

View File

@@ -1,18 +1,22 @@
from itertools import cycle
from typing import Any, Dict, Iterator, List, Optional, Union
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, Union
from django.contrib.admin.templatetags.base import InclusionAdminNode
from django.core.handlers.wsgi import WSGIRequest
from django.contrib.admin.templatetags.admin_list import ResultList
from django.contrib.admin.views.main import ChangeList
from django.db.models.base import Model
from django.db.models.options import Options
from django.forms.boundfield import BoundField
from django.http.request import HttpRequest
from django.template.base import Node, Origin, Template
from django.template.defaulttags import CycleNode
from django.template.defaulttags import CycleNode, IfChangedNode
from django.template.library import InclusionNode
from django.template.loader_tags import BlockContext
from django.utils.functional import SimpleLazyObject
class ContextPopException(Exception): ...
class ContextDict(dict):
context: Any = ...
context: django.template.context.BaseContext = ...
def __init__(
self, context: BaseContext, *args: Any, **kwargs: Any
) -> None: ...
@@ -25,26 +29,51 @@ class BaseContext:
def __iter__(self) -> None: ...
def push(self, *args: Any, **kwargs: Any) -> ContextDict: ...
def pop(self) -> ContextDict: ...
def __setitem__(self, key: Union[str, Node], value: Any) -> None: ...
def set_upward(self, key: Any, value: Any) -> None: ...
def __getitem__(self, key: str) -> Any: ...
def __setitem__(self, key: Union[Node, str], value: Any) -> None: ...
def set_upward(self, key: str, value: Union[int, str]) -> None: ...
def __getitem__(self, key: Union[int, str]) -> Any: ...
def __delitem__(self, key: Any) -> None: ...
def __contains__(self, key: str) -> bool: ...
def get(
self, key: str, otherwise: Optional[int] = ...
) -> Union[SimpleLazyObject, int]: ...
) -> Optional[Union[Options, int, str]]: ...
def setdefault(
self, key: str, default: List[Origin] = ...
) -> List[Origin]: ...
def new(self, values: Any = ...) -> RequestContext: ...
def flatten(self): ...
def __eq__(self, other: Any): ...
self,
key: Union[IfChangedNode, str],
default: Optional[Union[List[Origin], int]] = ...,
) -> Optional[Union[List[Origin], int]]: ...
def new(
self,
values: Optional[
Union[
Dict[
str,
Union[
List[Dict[str, Union[int, str]]],
List[ResultList],
List[BoundField],
ChangeList,
int,
],
],
Dict[str, Union[List[Dict[str, str]], ChangeList, int, str]],
Dict[str, Union[ChangeList, int, range, str]],
Context,
]
] = ...,
) -> Context: ...
def flatten(
self
) -> Dict[
str, Optional[Union[Dict[str, Union[Type[Any], str]], int, str]]
]: ...
def __eq__(self, other: Context) -> bool: ...
class Context(BaseContext):
dicts: List
dicts: Any
autoescape: bool = ...
use_l10n: Optional[bool] = ...
use_tz: None = ...
use_tz: Optional[bool] = ...
template_name: Optional[str] = ...
render_context: django.template.context.RenderContext = ...
template: Optional[django.template.base.Template] = ...
@@ -52,54 +81,36 @@ class Context(BaseContext):
self,
dict_: Any = ...,
autoescape: bool = ...,
use_l10n: None = ...,
use_l10n: Optional[bool] = ...,
use_tz: None = ...,
) -> None: ...
def bind_template(self, template: Template) -> Iterator[None]: ...
def __copy__(self) -> Context: ...
def update(self, other_dict: Dict[str, Any]) -> ContextDict: ...
def update(
self,
other_dict: Union[
Dict[str, Model], Dict[str, int], Dict[str, str], Context
],
) -> ContextDict: ...
class RenderContext(BaseContext):
dicts: Union[
List[
Dict[
Union[str, django.template.loader_tags.IncludeNode],
Union[bool, None, Dict[str, django.template.base.Template]],
]
],
List[
Union[
Dict[
Union[str, django.template.loader_tags.IncludeNode],
Union[bool, None, Dict[Any, Any]],
],
django.template.context.ContextDict,
]
],
List[
Union[
Dict[str, Union[bool, None]],
Dict[str, str],
django.template.context.ContextDict,
]
],
]
dicts: List[Dict[Union[django.template.loader_tags.IncludeNode, str], str]]
template: Optional[django.template.base.Template] = ...
def __iter__(self) -> None: ...
def __contains__(self, key: Union[str, CycleNode]) -> bool: ...
def __contains__(self, key: Union[CycleNode, str]) -> bool: ...
def get(
self, key: Union[str, InclusionAdminNode], otherwise: None = ...
) -> Optional[Union[BlockContext, Template]]: ...
self, key: Union[InclusionNode, str], otherwise: None = ...
) -> Optional[Union[Template, BlockContext]]: ...
def __getitem__(
self, key: Union[str, CycleNode]
) -> Union[List[Origin], BlockContext, cycle]: ...
self, key: Union[Node, str]
) -> Optional[Union[List[Origin], BlockContext, cycle]]: ...
def push_state(
self, template: Template, isolated_context: bool = ...
) -> Iterator[None]: ...
class RequestContext(Context):
autoescape: bool
dicts: List
dicts: List[Dict[str, str]]
render_context: django.template.context.RenderContext
template_name: Optional[str]
use_l10n: None
@@ -107,17 +118,39 @@ class RequestContext(Context):
request: django.http.request.HttpRequest = ...
def __init__(
self,
request: WSGIRequest,
dict_: None = ...,
processors: None = ...,
request: HttpRequest,
dict_: Optional[
Dict[str, Union[Dict[str, Union[Type[Any], str]], str]]
] = ...,
processors: Optional[List[Callable]] = ...,
use_l10n: None = ...,
use_tz: None = ...,
autoescape: bool = ...,
) -> None: ...
template: Optional[django.template.base.Template] = ...
def bind_template(self, template: Template) -> Iterator[None]: ...
def new(self, values: Any = ...) -> RequestContext: ...
def new(
self,
values: Optional[
Union[
Dict[str, Union[Dict[str, str], List[Dict[str, str]], bool]],
Dict[str, Union[List[Any], ChangeList, int, str]],
Dict[
str,
Union[
List[Dict[str, Optional[Union[int, str]]]],
List[ResultList],
List[BoundField],
ChangeList,
int,
],
],
Dict[str, Union[ChangeList, int, range, str]],
Context,
]
] = ...,
) -> RequestContext: ...
def make_context(
context: Dict[str, Any], request: Optional[WSGIRequest] = ..., **kwargs: Any
context: Any, request: Optional[HttpRequest] = ..., **kwargs: Any
) -> Context: ...

View File

@@ -1,8 +1,7 @@
from datetime import date, time, timedelta
from datetime import date, datetime, timedelta
from decimal import Decimal
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
from django.db.models.query import QuerySet
from django.utils.safestring import SafeText
from .base import Variable, VariableDoesNotExist
@@ -52,7 +51,7 @@ def dictsort(
value: Union[
Dict[str, int],
List[Dict[str, Dict[str, Union[int, str]]]],
List[Dict[str, Union[int, str]]],
List[Dict[str, str]],
List[Tuple[str, str]],
List[int],
int,
@@ -61,7 +60,7 @@ def dictsort(
arg: Union[int, str],
) -> Union[
List[Dict[str, Dict[str, Union[int, str]]]],
List[Dict[str, Union[int, str]]],
List[Dict[str, str]],
List[Tuple[str, str]],
str,
]: ...
@@ -79,21 +78,17 @@ def dictsortreversed(
def first(value: Union[List[int], List[str], str]) -> Union[int, str]: ...
def join(value: Any, arg: str, autoescape: bool = ...) -> Any: ...
def last(value: List[str]) -> str: ...
def length(
value: Optional[
Union[
List[Optional[Union[Dict[Any, Any], int, str]]], QuerySet, int, str
]
]
) -> int: ...
def length_is(value: Any, arg: Union[SafeText, int]) -> Union[bool, str]: ...
def length(value: Any) -> int: ...
def length_is(
value: Optional[Union[List[Callable], Tuple[str, str], int, str]],
arg: Union[SafeText, int],
) -> Union[bool, str]: ...
def random(value: List[str]) -> str: ...
def slice_filter(value: Any, arg: str) -> Any: ...
def unordered_list(
value: Union[
Iterator[Any],
List[Union[List[Union[List[Union[List[str], str]], str]], str]],
List[Union[List[Union[List[str], str]], str]],
],
autoescape: bool = ...,
) -> SafeText: ...
@@ -103,10 +98,10 @@ def add(
) -> Union[List[int], Tuple[int, int, int, int], date, int, str]: ...
def get_digit(value: Union[int, str], arg: int) -> Union[int, str]: ...
def date(
value: Optional[Union[date, time, str]], arg: Optional[str] = ...
value: Optional[Union[datetime, str]], arg: Optional[str] = ...
) -> str: ...
def time(
value: Optional[Union[date, time, str]], arg: Optional[str] = ...
value: Optional[Union[datetime, str]], arg: Optional[str] = ...
) -> str: ...
def timesince_filter(
value: Optional[date], arg: Optional[date] = ...

View File

@@ -84,15 +84,15 @@ class ForNode(Node):
token: django.template.base.Token
child_nodelists: Any = ...
is_reversed: bool = ...
nodelist_loop: List[str] = ...
nodelist_empty: List[str] = ...
nodelist_loop: Union[List[str], django.template.base.NodeList] = ...
nodelist_empty: Union[List[str], django.template.base.NodeList] = ...
def __init__(
self,
loopvars: Union[List[str], str],
sequence: Union[FilterExpression, str],
is_reversed: bool,
nodelist_loop: List[str],
nodelist_empty: Optional[List[str]] = ...,
nodelist_loop: Union[List[str], NodeList],
nodelist_empty: Optional[Union[List[str], NodeList]] = ...,
) -> None: ...
def render(self, context: Context) -> SafeText: ...
@@ -108,8 +108,8 @@ class IfChangedNode(Node):
def render(self, context: Context) -> str: ...
class IfEqualNode(Node):
nodelist_false: List[Any]
nodelist_true: List[Any]
nodelist_false: Union[List[Any], django.template.base.NodeList]
nodelist_true: Union[List[Any], django.template.base.NodeList]
origin: django.template.base.Origin
token: django.template.base.Token
var1: Union[django.template.base.FilterExpression, str]
@@ -120,8 +120,8 @@ class IfEqualNode(Node):
self,
var1: Union[FilterExpression, str],
var2: Union[FilterExpression, str],
nodelist_true: List[Any],
nodelist_false: List[Any],
nodelist_true: Union[List[Any], NodeList],
nodelist_false: Union[List[Any], NodeList],
negate: bool,
) -> None: ...
def render(self, context: Context) -> SafeText: ...
@@ -130,10 +130,14 @@ class IfNode(Node):
origin: django.template.base.Origin
token: django.template.base.Token
conditions_nodelists: List[
Tuple[django.template.base.NodeList, django.template.base.NodeList]
Tuple[
Optional[django.template.defaulttags.TemplateLiteral],
django.template.base.NodeList,
]
] = ...
def __init__(
self, conditions_nodelists: List[Tuple[NodeList, NodeList]]
self,
conditions_nodelists: List[Tuple[Optional[TemplateLiteral], NodeList]],
) -> None: ...
def __iter__(self) -> None: ...
@property
@@ -166,13 +170,7 @@ class RegroupNode(Node):
var_name: str,
) -> None: ...
def resolve_expression(
self,
obj: Union[
Dict[str, Union[List[str], str]],
Dict[str, Union[int, str]],
Dict[str, date],
],
context: Context,
self, obj: Dict[str, date], context: Context
) -> Union[int, str]: ...
def render(self, context: Context) -> str: ...
@@ -255,15 +253,15 @@ class WidthRatioNode(Node):
class WithNode(Node):
origin: django.template.base.Origin
token: django.template.base.Token
nodelist: List[Any] = ...
extra_context: Union[
Dict[str, django.template.base.FilterExpression], Dict[str, str]
nodelist: Union[List[Any], django.template.base.NodeList] = ...
extra_context: Dict[
str, Union[django.template.base.FilterExpression, str]
] = ...
def __init__(
self,
var: Optional[str],
name: Optional[str],
nodelist: List[Any],
nodelist: Union[List[Any], NodeList],
extra_context: Optional[Dict[str, FilterExpression]] = ...,
) -> None: ...
def render(self, context: Context) -> Any: ...

View File

@@ -1,4 +1,3 @@
from datetime import date, time, timedelta
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from django.template.base import Origin, Template
@@ -23,19 +22,8 @@ class Engine:
debug: bool = ...
loaders: Union[
List[List[Union[Dict[str, str], str]]],
List[
Union[
Tuple[
str,
Union[
Dict[str, str],
List[Tuple[str, Dict[str, str]]],
List[str],
],
],
str,
]
],
List[Tuple[str, List[str]]],
List[str],
] = ...
string_if_invalid: str = ...
file_charset: str = ...
@@ -52,19 +40,8 @@ class Engine:
loaders: Optional[
Union[
List[List[Union[Dict[str, str], str]]],
List[
Union[
Tuple[
str,
Union[
Dict[str, str],
List[Tuple[str, Dict[str, str]]],
List[str],
],
],
str,
]
],
List[Tuple[str, List[str]]],
List[str],
]
] = ...,
string_if_invalid: str = ...,
@@ -85,32 +62,14 @@ class Engine:
self,
template_loaders: Union[
List[List[Union[Dict[str, str], str]]],
List[
Union[
Tuple[
str,
Union[
Dict[str, str],
List[Tuple[str, Dict[str, str]]],
List[str],
],
],
str,
]
],
List[Tuple[str, List[str]]],
List[str],
],
) -> List[Loader]: ...
def find_template_loader(
self,
loader: Union[
List[Union[Dict[str, str], str]],
Tuple[
str,
Union[
Dict[str, str], List[Tuple[str, Dict[str, str]]], List[str]
],
],
str,
List[Union[Dict[str, str], str]], Tuple[str, List[str]], str
],
) -> Loader: ...
def find_template(
@@ -119,62 +78,6 @@ class Engine:
def from_string(self, template_code: str) -> Template: ...
def get_template(self, template_name: str) -> Template: ...
def render_to_string(
self,
template_name: str,
context: Optional[
Union[
Dict[str, Callable],
Dict[str, Dict[Union[int, str], str]],
Dict[str, Dict[str, Callable]],
Dict[str, Dict[str, Dict[str, str]]],
Dict[str, Dict[str, List[Tuple[str, int]]]],
Dict[str, Dict[str, Tuple[str, str, str, str]]],
Dict[str, List[Dict[str, Union[List[int], int]]]],
Dict[str, List[Dict[str, Union[int, str]]]],
Dict[str, List[List[Tuple[int, str]]]],
Dict[str, List[Union[List[SafeText], str]]],
Dict[str, List[Template]],
Dict[str, Optional[int]],
Dict[str, Optional[str]],
Dict[
str, Tuple[Dict[str, str], Dict[str, str], Dict[str, str]]
],
Dict[
str,
Tuple[
Tuple[str, Union[int, str]], Tuple[str, Union[int, str]]
],
],
Dict[str, Tuple[int, int]],
Dict[str, Tuple[str, str]],
Dict[str, Union[Dict[str, int], List[Union[List[str], str]]]],
Dict[str, Union[Dict[str, int], str]],
Dict[
str,
Union[
List[
Optional[
Union[
Dict[str, Union[List[str], str]], int, str
]
]
],
str,
],
],
Dict[
str,
Union[
List[Optional[Union[Dict[str, date], int, str]]], int
],
],
Dict[str, Union[date, timedelta]],
Dict[str, Union[int, str]],
Dict[str, time],
Dict[str, Template],
Dict[str, float],
Dict[str, range],
]
] = ...,
self, template_name: str, context: Any = ...
) -> SafeText: ...
def select_template(self, template_name_list: List[str]) -> Template: ...

View File

@@ -55,10 +55,7 @@ class TagHelperNode(Node):
) -> None: ...
def get_resolved_arguments(
self, context: Context
) -> Tuple[
Union[Dict[str, Union[SafeText, int]], List[Union[Context, int]]],
Union[Dict[Any, Any], Dict[str, Union[SafeText, int]], Dict[str, int]],
]: ...
) -> Tuple[List[int], Dict[str, Union[SafeText, int]]]: ...
class SimpleNode(TagHelperNode):
args: List[django.template.base.FilterExpression]
@@ -102,7 +99,7 @@ def parse_bits(
params: List[str],
varargs: Optional[str],
varkw: Optional[str],
defaults: Optional[Union[Tuple[bool, None], Tuple[str]]],
defaults: Optional[Tuple[Union[bool, str]]],
kwonly: List[str],
kwonly_defaults: Optional[Dict[str, int]],
takes_context: Optional[bool],

View File

@@ -1,10 +1,6 @@
from typing import Any, Dict, List, Optional, Union
from django.contrib.auth.base_user import AbstractBaseUser
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.manager import Manager
from django.db.models.query import QuerySet
from django.forms.forms import Form
from django.template.backends.django import Template
from django.template.backends.dummy import Template
from django.template.backends.jinja2 import Template
@@ -20,15 +16,7 @@ def select_template(
) -> Union[Template, Template, Template]: ...
def render_to_string(
template_name: Union[List[str], str],
context: Optional[
Union[
Dict[str, Optional[str]],
Dict[str, Union[AbstractBaseUser, str]],
Dict[str, Union[Manager, QuerySet]],
Dict[str, Union[Form, str]],
Dict[str, bool],
]
] = ...,
context: Optional[Union[Dict[str, bool], Dict[str, str]]] = ...,
request: Optional[WSGIRequest] = ...,
using: Optional[str] = ...,
) -> str: ...

View File

@@ -9,21 +9,8 @@ from .base import Loader as BaseLoader
class Loader(BaseLoader):
engine: django.template.engine.Engine
template_cache: Dict[Any, Any] = ...
get_template_cache: Union[
Dict[
str,
Union[
Type[django.template.exceptions.TemplateDoesNotExist],
django.template.base.Template,
],
],
Dict[
str,
Union[
django.template.base.Template,
django.template.exceptions.TemplateDoesNotExist,
],
],
get_template_cache: Dict[
str, django.template.exceptions.TemplateDoesNotExist
] = ...
loaders: List[django.template.loaders.base.Loader] = ...
def __init__(

View File

@@ -1,20 +1,14 @@
from datetime import datetime
from http.cookies import SimpleCookie
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from unittest.mock import MagicMock
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.views import LoginView
from django.contrib.sites.requests import RequestSite
from django.core.paginator import Page, Paginator
from django.db.models.base import Model
from django.forms.forms import BaseForm
from django.http import HttpResponse
from django.http.request import HttpRequest
from django.template.backends.django import Template
from django.template.backends.jinja2 import Template
from django.views.generic.base import TemplateResponseMixin
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from .loader import get_template, select_template
@@ -29,42 +23,20 @@ class SimpleTemplateResponse(HttpResponse):
template_name: Union[
List[str], django.template.backends.django.Template, str
] = ...
context_data: Optional[
Union[Dict[str, Union[Callable, int]], Dict[str, str]]
] = ...
context_data: Optional[Dict[str, str]] = ...
using: Optional[str] = ...
def __init__(
self,
template: Union[List[str], Template, str],
context: Optional[
Union[
Dict[str, Any],
Dict[str, List[Dict[str, Any]]],
Dict[
str,
Optional[
Union[
List[
Dict[str, Optional[Union[datetime, Model, str]]]
],
bool,
ListView,
]
],
str, List[Dict[str, Optional[Union[datetime, Model, str]]]]
],
Dict[str, Union[Callable, int]],
Dict[str, Union[Dict[str, str], DetailView]],
Dict[
str,
Union[
List[Dict[str, str]], bool, Page, Paginator, ListView
],
],
Dict[str, Union[List[str], str]],
Dict[
str, Union[AuthenticationForm, LoginView, RequestSite, str]
],
Dict[str, Union[Model, BaseForm, TemplateResponseMixin, str]],
Dict[str, List[str]],
Dict[str, Model],
Dict[str, TemplateResponseMixin],
Dict[str, str],
MagicMock,
]
] = ...,
@@ -80,59 +52,23 @@ class SimpleTemplateResponse(HttpResponse):
self,
context: Optional[
Union[
Dict[str, Any],
Dict[str, List[Dict[str, Any]]],
Dict[
str,
Optional[
Union[
List[
Dict[str, Optional[Union[datetime, Model, str]]]
],
bool,
ListView,
]
],
str, List[Dict[str, Optional[Union[datetime, Model, str]]]]
],
Dict[str, Union[Callable, int]],
Dict[str, Union[Dict[str, str], DetailView]],
Dict[
str,
Union[
List[Dict[str, str]], bool, Page, Paginator, ListView
],
],
Dict[str, Union[List[str], str]],
Dict[
str, Union[AuthenticationForm, LoginView, RequestSite, str]
],
Dict[str, Union[Model, BaseForm, TemplateResponseMixin, str]],
Dict[str, List[str]],
Dict[str, Model],
Dict[str, TemplateResponseMixin],
Dict[str, str],
MagicMock,
]
],
) -> Optional[
Union[
Dict[str, Any],
Dict[str, List[Dict[str, Any]]],
Dict[
str,
Optional[
Union[
List[Dict[str, Optional[Union[datetime, Model, str]]]],
bool,
ListView,
]
],
],
Dict[str, Union[Callable, int]],
Dict[str, Union[Dict[str, str], DetailView]],
Dict[
str,
Union[List[Dict[str, str]], bool, Page, Paginator, ListView],
],
Dict[str, Union[List[str], str]],
Dict[str, Union[AuthenticationForm, LoginView, RequestSite, str]],
Dict[str, Union[Model, BaseForm, TemplateResponseMixin, str]],
Dict[str, List[Dict[str, Optional[Union[datetime, Model, str]]]]],
Dict[str, List[str]],
Dict[str, Model],
Dict[str, TemplateResponseMixin],
Dict[str, str],
MagicMock,
]
]: ...
@@ -155,63 +91,25 @@ class TemplateResponse(SimpleTemplateResponse):
context: django.template.context.RequestContext
context_data: Optional[
Union[
Dict[str, Any],
Dict[str, List[Dict[str, Any]]],
Dict[
str,
Optional[
Union[
List[
Dict[
List[
Dict[
str,
Optional[
Union[
datetime.datetime,
django.db.models.base.Model,
str,
Optional[
Union[
datetime.datetime,
django.db.models.base.Model,
str,
]
],
]
],
bool,
django.views.generic.list.ListView,
]
],
],
Dict[str, Union[Callable, int]],
Dict[
str,
Union[Dict[str, str], django.views.generic.detail.DetailView],
],
Dict[
str,
Union[
List[Dict[str, str]],
bool,
django.core.paginator.Page,
django.core.paginator.Paginator,
django.views.generic.list.ListView,
],
],
Dict[str, Union[List[str], str]],
Dict[
str,
Union[
django.contrib.auth.forms.AuthenticationForm,
django.contrib.auth.views.LoginView,
django.contrib.sites.requests.RequestSite,
str,
],
],
Dict[
str,
Union[
django.db.models.base.Model,
django.forms.forms.BaseForm,
django.views.generic.base.TemplateResponseMixin,
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,
]
]
@@ -235,33 +133,13 @@ class TemplateResponse(SimpleTemplateResponse):
template: Union[List[str], Template, str],
context: Optional[
Union[
Dict[str, Any],
Dict[str, List[Dict[str, Any]]],
Dict[
str,
Optional[
Union[
List[
Dict[str, Optional[Union[datetime, Model, str]]]
],
bool,
ListView,
]
],
str, List[Dict[str, Optional[Union[datetime, Model, str]]]]
],
Dict[str, Union[Callable, int]],
Dict[str, Union[Dict[str, str], DetailView]],
Dict[
str,
Union[
List[Dict[str, str]], bool, Page, Paginator, ListView
],
],
Dict[str, Union[List[str], str]],
Dict[
str, Union[AuthenticationForm, LoginView, RequestSite, str]
],
Dict[str, Union[Model, BaseForm, TemplateResponseMixin, str]],
Dict[str, List[str]],
Dict[str, Model],
Dict[str, TemplateResponseMixin],
Dict[str, str],
MagicMock,
]
] = ...,