Skip to content

Commit 6ec7272

Browse files
authored
chore(typing): Move DepthTracking* typing (#2272)
1 parent 64915e3 commit 6ec7272

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

narwhals/_compliant/group_by.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
from narwhals._compliant.typing import CompliantExprT_contra
1818
from narwhals._compliant.typing import CompliantFrameT_co
1919
from narwhals._compliant.typing import CompliantLazyFrameT_co
20+
from narwhals._compliant.typing import DepthTrackingExprAny
21+
from narwhals._compliant.typing import DepthTrackingExprT_contra
2022
from narwhals._compliant.typing import EagerExprT_contra
2123
from narwhals._compliant.typing import LazyExprT_contra
2224
from narwhals._compliant.typing import NativeExprT_co
2325

2426
if TYPE_CHECKING:
2527
from typing_extensions import TypeAlias
2628

27-
from narwhals._compliant.expr import DepthTrackingExpr
2829

2930
if not TYPE_CHECKING: # pragma: no cover
3031
if sys.version_info >= (3, 9):
@@ -50,10 +51,6 @@
5051
NarwhalsAggregation: TypeAlias = Literal[
5152
"sum", "mean", "median", "max", "min", "std", "var", "len", "n_unique", "count"
5253
]
53-
DepthTrackingExprAny: TypeAlias = "DepthTrackingExpr[Any, Any]"
54-
DepthTrackingExprT_contra = TypeVar(
55-
"DepthTrackingExprT_contra", bound=DepthTrackingExprAny, contravariant=True
56-
)
5754

5855

5956
_RE_LEAF_NAME: re.Pattern[str] = re.compile(r"(\w+->)")

narwhals/_compliant/namespace.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from typing import Iterable
88
from typing import Literal
99
from typing import Protocol
10-
from typing import TypeVar
1110

1211
from narwhals._compliant.typing import CompliantExprT
1312
from narwhals._compliant.typing import CompliantFrameT
13+
from narwhals._compliant.typing import DepthTrackingExprT
1414
from narwhals._compliant.typing import EagerDataFrameT
1515
from narwhals._compliant.typing import EagerExprT
1616
from narwhals._compliant.typing import EagerSeriesT
@@ -21,7 +21,6 @@
2121
if TYPE_CHECKING:
2222
from typing_extensions import TypeAlias
2323

24-
from narwhals._compliant.expr import DepthTrackingExpr
2524
from narwhals._compliant.selectors import CompliantSelectorNamespace
2625
from narwhals._compliant.when_then import CompliantWhen
2726
from narwhals._compliant.when_then import EagerWhen
@@ -33,9 +32,6 @@
3332

3433
__all__ = ["CompliantNamespace", "EagerNamespace"]
3534

36-
DepthTrackingExprAny: TypeAlias = "DepthTrackingExpr[Any, Any]"
37-
DepthTrackingExprT = TypeVar("DepthTrackingExprT", bound=DepthTrackingExprAny)
38-
3935

4036
class CompliantNamespace(Protocol[CompliantFrameT, CompliantExprT]):
4137
_implementation: Implementation

narwhals/_compliant/typing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from narwhals._compliant.dataframe import CompliantLazyFrame
1414
from narwhals._compliant.dataframe import EagerDataFrame
1515
from narwhals._compliant.expr import CompliantExpr
16+
from narwhals._compliant.expr import DepthTrackingExpr
1617
from narwhals._compliant.expr import EagerExpr
1718
from narwhals._compliant.expr import LazyExpr
1819
from narwhals._compliant.expr import NativeExpr
@@ -40,6 +41,8 @@
4041
CompliantLazyFrameAny: TypeAlias = "CompliantLazyFrame[Any, Any]"
4142
CompliantFrameAny: TypeAlias = "CompliantDataFrameAny | CompliantLazyFrameAny"
4243

44+
DepthTrackingExprAny: TypeAlias = "DepthTrackingExpr[Any, Any]"
45+
4346
EagerDataFrameAny: TypeAlias = "EagerDataFrame[Any, Any, Any]"
4447
EagerSeriesAny: TypeAlias = "EagerSeries[Any]"
4548
EagerExprAny: TypeAlias = "EagerExpr[Any, Any]"
@@ -82,6 +85,11 @@
8285
)
8386
IntoCompliantExpr: TypeAlias = "CompliantExpr[CompliantFrameT, CompliantSeriesOrNativeExprT_co] | CompliantSeriesOrNativeExprT_co"
8487

88+
DepthTrackingExprT = TypeVar("DepthTrackingExprT", bound=DepthTrackingExprAny)
89+
DepthTrackingExprT_contra = TypeVar(
90+
"DepthTrackingExprT_contra", bound=DepthTrackingExprAny, contravariant=True
91+
)
92+
8593
EagerExprT = TypeVar("EagerExprT", bound=EagerExprAny)
8694
EagerExprT_contra = TypeVar("EagerExprT_contra", bound=EagerExprAny, contravariant=True)
8795
EagerSeriesT = TypeVar("EagerSeriesT", bound=EagerSeriesAny)

0 commit comments

Comments
 (0)