|
42 | 42 | from collections.abc import Callable |
43 | 43 |
|
44 | 44 |
|
45 | | -_T_SelfModel = TypeVar("_T_SelfModel", bound="type[BaseGelModel]") |
46 | | -_T_OtherModel = TypeVar("_T_OtherModel", bound="type[BaseGelModel]") |
| 45 | +_T_OtherModel = TypeVar("_T_OtherModel", bound="BaseGelModel") |
47 | 46 |
|
48 | 47 |
|
49 | 48 | class BaseGelModel(AbstractGelModel): |
@@ -84,10 +83,13 @@ def limit(cls, /, expr: Any) -> type[Self]: ... |
84 | 83 | @classmethod |
85 | 84 | def offset(cls, /, expr: Any) -> type[Self]: ... |
86 | 85 |
|
| 86 | + # We pretend that the return type is _T_OtherModel so that the type |
| 87 | + # checker is aware of _T_OtherModel's pointers. We don't get Self's |
| 88 | + # pointers, but that's ok most of the time. |
87 | 89 | @classmethod |
88 | 90 | def is_( |
89 | | - cls: _T_SelfModel, /, other_model: _T_OtherModel |
90 | | - ) -> type[BaseGelModelIntersection[_T_SelfModel, _T_OtherModel]]: ... |
| 91 | + cls: type[Self], /, other_model: type[_T_OtherModel] |
| 92 | + ) -> type[_T_OtherModel]: ... |
91 | 93 |
|
92 | 94 | @classmethod |
93 | 95 | def __gel_assert_single__( |
@@ -207,11 +209,11 @@ def offset( |
207 | 209 | @_qb.exprmethod |
208 | 210 | @classmethod |
209 | 211 | def is_( |
210 | | - cls: _T_SelfModel, |
| 212 | + cls: type[Self], |
211 | 213 | /, |
212 | | - value: _T_OtherModel, |
| 214 | + value: type[_T_OtherModel], |
213 | 215 | __operand__: _qb.ExprAlias | None = None, |
214 | | - ) -> type[BaseGelModelIntersection[_T_SelfModel, _T_OtherModel]]: |
| 216 | + ) -> type[BaseGelModelIntersection[type[Self], type[_T_OtherModel]]]: |
215 | 217 | return _qb.AnnotatedExpr( # type: ignore [return-value] |
216 | 218 | create_intersection(cls, value), |
217 | 219 | add_object_type_filter(cls, value, __operand__=__operand__), |
|
0 commit comments