|
1 | 1 | import operator
|
2 | 2 | from operator import le, lt
|
3 | 3 | import textwrap
|
4 |
| -from typing import Sequence, Type, TypeVar |
| 4 | +from typing import Optional, Sequence, Type, TypeVar |
5 | 5 |
|
6 | 6 | import numpy as np
|
7 | 7 |
|
|
14 | 14 | intervals_to_interval_bounds,
|
15 | 15 | )
|
16 | 16 | from pandas._libs.missing import NA
|
17 |
| -from pandas._typing import ArrayLike |
| 17 | +from pandas._typing import ArrayLike, Dtype |
18 | 18 | from pandas.compat.numpy import function as nv
|
19 | 19 | from pandas.util._decorators import Appender
|
20 | 20 |
|
@@ -170,7 +170,7 @@ def __new__(
|
170 | 170 | cls,
|
171 | 171 | data,
|
172 | 172 | closed=None,
|
173 |
| - dtype=None, |
| 173 | + dtype: Optional[Dtype] = None, |
174 | 174 | copy: bool = False,
|
175 | 175 | verify_integrity: bool = True,
|
176 | 176 | ):
|
@@ -212,7 +212,13 @@ def __new__(
|
212 | 212 |
|
213 | 213 | @classmethod
|
214 | 214 | def _simple_new(
|
215 |
| - cls, left, right, closed=None, copy=False, dtype=None, verify_integrity=True |
| 215 | + cls, |
| 216 | + left, |
| 217 | + right, |
| 218 | + closed=None, |
| 219 | + copy=False, |
| 220 | + dtype: Optional[Dtype] = None, |
| 221 | + verify_integrity=True, |
216 | 222 | ):
|
217 | 223 | result = IntervalMixin.__new__(cls)
|
218 | 224 |
|
@@ -279,7 +285,7 @@ def _simple_new(
|
279 | 285 | return result
|
280 | 286 |
|
281 | 287 | @classmethod
|
282 |
| - def _from_sequence(cls, scalars, *, dtype=None, copy=False): |
| 288 | + def _from_sequence(cls, scalars, *, dtype: Optional[Dtype] = None, copy=False): |
283 | 289 | return cls(scalars, dtype=dtype, copy=copy)
|
284 | 290 |
|
285 | 291 | @classmethod
|
@@ -338,7 +344,9 @@ def _from_factorized(cls, values, original):
|
338 | 344 | ),
|
339 | 345 | }
|
340 | 346 | )
|
341 |
| - def from_breaks(cls, breaks, closed="right", copy=False, dtype=None): |
| 347 | + def from_breaks( |
| 348 | + cls, breaks, closed="right", copy=False, dtype: Optional[Dtype] = None |
| 349 | + ): |
342 | 350 | breaks = maybe_convert_platform_interval(breaks)
|
343 | 351 |
|
344 | 352 | return cls.from_arrays(breaks[:-1], breaks[1:], closed, copy=copy, dtype=dtype)
|
@@ -407,7 +415,9 @@ def from_breaks(cls, breaks, closed="right", copy=False, dtype=None):
|
407 | 415 | ),
|
408 | 416 | }
|
409 | 417 | )
|
410 |
| - def from_arrays(cls, left, right, closed="right", copy=False, dtype=None): |
| 418 | + def from_arrays( |
| 419 | + cls, left, right, closed="right", copy=False, dtype: Optional[Dtype] = None |
| 420 | + ): |
411 | 421 | left = maybe_convert_platform_interval(left)
|
412 | 422 | right = maybe_convert_platform_interval(right)
|
413 | 423 |
|
@@ -464,7 +474,9 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
|
464 | 474 | ),
|
465 | 475 | }
|
466 | 476 | )
|
467 |
| - def from_tuples(cls, data, closed="right", copy=False, dtype=None): |
| 477 | + def from_tuples( |
| 478 | + cls, data, closed="right", copy=False, dtype: Optional[Dtype] = None |
| 479 | + ): |
468 | 480 | if len(data):
|
469 | 481 | left, right = [], []
|
470 | 482 | else:
|
|
0 commit comments