From 724442b24118a242d4e1875fe6a53b8d00036d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigurd=20Lj=C3=B8dal?= <544451+ljodal@users.noreply.github.com> Date: Tue, 10 May 2022 19:44:49 +0200 Subject: [PATCH] Fix type stubs for OuterRef (#952) * Fix error when nesting OuterRef expressions OuterRef(OuterRef("my_field")) is a valid expression in nested subqueries. Mypy would complain that OuterRef was an incompatible type because OuterRef is typed to only accept str. * Only fix for OuterRef * OuterRef is not guaranteed to be resolved to ResolvedOuterRef --- django-stubs/db/models/expressions.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-stubs/db/models/expressions.pyi b/django-stubs/db/models/expressions.pyi index 5ebdccf..55ed386 100644 --- a/django-stubs/db/models/expressions.pyi +++ b/django-stubs/db/models/expressions.pyi @@ -130,8 +130,8 @@ class F(Combinable): class ResolvedOuterRef(F): ... class OuterRef(F): + def __init__(self, name: Union[str, OuterRef]): ... contains_aggregate: bool - def resolve_expression(self, *args: Any, **kwargs: Any) -> ResolvedOuterRef: ... def relabeled_clone(self: _Self, relabels: Any) -> _Self: ... class Subquery(BaseExpression, Combinable):