110110 )
111111
112112
113- IntervalSideT = Union [TimeArrayLike , np .ndarray ]
113+ IntervalSide = Union [TimeArrayLike , np .ndarray ]
114114IntervalOrNA = Union [Interval , float ]
115115
116116_interval_shared_docs : dict [str , str ] = {}
@@ -219,8 +219,8 @@ def ndim(self) -> Literal[1]:
219219 return 1
220220
221221 # To make mypy recognize the fields
222- _left : IntervalSideT
223- _right : IntervalSideT
222+ _left : IntervalSide
223+ _right : IntervalSide
224224 _dtype : IntervalDtype
225225
226226 # ---------------------------------------------------------------------
@@ -237,8 +237,8 @@ def __new__(
237237 data = extract_array (data , extract_numpy = True )
238238
239239 if isinstance (data , cls ):
240- left : IntervalSideT = data ._left
241- right : IntervalSideT = data ._right
240+ left : IntervalSide = data ._left
241+ right : IntervalSide = data ._right
242242 closed = closed or data .closed
243243 dtype = IntervalDtype (left .dtype , closed = closed )
244244 else :
@@ -280,8 +280,8 @@ def __new__(
280280 @classmethod
281281 def _simple_new (
282282 cls ,
283- left : IntervalSideT ,
284- right : IntervalSideT ,
283+ left : IntervalSide ,
284+ right : IntervalSide ,
285285 dtype : IntervalDtype ,
286286 ) -> Self :
287287 result = IntervalMixin .__new__ (cls )
@@ -299,7 +299,7 @@ def _ensure_simple_new_inputs(
299299 closed : IntervalClosedType | None = None ,
300300 copy : bool = False ,
301301 dtype : Dtype | None = None ,
302- ) -> tuple [IntervalSideT , IntervalSideT , IntervalDtype ]:
302+ ) -> tuple [IntervalSide , IntervalSide , IntervalDtype ]:
303303 """Ensure correctness of input parameters for cls._simple_new."""
304304 from pandas .core .indexes .base import ensure_index
305305
@@ -1031,8 +1031,8 @@ def _concat_same_type(cls, to_concat: Sequence[IntervalArray]) -> Self:
10311031 raise ValueError ("Intervals must all be closed on the same side." )
10321032 closed = closed_set .pop ()
10331033
1034- left = np .concatenate ([interval .left for interval in to_concat ])
1035- right = np .concatenate ([interval .right for interval in to_concat ])
1034+ left : IntervalSide = np .concatenate ([interval .left for interval in to_concat ])
1035+ right : IntervalSide = np .concatenate ([interval .right for interval in to_concat ])
10361036
10371037 left , right , dtype = cls ._ensure_simple_new_inputs (left , right , closed = closed )
10381038
@@ -1283,7 +1283,7 @@ def _format_space(self) -> str:
12831283 # Vectorized Interval Properties/Attributes
12841284
12851285 @property
1286- def left (self ):
1286+ def left (self ) -> Index :
12871287 """
12881288 Return the left endpoints of each Interval in the IntervalArray as an Index.
12891289
@@ -1303,7 +1303,7 @@ def left(self):
13031303 return Index (self ._left , copy = False )
13041304
13051305 @property
1306- def right (self ):
1306+ def right (self ) -> Index :
13071307 """
13081308 Return the right endpoints of each Interval in the IntervalArray as an Index.
13091309
@@ -1855,11 +1855,17 @@ def isin(self, values) -> npt.NDArray[np.bool_]:
18551855 return isin (self .astype (object ), values .astype (object ))
18561856
18571857 @property
1858- def _combined (self ) -> IntervalSideT :
1859- left = self .left ._values .reshape (- 1 , 1 )
1860- right = self .right ._values .reshape (- 1 , 1 )
1858+ def _combined (self ) -> IntervalSide :
1859+ # error: Item "ExtensionArray" of "ExtensionArray | ndarray[Any, Any]"
1860+ # has no attribute "reshape" [union-attr]
1861+ left = self .left ._values .reshape (- 1 , 1 ) # type: ignore[union-attr]
1862+ right = self .right ._values .reshape (- 1 , 1 ) # type: ignore[union-attr]
18611863 if needs_i8_conversion (left .dtype ):
1862- comb = left ._concat_same_type ([left , right ], axis = 1 )
1864+ # error: Item "ndarray[Any, Any]" of "Any | ndarray[Any, Any]" has
1865+ # no attribute "_concat_same_type"
1866+ comb = left ._concat_same_type ( # type: ignore[union-attr]
1867+ [left , right ], axis = 1
1868+ )
18631869 else :
18641870 comb = np .concatenate ([left , right ], axis = 1 )
18651871 return comb
0 commit comments