@@ -765,9 +765,7 @@ def _validate_shift_value(self, fill_value):
765
765
766
766
return self ._unbox (fill_value )
767
767
768
- def _validate_scalar (
769
- self , value , msg : Optional [str ] = None , cast_str : bool = False
770
- ):
768
+ def _validate_scalar (self , value , msg : Optional [str ] = None ):
771
769
"""
772
770
Validate that the input value can be cast to our scalar_type.
773
771
@@ -778,14 +776,12 @@ def _validate_scalar(
778
776
Message to raise in TypeError on invalid input.
779
777
If not provided, `value` is cast to a str and used
780
778
as the message.
781
- cast_str : bool, default False
782
- Whether to try to parse string input to scalar_type.
783
779
784
780
Returns
785
781
-------
786
782
self._scalar_type or NaT
787
783
"""
788
- if cast_str and isinstance (value , str ):
784
+ if isinstance (value , str ):
789
785
# NB: Careful about tzawareness
790
786
try :
791
787
value = self ._scalar_from_string (value )
@@ -807,9 +803,7 @@ def _validate_scalar(
807
803
808
804
return value
809
805
810
- def _validate_listlike (
811
- self , value , opname : str , cast_str : bool = False , allow_object : bool = False
812
- ):
806
+ def _validate_listlike (self , value , opname : str , allow_object : bool = False ):
813
807
if isinstance (value , type (self )):
814
808
return value
815
809
@@ -818,7 +812,7 @@ def _validate_listlike(
818
812
value = array (value )
819
813
value = extract_array (value , extract_numpy = True )
820
814
821
- if cast_str and is_dtype_equal (value .dtype , "string" ):
815
+ if is_dtype_equal (value .dtype , "string" ):
822
816
# We got a StringArray
823
817
try :
824
818
# TODO: Could use from_sequence_of_strings if implemented
@@ -848,9 +842,9 @@ def _validate_listlike(
848
842
def _validate_searchsorted_value (self , value ):
849
843
msg = "searchsorted requires compatible dtype or scalar"
850
844
if not is_list_like (value ):
851
- value = self ._validate_scalar (value , msg , cast_str = True )
845
+ value = self ._validate_scalar (value , msg )
852
846
else :
853
- value = self ._validate_listlike (value , "searchsorted" , cast_str = True )
847
+ value = self ._validate_listlike (value , "searchsorted" )
854
848
855
849
rv = self ._unbox (value )
856
850
return self ._rebox_native (rv )
@@ -861,15 +855,15 @@ def _validate_setitem_value(self, value):
861
855
f"or array of those. Got '{ type (value ).__name__ } ' instead."
862
856
)
863
857
if is_list_like (value ):
864
- value = self ._validate_listlike (value , "setitem" , cast_str = True )
858
+ value = self ._validate_listlike (value , "setitem" )
865
859
else :
866
- value = self ._validate_scalar (value , msg , cast_str = True )
860
+ value = self ._validate_scalar (value , msg )
867
861
868
862
return self ._unbox (value , setitem = True )
869
863
870
864
def _validate_insert_value (self , value ):
871
865
msg = f"cannot insert { type (self ).__name__ } with incompatible label"
872
- value = self ._validate_scalar (value , msg , cast_str = False )
866
+ value = self ._validate_scalar (value , msg )
873
867
874
868
self ._check_compatible_with (value , setitem = True )
875
869
# TODO: if we dont have compat, should we raise or astype(object)?
0 commit comments