File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 9
9
10
10
from pandas ._libs import Interval , Period , algos
11
11
from pandas ._libs .tslibs import conversion
12
- from pandas ._typing import ArrayLike , DtypeObj
12
+ from pandas ._typing import ArrayLike , DtypeObj , Optional
13
13
14
14
from pandas .core .dtypes .base import registry
15
15
from pandas .core .dtypes .dtypes import (
@@ -1732,7 +1732,7 @@ def _validate_date_like_dtype(dtype) -> None:
1732
1732
)
1733
1733
1734
1734
1735
- def validate_all_hashable (* args , error_name = None ) -> None :
1735
+ def validate_all_hashable (* args , error_name : Optional [ str ] = None ) -> None :
1736
1736
"""
1737
1737
Return None if all args are hashable, else raise a TypeError.
1738
1738
Original file line number Diff line number Diff line change @@ -746,3 +746,13 @@ def test_astype_object_preserves_datetime_na(from_type):
746
746
result = astype_nansafe (arr , dtype = "object" )
747
747
748
748
assert isna (result )[0 ]
749
+
750
+
751
+ def test_validate_allhashable ():
752
+ assert com .validate_all_hashable (1 , "a" ) is None
753
+
754
+ with pytest .raises (TypeError , match = "All elements must be hashable" ):
755
+ com .validate_all_hashable ([])
756
+
757
+ with pytest .raises (TypeError , match = "list must be a hashable type" ):
758
+ com .validate_all_hashable ([], error_name = "list" )
You can’t perform that action at this time.
0 commit comments