mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 16:57:12 +08:00
Made BaseContext __setitem__ and __getitem__ consistant. (#1040)
* Made BaseContext __setitem__ and __getitem__ consistant. * Standardised ContextKeys
This commit is contained in:
@@ -6,6 +6,7 @@ from django.template.base import Node, Origin, Template
|
|||||||
from django.template.defaulttags import IfChangedNode
|
from django.template.defaulttags import IfChangedNode
|
||||||
from django.template.loader_tags import IncludeNode
|
from django.template.loader_tags import IncludeNode
|
||||||
|
|
||||||
|
_ContextKeys = Union[int, str, Node]
|
||||||
_ContextValues = Union[Dict[str, Any], "Context"]
|
_ContextValues = Union[Dict[str, Any], "Context"]
|
||||||
_ContextCopy = TypeVar("_ContextCopy", bound="BaseContext")
|
_ContextCopy = TypeVar("_ContextCopy", bound="BaseContext")
|
||||||
|
|
||||||
@@ -23,17 +24,17 @@ class BaseContext(Iterable[Any]):
|
|||||||
def __iter__(self) -> Iterator[Any]: ...
|
def __iter__(self) -> Iterator[Any]: ...
|
||||||
def push(self, *args: Any, **kwargs: Any) -> ContextDict: ...
|
def push(self, *args: Any, **kwargs: Any) -> ContextDict: ...
|
||||||
def pop(self) -> ContextDict: ...
|
def pop(self) -> ContextDict: ...
|
||||||
def __setitem__(self, key: Union[Node, str], value: Any) -> None: ...
|
def __setitem__(self, key: _ContextKeys, value: Any) -> None: ...
|
||||||
def set_upward(self, key: str, value: Union[int, str]) -> None: ...
|
def set_upward(self, key: _ContextKeys, value: Union[int, str]) -> None: ...
|
||||||
def __getitem__(self, key: Union[int, str]) -> Any: ...
|
def __getitem__(self, key: _ContextKeys) -> Any: ...
|
||||||
def __delitem__(self, key: Any) -> None: ...
|
def __delitem__(self, key: _ContextKeys) -> None: ...
|
||||||
def __contains__(self, key: str) -> bool: ...
|
def __contains__(self, key: _ContextKeys) -> bool: ...
|
||||||
def get(self, key: str, otherwise: Optional[Any] = ...) -> Optional[Any]: ...
|
def get(self, key: _ContextKeys, otherwise: Optional[Any] = ...) -> Optional[Any]: ...
|
||||||
def setdefault(
|
def setdefault(
|
||||||
self, key: Union[IfChangedNode, str], default: Optional[Union[List[Origin], int]] = ...
|
self, key: _ContextKeys, default: Optional[Union[List[Origin], int]] = ...
|
||||||
) -> Optional[Union[List[Origin], int]]: ...
|
) -> Optional[Union[List[Origin], int]]: ...
|
||||||
def new(self, values: Optional[_ContextValues] = ...) -> Context: ...
|
def new(self, values: Optional[_ContextValues] = ...) -> Context: ...
|
||||||
def flatten(self) -> Dict[str, Optional[Union[Dict[str, Union[Type[Any], str]], int, str]]]: ...
|
def flatten(self) -> Dict[_ContextKeys, Optional[Union[Dict[_ContextKeys, Union[Type[Any], str]], int, str]]]: ...
|
||||||
|
|
||||||
class Context(BaseContext):
|
class Context(BaseContext):
|
||||||
dicts: Any
|
dicts: Any
|
||||||
|
|||||||
Reference in New Issue
Block a user