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
This commit is contained in:
Sigurd Ljødal
2022-05-10 19:44:49 +02:00
committed by GitHub
parent 7d84e5473a
commit 724442b241

View File

@@ -130,8 +130,8 @@ class F(Combinable):
class ResolvedOuterRef(F): ... class ResolvedOuterRef(F): ...
class OuterRef(F): class OuterRef(F):
def __init__(self, name: Union[str, OuterRef]): ...
contains_aggregate: bool contains_aggregate: bool
def resolve_expression(self, *args: Any, **kwargs: Any) -> ResolvedOuterRef: ...
def relabeled_clone(self: _Self, relabels: Any) -> _Self: ... def relabeled_clone(self: _Self, relabels: Any) -> _Self: ...
class Subquery(BaseExpression, Combinable): class Subquery(BaseExpression, Combinable):