Skip to content

Commit 43ebacc

Browse files
Refactoring type hints to avoid use of Self
Various other type improvements
1 parent f43890a commit 43ebacc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pins/_adaptors.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
import json
44
from abc import abstractmethod
5-
from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias, overload
6-
7-
from typing_extensions import Self
5+
from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias, Union, overload
86

97
from ._databackend import AbstractBackend
108

119
if TYPE_CHECKING:
1210
import pandas as pd
1311

1412
_PandasDataFrame: TypeAlias = pd.DataFrame
15-
_DataFrame: TypeAlias = pd.DataFrame
13+
_DataFrame: TypeAlias = Union[_PandasDataFrame,]
1614

1715

1816
class _AbstractPandasFrame(AbstractBackend):
@@ -99,7 +97,7 @@ def columns(self) -> list[Any]: ...
9997
def shape(self) -> tuple[int, int]: ...
10098

10199
@abstractmethod
102-
def head(self, n: int) -> Self: ...
100+
def head(self, n: int) -> _DFAdaptor: ...
103101

104102
@property
105103
def data_preview(self) -> str:
@@ -123,6 +121,8 @@ def _obj_name(self) -> str:
123121

124122

125123
class _PandasAdaptor(_DFAdaptor):
124+
_d: ClassVar[_PandasDataFrame]
125+
126126
def __init__(self, data: _AbstractPandasFrame) -> None:
127127
super().__init__(data)
128128

@@ -134,7 +134,7 @@ def columns(self) -> list[Any]:
134134
def shape(self) -> tuple[int, int]:
135135
return self._d.shape
136136

137-
def head(self, n: int) -> Self:
137+
def head(self, n: int) -> _PandasAdaptor:
138138
return _PandasAdaptor(self._d.head(n))
139139

140140
@overload

0 commit comments

Comments
 (0)