191
191
str_t = str
192
192
193
193
194
- # error: Value of type variable "_DTypeScalar" of "dtype" cannot be "object"
195
- _o_dtype = np .dtype (object ) # type: ignore[type-var]
194
+ _o_dtype = np .dtype ("object" )
196
195
197
196
198
197
_Identity = NewType ("_Identity" , object )
@@ -417,11 +416,7 @@ def __new__(
417
416
# maybe coerce to a sub-class
418
417
arr = data
419
418
else :
420
- # error: Argument "dtype" to "asarray_tuplesafe" has incompatible type
421
- # "Type[object]"; expected "Union[str, dtype[Any], None]"
422
- arr = com .asarray_tuplesafe (
423
- data , dtype = object # type: ignore[arg-type]
424
- )
419
+ arr = com .asarray_tuplesafe (data , dtype = np .dtype ("object" ))
425
420
426
421
if dtype is None :
427
422
arr = _maybe_cast_data_without_dtype (arr )
@@ -456,9 +451,7 @@ def __new__(
456
451
)
457
452
# other iterable of some kind
458
453
459
- # error: Argument "dtype" to "asarray_tuplesafe" has incompatible type
460
- # "Type[object]"; expected "Union[str, dtype[Any], None]"
461
- subarr = com .asarray_tuplesafe (data , dtype = object ) # type: ignore[arg-type]
454
+ subarr = com .asarray_tuplesafe (data , dtype = np .dtype ("object" ))
462
455
return Index (subarr , dtype = dtype , copy = copy , name = name , ** kwargs )
463
456
464
457
@classmethod
@@ -2902,16 +2895,10 @@ def union(self, other, sort=None):
2902
2895
# <T> | <T> -> T
2903
2896
# <T> | <U> -> object
2904
2897
if not (is_integer_dtype (self .dtype ) and is_integer_dtype (other .dtype )):
2905
- # error: Incompatible types in assignment (expression has type
2906
- # "str", variable has type "Union[dtype[Any], ExtensionDtype]")
2907
- dtype = "float64" # type: ignore[assignment]
2898
+ dtype = np .dtype ("float64" )
2908
2899
else :
2909
2900
# one is int64 other is uint64
2910
-
2911
- # error: Incompatible types in assignment (expression has type
2912
- # "Type[object]", variable has type "Union[dtype[Any],
2913
- # ExtensionDtype]")
2914
- dtype = object # type: ignore[assignment]
2901
+ dtype = np .dtype ("object" )
2915
2902
2916
2903
left = self .astype (dtype , copy = False )
2917
2904
right = other .astype (dtype , copy = False )
@@ -3906,6 +3893,9 @@ def join(
3906
3893
self_is_mi = isinstance (self , ABCMultiIndex )
3907
3894
other_is_mi = isinstance (other , ABCMultiIndex )
3908
3895
3896
+ lindexer : Optional [np .ndarray ]
3897
+ rindexer : Optional [np .ndarray ]
3898
+
3909
3899
# try to figure out the join level
3910
3900
# GH3662
3911
3901
if level is None and (self_is_mi or other_is_mi ):
@@ -4003,15 +3993,11 @@ def join(
4003
3993
4004
3994
if return_indexers :
4005
3995
if join_index is self :
4006
- # error: Incompatible types in assignment (expression has type "None",
4007
- # variable has type "ndarray")
4008
- lindexer = None # type: ignore[assignment]
3996
+ lindexer = None
4009
3997
else :
4010
3998
lindexer = self .get_indexer (join_index )
4011
3999
if join_index is other :
4012
- # error: Incompatible types in assignment (expression has type "None",
4013
- # variable has type "ndarray")
4014
- rindexer = None # type: ignore[assignment]
4000
+ rindexer = None
4015
4001
else :
4016
4002
rindexer = other .get_indexer (join_index )
4017
4003
return join_index , lindexer , rindexer
@@ -4114,15 +4100,11 @@ def _join_non_unique(self, other, how="left", return_indexers=False):
4114
4100
left_idx = ensure_platform_int (left_idx )
4115
4101
right_idx = ensure_platform_int (right_idx )
4116
4102
4117
- join_index = np .asarray (lvalues .take (left_idx ))
4103
+ join_array = np .asarray (lvalues .take (left_idx ))
4118
4104
mask = left_idx == - 1
4119
- np .putmask (join_index , mask , rvalues .take (right_idx ))
4105
+ np .putmask (join_array , mask , rvalues .take (right_idx ))
4120
4106
4121
- # error: Incompatible types in assignment (expression has type "Index", variable
4122
- # has type "ndarray")
4123
- join_index = self ._wrap_joined_index (
4124
- join_index , other # type: ignore[assignment]
4125
- )
4107
+ join_index = self ._wrap_joined_index (join_array , other )
4126
4108
4127
4109
if return_indexers :
4128
4110
return join_index , left_idx , right_idx
@@ -4286,6 +4268,9 @@ def _join_monotonic(self, other, how="left", return_indexers=False):
4286
4268
sv = self ._get_engine_target ()
4287
4269
ov = other ._get_engine_target ()
4288
4270
4271
+ ridx : Optional [np .ndarray ]
4272
+ lidx : Optional [np .ndarray ]
4273
+
4289
4274
if self .is_unique and other .is_unique :
4290
4275
# We can perform much better than the general case
4291
4276
if how == "left" :
@@ -4295,61 +4280,24 @@ def _join_monotonic(self, other, how="left", return_indexers=False):
4295
4280
elif how == "right" :
4296
4281
join_index = other
4297
4282
lidx = self ._left_indexer_unique (ov , sv )
4298
- # error: Incompatible types in assignment (expression has type "None",
4299
- # variable has type "ndarray")
4300
- ridx = None # type: ignore[assignment]
4283
+ ridx = None
4301
4284
elif how == "inner" :
4302
- # error: Incompatible types in assignment (expression has type
4303
- # "ndarray", variable has type "Index")
4304
- join_index , lidx , ridx = self ._inner_indexer ( # type:ignore[assignment]
4305
- sv , ov
4306
- )
4307
- # error: Argument 1 to "_wrap_joined_index" of "Index" has incompatible
4308
- # type "Index"; expected "ndarray"
4309
- join_index = self ._wrap_joined_index (
4310
- join_index , other # type: ignore[arg-type]
4311
- )
4285
+ join_array , lidx , ridx = self ._inner_indexer (sv , ov )
4286
+ join_index = self ._wrap_joined_index (join_array , other )
4312
4287
elif how == "outer" :
4313
- # error: Incompatible types in assignment (expression has type
4314
- # "ndarray", variable has type "Index")
4315
- join_index , lidx , ridx = self ._outer_indexer ( # type:ignore[assignment]
4316
- sv , ov
4317
- )
4318
- # error: Argument 1 to "_wrap_joined_index" of "Index" has incompatible
4319
- # type "Index"; expected "ndarray"
4320
- join_index = self ._wrap_joined_index (
4321
- join_index , other # type: ignore[arg-type]
4322
- )
4288
+ join_array , lidx , ridx = self ._outer_indexer (sv , ov )
4289
+ join_index = self ._wrap_joined_index (join_array , other )
4323
4290
else :
4324
4291
if how == "left" :
4325
- # error: Incompatible types in assignment (expression has type
4326
- # "ndarray", variable has type "Index")
4327
- join_index , lidx , ridx = self ._left_indexer ( # type: ignore[assignment]
4328
- sv , ov
4329
- )
4292
+ join_array , lidx , ridx = self ._left_indexer (sv , ov )
4330
4293
elif how == "right" :
4331
- # error: Incompatible types in assignment (expression has type
4332
- # "ndarray", variable has type "Index")
4333
- join_index , ridx , lidx = self ._left_indexer ( # type: ignore[assignment]
4334
- ov , sv
4335
- )
4294
+ join_array , ridx , lidx = self ._left_indexer (ov , sv )
4336
4295
elif how == "inner" :
4337
- # error: Incompatible types in assignment (expression has type
4338
- # "ndarray", variable has type "Index")
4339
- join_index , lidx , ridx = self ._inner_indexer ( # type:ignore[assignment]
4340
- sv , ov
4341
- )
4296
+ join_array , lidx , ridx = self ._inner_indexer (sv , ov )
4342
4297
elif how == "outer" :
4343
- # error: Incompatible types in assignment (expression has type
4344
- # "ndarray", variable has type "Index")
4345
- join_index , lidx , ridx = self ._outer_indexer ( # type:ignore[assignment]
4346
- sv , ov
4347
- )
4348
- # error: Argument 1 to "_wrap_joined_index" of "Index" has incompatible type
4349
- # "Index"; expected "ndarray"
4350
- join_index = self ._wrap_joined_index (
4351
- join_index , other # type: ignore[arg-type]
4352
- )
4298
+ join_array , lidx , ridx = self ._outer_indexer (sv , ov )
4299
+
4300
+ join_index = self ._wrap_joined_index (join_array , other )
4353
4301
4354
4302
if return_indexers :
4355
4303
lidx = None if lidx is None else ensure_platform_int (lidx )
@@ -6481,12 +6429,8 @@ def _maybe_cast_data_without_dtype(subarr):
6481
6429
pass
6482
6430
6483
6431
elif inferred .startswith ("timedelta" ):
6484
- # error: Incompatible types in assignment (expression has type
6485
- # "TimedeltaArray", variable has type "ndarray")
6486
- data = TimedeltaArray ._from_sequence ( # type: ignore[assignment]
6487
- subarr , copy = False
6488
- )
6489
- return data
6432
+ tda = TimedeltaArray ._from_sequence (subarr , copy = False )
6433
+ return tda
6490
6434
elif inferred == "period" :
6491
6435
try :
6492
6436
data = PeriodArray ._from_sequence (subarr )
0 commit comments