From 44157a4b03b6a59228bd11c95b37ad3927cede92 Mon Sep 17 00:00:00 2001 From: David Smith <39445562+smithdc1@users.noreply.github.com> Date: Sat, 25 Jun 2022 09:57:04 +0100 Subject: [PATCH] BaseContext.__copy__ (#1012) * Improved BaseContext.__copy__() * Update django-stubs/template/context.pyi Co-authored-by: Nikita Sobolev * Updated __copy__ to use private name. Co-authored-by: Nikita Sobolev --- django-stubs/template/context.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index 6c10e9f..98e3e84 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -1,5 +1,5 @@ from contextlib import contextmanager -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, TypeVar, Union from django.http.request import HttpRequest from django.template.base import Node, Origin, Template @@ -7,6 +7,7 @@ from django.template.defaulttags import IfChangedNode from django.template.loader_tags import IncludeNode _ContextValues = Union[Dict[str, Any], "Context"] +_ContextCopy = TypeVar("_ContextCopy", bound="BaseContext") class ContextPopException(Exception): ... @@ -18,7 +19,7 @@ class ContextDict(dict): class BaseContext(Iterable[Any]): def __init__(self, dict_: Any = ...) -> None: ... - def __copy__(self) -> BaseContext: ... + def __copy__(self: _ContextCopy) -> _ContextCopy: ... def __iter__(self) -> Iterator[Any]: ... def push(self, *args: Any, **kwargs: Any) -> ContextDict: ... def pop(self) -> ContextDict: ...