@@ -109,7 +109,7 @@ def _unbox_scalar(self, value: Union[Period, Timestamp, Timedelta, NaTType]) ->
109
109
raise AbstractMethodError (self )
110
110
111
111
def _check_compatible_with (
112
- self , other : Union [Period , Timestamp , Timedelta , NaTType ]
112
+ self , other : Union [Period , Timestamp , Timedelta , NaTType ], setitem : bool = False
113
113
) -> None :
114
114
"""
115
115
Verify that `self` and `other` are compatible.
@@ -123,6 +123,9 @@ def _check_compatible_with(
123
123
Parameters
124
124
----------
125
125
other
126
+ setitem : bool, default False
127
+ For __setitem__ we may have stricter compatiblity resrictions than
128
+ for comparisons.
126
129
127
130
Raises
128
131
------
@@ -500,10 +503,10 @@ def __setitem__(
500
503
return
501
504
502
505
value = type (self )._from_sequence (value , dtype = self .dtype )
503
- self ._check_compatible_with (value )
506
+ self ._check_compatible_with (value , setitem = True )
504
507
value = value .asi8
505
508
elif isinstance (value , self ._scalar_type ):
506
- self ._check_compatible_with (value )
509
+ self ._check_compatible_with (value , setitem = True )
507
510
value = self ._unbox_scalar (value )
508
511
elif is_valid_nat_for_dtype (value , self .dtype ):
509
512
value = iNaT
0 commit comments