Skip to content

Commit aeaea2d

Browse files
committed
Add _type_expression.
1 parent e347ba4 commit aeaea2d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

gel/_internal/_qbmodel/_abstract/_methods.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from gel._internal._schemapath import (
2121
TypeNameIntersection,
2222
)
23+
from gel._internal import _type_expression
2324
from gel._internal._xmethod import classonlymethod
2425

2526
from ._base import AbstractGelModel
@@ -246,6 +247,7 @@ def __edgeql_qb_expr__(cls) -> _qb.Expr: # pyright: ignore [reportIncompatibleM
246247

247248
class BaseGelModelIntersection(
248249
BaseGelModel,
250+
_type_expression.Intersection,
249251
Generic[_T_Lhs, _T_Rhs],
250252
):
251253
__gel_type_class__: ClassVar[type]

gel/_internal/_type_expression.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-PackageName: gel-python
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-FileCopyrightText: Copyright Gel Data Inc. and the contributors.
4+
5+
import typing
6+
7+
8+
class Intersection:
9+
lhs: typing.ClassVar[type]
10+
rhs: typing.ClassVar[type]
11+
12+
13+
class Union:
14+
lhs: typing.ClassVar[type]
15+
rhs: typing.ClassVar[type]

gel/_internal/_typing_dispatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
import typing
3535

3636
from gel._internal import _namespace
37+
from gel._internal import _type_expression
3738
from gel._internal import _typing_eval
3839
from gel._internal import _typing_inspect
3940
from gel._internal import _typing_parametric
4041
from gel._internal._utils import type_repr
41-
from gel._internal._qbmodel._abstract._methods import BaseGelModelIntersection
4242

4343
_P = ParamSpec("_P")
4444
_R_co = TypeVar("_R_co", covariant=True)
@@ -68,7 +68,7 @@ def _issubclass(lhs: Any, tp: Any, fn: Any) -> bool:
6868
# This lets us handle cases like:
6969
# std.array[Object] <: std.array[_T_anytype].
7070

71-
if issubclass(lhs, BaseGelModelIntersection):
71+
if issubclass(lhs, _type_expression.Intersection):
7272
return any(_issubclass(c, tp, fn) for c in (lhs.lhs, lhs.rhs))
7373

7474
if _typing_inspect.is_generic_alias(tp):

0 commit comments

Comments
 (0)