django.template cleanups

This commit is contained in:
Maxim Kurnikov
2018-12-22 04:25:22 +03:00
parent e9cd2b6b62
commit 59b8008a21
2 changed files with 27 additions and 17 deletions

View File

@@ -0,0 +1,14 @@
from .engine import Engine as Engine
from .utils import EngineHandler as EngineHandler
engines: EngineHandler
from .base import VariableDoesNotExist as VariableDoesNotExist
from .context import ContextPopException as ContextPopException
from .exceptions import TemplateDoesNotExist as TemplateDoesNotExist, TemplateSyntaxError as TemplateSyntaxError
# Template parts
from .base import Node as Node, NodeList as NodeList, Origin as Origin, Template as Template, Variable as Variable
from .context import Context as Context, RequestContext as RequestContext
from .library import Library as Library

View File

@@ -8,8 +8,6 @@ from django.template.library import Library
from django.template.loaders.base import Loader from django.template.loaders.base import Loader
from django.utils.safestring import SafeText from django.utils.safestring import SafeText
from .exceptions import TemplateSyntaxError
FILTER_SEPARATOR: str FILTER_SEPARATOR: str
FILTER_ARGUMENT_SEPARATOR: str FILTER_ARGUMENT_SEPARATOR: str
VARIABLE_ATTRIBUTE_SEPARATOR: str VARIABLE_ATTRIBUTE_SEPARATOR: str
@@ -53,7 +51,7 @@ class Origin:
class Template: class Template:
name: Optional[str] = ... name: Optional[str] = ...
origin: django.template.base.Origin = ... origin: Origin = ...
engine: django.template.engine.Engine = ... engine: django.template.engine.Engine = ...
source: str = ... source: str = ...
nodelist: django.template.base.NodeList = ... nodelist: django.template.base.NodeList = ...
@@ -75,7 +73,7 @@ def linebreak_iter(template_source: str) -> Iterator[int]: ...
class Token: class Token:
contents: str contents: str
token_type: django.template.base.TokenType token_type: TokenType
lineno: Optional[int] = ... lineno: Optional[int] = ...
position: Optional[Tuple[int, int]] = ... position: Optional[Tuple[int, int]] = ...
def __init__( def __init__(
@@ -102,12 +100,12 @@ class DebugLexer(Lexer):
def tokenize(self) -> List[Token]: ... def tokenize(self) -> List[Token]: ...
class Parser: class Parser:
tokens: Union[List[django.template.base.Token], str] = ... tokens: Union[List[Token], str] = ...
tags: Dict[str, Callable] = ... tags: Dict[str, Callable] = ...
filters: Dict[str, Callable] = ... filters: Dict[str, Callable] = ...
command_stack: List[Tuple[str, django.template.base.Token]] = ... command_stack: List[Tuple[str, Token]] = ...
libraries: Dict[str, django.template.library.Library] = ... libraries: Dict[str, Library] = ...
origin: Optional[django.template.base.Origin] = ... origin: Optional[Origin] = ...
def __init__( def __init__(
self, self,
tokens: Union[List[Token], str], tokens: Union[List[Token], str],
@@ -134,10 +132,8 @@ filter_re: Any
class FilterExpression: class FilterExpression:
token: str = ... token: str = ...
filters: List[ filters: List[Tuple[Callable, List[Tuple[bool, Union[Variable, SafeText]]]]] = ...
Tuple[Callable, List[Tuple[bool, Union[django.template.base.Variable, django.utils.safestring.SafeText]]]] var: Union[Variable, SafeText] = ...
] = ...
var: Union[django.template.base.Variable, django.utils.safestring.SafeText] = ...
def __init__(self, token: str, parser: Parser) -> None: ... def __init__(self, token: str, parser: Parser) -> None: ...
def resolve(self, context: Union[Dict[str, Dict[str, str]], Context], ignore_failures: bool = ...) -> Any: ... def resolve(self, context: Union[Dict[str, Dict[str, str]], Context], ignore_failures: bool = ...) -> Any: ...
def args_check(name: str, func: Callable, provided: List[Tuple[bool, Union[Variable, SafeText]]]) -> bool: ... def args_check(name: str, func: Callable, provided: List[Tuple[bool, Union[Variable, SafeText]]]) -> bool: ...
@@ -145,7 +141,7 @@ class FilterExpression:
class Variable: class Variable:
var: Union[Dict[Any, Any], str] = ... var: Union[Dict[Any, Any], str] = ...
literal: Optional[Union[django.utils.safestring.SafeText, float]] = ... literal: Optional[Union[SafeText, float]] = ...
lookups: Optional[Tuple[str]] = ... lookups: Optional[Tuple[str]] = ...
translate: bool = ... translate: bool = ...
message_context: Optional[str] = ... message_context: Optional[str] = ...
@@ -167,8 +163,8 @@ class NodeList(list):
def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ...
class TextNode(Node): class TextNode(Node):
origin: django.template.base.Origin origin: Origin
token: django.template.base.Token token: Token
s: str = ... s: str = ...
def __init__(self, s: str) -> None: ... def __init__(self, s: str) -> None: ...
def render(self, context: Context) -> str: ... def render(self, context: Context) -> str: ...
@@ -176,8 +172,8 @@ class TextNode(Node):
def render_value_in_context(value: Any, context: Context) -> str: ... def render_value_in_context(value: Any, context: Context) -> str: ...
class VariableNode(Node): class VariableNode(Node):
origin: django.template.base.Origin origin: Origin
token: django.template.base.Token token: Token
filter_expression: django.template.base.FilterExpression = ... filter_expression: django.template.base.FilterExpression = ...
def __init__(self, filter_expression: FilterExpression) -> None: ... def __init__(self, filter_expression: FilterExpression) -> None: ...
def render(self, context: Context) -> str: ... def render(self, context: Context) -> str: ...