mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-09 05:24:53 +08:00
improved version
This commit is contained in:
@@ -26,7 +26,7 @@ from typing import (
|
||||
def linebreak_iter(template_source: str) -> Iterator[int]: ...
|
||||
|
||||
|
||||
def render_value_in_context(value: Any, context: Context) -> str: ...
|
||||
def render_value_in_context(value: object, context: Context) -> str: ...
|
||||
|
||||
|
||||
def token_kwargs(
|
||||
@@ -53,7 +53,7 @@ class FilterExpression:
|
||||
self,
|
||||
context: Union[Dict[str, Dict[str, str]], Context],
|
||||
ignore_failures: bool = ...
|
||||
) -> Any: ...
|
||||
) -> object: ...
|
||||
|
||||
|
||||
class Lexer:
|
||||
@@ -72,8 +72,8 @@ class Node:
|
||||
def get_nodes_by_type(
|
||||
self,
|
||||
nodetype: Type[Node]
|
||||
) -> Union[List[VariableNode], List[BlockNode], List[LoadNode], List[ExtendsNode]]: ...
|
||||
def render_annotated(self, context: Context) -> Union[str, int]: ...
|
||||
) -> Union[List[LoadNode], List[VariableNode], List[BlockNode], List[ExtendsNode]]: ...
|
||||
def render_annotated(self, context: Context) -> Union[int, str]: ...
|
||||
|
||||
|
||||
class NodeList:
|
||||
@@ -110,8 +110,8 @@ class Parser:
|
||||
def error(
|
||||
self,
|
||||
token: Token,
|
||||
e: Union[str, TemplateSyntaxError, RuntimeError]
|
||||
) -> Union[TemplateSyntaxError, RuntimeError]: ...
|
||||
e: Union[str, RuntimeError, TemplateSyntaxError]
|
||||
) -> Union[RuntimeError, TemplateSyntaxError]: ...
|
||||
def extend_nodelist(
|
||||
self,
|
||||
nodelist: NodeList,
|
||||
@@ -128,11 +128,11 @@ class Parser:
|
||||
def next_token(self) -> Token: ...
|
||||
def parse(
|
||||
self,
|
||||
parse_until: Optional[Union[Tuple[str, str, str], Tuple[str], Tuple[str, str]]] = ...
|
||||
parse_until: Optional[Union[Tuple[str, str], Tuple[str], Tuple[str, str, str]]] = ...
|
||||
) -> NodeList: ...
|
||||
def prepend_token(self, token: Token) -> None: ...
|
||||
def skip_past(self, endtag: str) -> None: ...
|
||||
def unclosed_block_tag(self, parse_until: Union[Tuple[str, str, str], Tuple[str]]): ...
|
||||
def unclosed_block_tag(self, parse_until: Union[Tuple[str], Tuple[str, str, str]]): ...
|
||||
|
||||
|
||||
class Template:
|
||||
@@ -171,8 +171,8 @@ class Token:
|
||||
|
||||
class Variable:
|
||||
def __init__(self, var: str) -> None: ...
|
||||
def _resolve_lookup(self, context: Any) -> Any: ...
|
||||
def resolve(self, context: Any) -> Any: ...
|
||||
def _resolve_lookup(self, context: Any) -> object: ...
|
||||
def resolve(self, context: Any) -> object: ...
|
||||
|
||||
|
||||
class VariableDoesNotExist:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.options import Options
|
||||
from django.http.request import HttpRequest
|
||||
from django.template.base import (
|
||||
Origin,
|
||||
@@ -31,7 +32,7 @@ class BaseContext:
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def __copy__(self) -> BaseContext: ...
|
||||
def __eq__(self, other: Context) -> bool: ...
|
||||
def __getitem__(self, key: Union[str, int]) -> Any: ...
|
||||
def __getitem__(self, key: Union[str, int]) -> object: ...
|
||||
def __init__(self, dict_: Any = ...) -> None: ...
|
||||
def __iter__(self) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
@@ -41,8 +42,12 @@ class BaseContext:
|
||||
value: Any
|
||||
) -> None: ...
|
||||
def _reset_dicts(self, value: Any = ...) -> None: ...
|
||||
def flatten(self) -> Dict[str, Union[None, int, str, Dict[str, Union[Type[object], str]]]]: ...
|
||||
def get(self, key: str, otherwise: Optional[int] = ...) -> Any: ...
|
||||
def flatten(self) -> Dict[str, Optional[Union[int, str, Dict[str, Union[Type[object], str]]]]]: ...
|
||||
def get(
|
||||
self,
|
||||
key: str,
|
||||
otherwise: Optional[int] = ...
|
||||
) -> Optional[Union[Options, int, str]]: ...
|
||||
def new(self, values: Any = ...) -> Context: ...
|
||||
def pop(self) -> ContextDict: ...
|
||||
def push(self, *args, **kwargs) -> ContextDict: ...
|
||||
@@ -78,13 +83,13 @@ class RenderContext:
|
||||
def __getitem__(
|
||||
self,
|
||||
key: Union[str, CycleNode]
|
||||
) -> Union[List[Origin], BlockContext, cycle]: ...
|
||||
) -> Union[BlockContext, List[Origin], cycle]: ...
|
||||
def __iter__(self): ...
|
||||
def get(
|
||||
self,
|
||||
key: Union[str, InclusionNode],
|
||||
otherwise: None = ...
|
||||
) -> Optional[Union[BlockContext, Template]]: ...
|
||||
) -> Optional[Union[Template, BlockContext]]: ...
|
||||
def push_state(self, template: Template, isolated_context: bool = ...) -> Iterator[None]: ...
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from datetime import (
|
||||
time,
|
||||
timedelta,
|
||||
)
|
||||
from decimal import Decimal
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Any,
|
||||
@@ -19,8 +20,8 @@ def _property_resolver(arg: Union[str, int]) -> Callable: ...
|
||||
|
||||
|
||||
def add(
|
||||
value: Union[str, Tuple[int, int], date, int],
|
||||
arg: Union[int, timedelta, Tuple[int, int], SafeText]
|
||||
value: Union[date, Tuple[int, int], str, int],
|
||||
arg: Union[SafeText, Tuple[int, int], timedelta, int]
|
||||
) -> Union[str, Tuple[int, int, int, int], date, int]: ...
|
||||
|
||||
|
||||
@@ -39,7 +40,7 @@ def cut(value: str, arg: str) -> str: ...
|
||||
def date(value: Optional[Union[time, date, str]], arg: Optional[str] = ...) -> str: ...
|
||||
|
||||
|
||||
def default(value: Optional[Union[str, int]], arg: Union[int, SafeText]) -> Union[str, int]: ...
|
||||
def default(value: Optional[Union[int, str]], arg: Union[SafeText, int]) -> Union[int, str]: ...
|
||||
|
||||
|
||||
def default_if_none(value: Optional[str], arg: Union[str, int]) -> Union[str, int]: ...
|
||||
@@ -69,7 +70,7 @@ def filesizeformat(bytes_: Union[str, int]) -> str: ...
|
||||
def first(value: Union[str, List[str]]) -> str: ...
|
||||
|
||||
|
||||
def floatformat(text: Any, arg: Union[str, int] = ...) -> str: ...
|
||||
def floatformat(text: Optional[Union[Decimal, str, float]], arg: Union[str, int] = ...) -> str: ...
|
||||
|
||||
|
||||
def force_escape(value: str) -> SafeText: ...
|
||||
@@ -93,7 +94,7 @@ def last(value: List[str]) -> str: ...
|
||||
def length(value: Any) -> int: ...
|
||||
|
||||
|
||||
def length_is(value: Any, arg: Union[int, SafeText]) -> Union[bool, str]: ...
|
||||
def length_is(value: Any, arg: Union[SafeText, int]) -> Union[bool, str]: ...
|
||||
|
||||
|
||||
def linebreaks_filter(value: str, autoescape: bool = ...) -> SafeText: ...
|
||||
@@ -105,7 +106,7 @@ def linebreaksbr(value: str, autoescape: bool = ...) -> SafeText: ...
|
||||
def linenumbers(value: str, autoescape: bool = ...) -> SafeText: ...
|
||||
|
||||
|
||||
def ljust(value: str, arg: Union[int, SafeText]) -> str: ...
|
||||
def ljust(value: str, arg: Union[SafeText, int]) -> str: ...
|
||||
|
||||
|
||||
def lower(value: str) -> str: ...
|
||||
@@ -123,10 +124,10 @@ def pluralize(value: object, arg: str = ...) -> str: ...
|
||||
def pprint(value: object) -> str: ...
|
||||
|
||||
|
||||
def random(value: Union[List[SafeText], List[str]]) -> str: ...
|
||||
def random(value: Union[List[str], List[SafeText]]) -> str: ...
|
||||
|
||||
|
||||
def rjust(value: str, arg: Union[int, SafeText]) -> str: ...
|
||||
def rjust(value: str, arg: Union[SafeText, int]) -> str: ...
|
||||
|
||||
|
||||
def safe(value: str) -> SafeText: ...
|
||||
@@ -159,13 +160,13 @@ def timeuntil_filter(value: date, arg: Optional[date] = ...) -> str: ...
|
||||
def title(value: str) -> str: ...
|
||||
|
||||
|
||||
def truncatechars(value: str, arg: Union[int, SafeText]) -> str: ...
|
||||
def truncatechars(value: str, arg: Union[SafeText, int]) -> str: ...
|
||||
|
||||
|
||||
def truncatechars_html(value: str, arg: Union[str, int]) -> str: ...
|
||||
|
||||
|
||||
def truncatewords(value: str, arg: Union[int, SafeText]) -> str: ...
|
||||
def truncatewords(value: str, arg: Union[SafeText, int]) -> str: ...
|
||||
|
||||
|
||||
def truncatewords_html(value: str, arg: int) -> str: ...
|
||||
@@ -185,7 +186,7 @@ def urlize(value: str, autoescape: bool = ...) -> SafeText: ...
|
||||
|
||||
def urlizetrunc(
|
||||
value: str,
|
||||
limit: Union[int, SafeText],
|
||||
limit: Union[SafeText, int],
|
||||
autoescape: bool = ...
|
||||
) -> SafeText: ...
|
||||
|
||||
@@ -193,7 +194,7 @@ def urlizetrunc(
|
||||
def wordcount(value: str) -> int: ...
|
||||
|
||||
|
||||
def wordwrap(value: str, arg: Union[int, SafeText]) -> str: ...
|
||||
def wordwrap(value: str, arg: Union[SafeText, int]) -> str: ...
|
||||
|
||||
|
||||
def yesno(value: Optional[int], arg: Optional[str] = ...) -> Optional[str]: ...
|
||||
@@ -268,9 +268,9 @@ class RegroupNode:
|
||||
def render(self, context: Context) -> str: ...
|
||||
def resolve_expression(
|
||||
self,
|
||||
obj: Dict[str, Union[date, str, int, List[str]]],
|
||||
obj: Dict[str, Union[str, int, date, List[str]]],
|
||||
context: Context
|
||||
) -> Union[str, int]: ...
|
||||
) -> Union[int, str]: ...
|
||||
|
||||
|
||||
class ResetCycleNode:
|
||||
|
||||
@@ -24,7 +24,7 @@ class Engine:
|
||||
self,
|
||||
dirs: Optional[List[str]] = ...,
|
||||
app_dirs: bool = ...,
|
||||
context_processors: Optional[Union[Tuple[str, str], List[str]]] = ...,
|
||||
context_processors: Optional[Union[List[str], Tuple[str, str]]] = ...,
|
||||
debug: bool = ...,
|
||||
loaders: Any = ...,
|
||||
string_if_invalid: str = ...,
|
||||
@@ -41,7 +41,7 @@ class Engine:
|
||||
) -> Tuple[Template, Origin]: ...
|
||||
def find_template_loader(
|
||||
self,
|
||||
loader: Union[str, Tuple[str, List[Tuple[str, Dict[str, str]]]], Tuple[str, Dict[str, str]], Tuple[str, List[str]]]
|
||||
loader: Union[Tuple[str, List[Tuple[str, Dict[str, str]]]], Tuple[str, List[str]], Tuple[str, Dict[str, str]], str]
|
||||
) -> Loader: ...
|
||||
def from_string(self, template_code: str) -> Template: ...
|
||||
@staticmethod
|
||||
@@ -55,7 +55,7 @@ class Engine:
|
||||
@cached_property
|
||||
def template_context_processors(
|
||||
self
|
||||
) -> Union[Tuple[Callable, Callable, Callable], Tuple[Callable, Callable, Callable, Callable, Callable], Tuple[Callable, Callable], Tuple[Callable]]: ...
|
||||
) -> Union[Tuple[Callable, Callable, Callable], Tuple[Callable], Tuple[Callable, Callable, Callable, Callable, Callable], Tuple[Callable, Callable]]: ...
|
||||
@cached_property
|
||||
def template_loaders(
|
||||
self
|
||||
|
||||
@@ -30,7 +30,7 @@ def parse_bits(
|
||||
kwonly_defaults: Optional[Dict[str, int]],
|
||||
takes_context: Optional[bool],
|
||||
name: str
|
||||
) -> Union[Tuple[List[Any], Dict[str, FilterExpression]], Tuple[List[FilterExpression], Dict[str, FilterExpression]], Tuple[List[FilterExpression], Dict[Any, Any]], Tuple[List[Any], Dict[Any, Any]]]: ...
|
||||
) -> Union[Tuple[List[Any], Dict[Any, Any]], Tuple[List[FilterExpression], Dict[str, FilterExpression]], Tuple[List[Any], Dict[str, FilterExpression]], Tuple[List[FilterExpression], Dict[Any, Any]]]: ...
|
||||
|
||||
|
||||
class InclusionNode:
|
||||
|
||||
@@ -14,7 +14,7 @@ from typing import (
|
||||
|
||||
def _engine_list(
|
||||
using: Optional[str] = ...
|
||||
) -> Union[List[DjangoTemplates], List[BaseEngine]]: ...
|
||||
) -> Union[List[BaseEngine], List[DjangoTemplates]]: ...
|
||||
|
||||
|
||||
def get_template(template_name: str, using: None = ...) -> Template: ...
|
||||
|
||||
@@ -5,4 +5,4 @@ from typing import (
|
||||
|
||||
|
||||
class Loader:
|
||||
def get_dirs(self) -> Union[Tuple[str, str, str, str], Tuple[str, str, str], Tuple[str], Tuple[str, str]]: ...
|
||||
def get_dirs(self) -> Union[Tuple[str, str], Tuple[str, str, str], Tuple[str], Tuple[str, str, str, str]]: ...
|
||||
@@ -11,4 +11,4 @@ class Loader:
|
||||
def __init__(self, engine: Engine, dirs: None = ...) -> None: ...
|
||||
def get_contents(self, origin: Origin): ...
|
||||
def get_dirs(self) -> List[str]: ...
|
||||
def get_template_sources(self, template_name: Union[str, bytes]) -> Iterator[Origin]: ...
|
||||
def get_template_sources(self, template_name: Union[bytes, str]) -> Iterator[Origin]: ...
|
||||
@@ -15,7 +15,7 @@ class SimpleTemplateResponse:
|
||||
def __getstate__(self) -> Dict[str, Any]: ...
|
||||
def __init__(
|
||||
self,
|
||||
template: Union[str, Template, List[str]],
|
||||
template: Union[str, List[str], Template],
|
||||
context: Any = ...,
|
||||
content_type: Optional[str] = ...,
|
||||
status: Optional[int] = ...,
|
||||
@@ -31,7 +31,7 @@ class SimpleTemplateResponse:
|
||||
def resolve_context(self, context: Any) -> Any: ...
|
||||
def resolve_template(
|
||||
self,
|
||||
template: Union[str, Template, List[str]]
|
||||
template: Union[str, List[str], Template]
|
||||
) -> Template: ...
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class TemplateResponse:
|
||||
def __init__(
|
||||
self,
|
||||
request: HttpRequest,
|
||||
template: Union[str, Template, List[str]],
|
||||
template: Union[str, List[str], Template],
|
||||
context: Any = ...,
|
||||
content_type: Optional[str] = ...,
|
||||
status: Optional[int] = ...,
|
||||
|
||||
@@ -14,11 +14,11 @@ class IfParser:
|
||||
def expression(self, rbp: int = ...) -> Literal: ...
|
||||
def next_token(self) -> Literal: ...
|
||||
def parse(self) -> TemplateLiteral: ...
|
||||
def translate_token(self, token: Union[List[int], str, int]) -> Literal: ...
|
||||
def translate_token(self, token: Union[str, List[int], int]) -> Literal: ...
|
||||
|
||||
|
||||
class Literal:
|
||||
def __init__(self, value: Optional[int]) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def eval(self, context: Dict[Any, Any]) -> Optional[Union[int, List[int]]]: ...
|
||||
def eval(self, context: Dict[Any, Any]) -> Optional[Union[List[int], int]]: ...
|
||||
def nud(self, parser: IfParser) -> Literal: ...
|
||||
@@ -17,6 +17,6 @@ class EngineHandler:
|
||||
def __iter__(self): ...
|
||||
def all(
|
||||
self
|
||||
) -> Union[List[DjangoTemplates], List[TemplateStrings], List[BaseEngine]]: ...
|
||||
) -> Union[List[BaseEngine], List[TemplateStrings], List[DjangoTemplates]]: ...
|
||||
@cached_property
|
||||
def templates(self) -> OrderedDict: ...
|
||||
Reference in New Issue
Block a user