Skip to content

Commit

Permalink
Made BaseContext __setitem__ and __getitem__ consistant. (#1040)
Browse files Browse the repository at this point in the history
* Made BaseContext __setitem__ and __getitem__ consistant.

* Standardised ContextKeys
  • Loading branch information
smithdc1 authored Jul 13, 2022
1 parent 3648e10 commit 2e84c03
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions django-stubs/template/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from django.template.base import Node, Origin, Template
from django.template.defaulttags import IfChangedNode
from django.template.loader_tags import IncludeNode

_ContextKeys = Union[int, str, Node]
_ContextValues = Union[Dict[str, Any], "Context"]
_ContextCopy = TypeVar("_ContextCopy", bound="BaseContext")

Expand All @@ -23,17 +24,17 @@ class BaseContext(Iterable[Any]):
def __iter__(self) -> Iterator[Any]: ...
def push(self, *args: Any, **kwargs: Any) -> ContextDict: ...
def pop(self) -> ContextDict: ...
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[Any] = ...) -> Optional[Any]: ...
def __setitem__(self, key: _ContextKeys, value: Any) -> None: ...
def set_upward(self, key: _ContextKeys, value: Union[int, str]) -> None: ...
def __getitem__(self, key: _ContextKeys) -> Any: ...
def __delitem__(self, key: _ContextKeys) -> None: ...
def __contains__(self, key: _ContextKeys) -> bool: ...
def get(self, key: _ContextKeys, otherwise: Optional[Any] = ...) -> Optional[Any]: ...
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]]: ...
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):
dicts: Any
Expand Down

0 comments on commit 2e84c03

Please sign in to comment.