22from typing import Any , Callable , Dict , List
33
44from hyperbrowser .exceptions import HyperbrowserError
5+ from hyperbrowser .type_utils import is_plain_string
56
67
78def read_string_mapping_keys (
@@ -24,7 +25,7 @@ def read_string_mapping_keys(
2425 ) from exc
2526 normalized_keys : List [str ] = []
2627 for key in mapping_keys :
27- if type (key ) is str :
28+ if is_plain_string (key ):
2829 normalized_keys .append (key )
2930 continue
3031 raise HyperbrowserError (non_string_key_error_builder (key ))
@@ -55,7 +56,7 @@ def read_string_key_mapping(
5556 except Exception as exc :
5657 try :
5758 key_text = key_display (key )
58- if type (key_text ) is not str :
59+ if not is_plain_string (key_text ):
5960 raise TypeError ("mapping key display must be a string" )
6061 except Exception :
6162 key_text = "<unreadable key>"
@@ -75,7 +76,7 @@ def copy_mapping_values_by_string_keys(
7576) -> Dict [str , object ]:
7677 normalized_mapping : Dict [str , object ] = {}
7778 for key in keys :
78- if type (key ) is not str :
79+ if not is_plain_string (key ):
7980 raise HyperbrowserError ("mapping key list must contain plain strings" )
8081 try :
8182 normalized_mapping [key ] = mapping_value [key ]
@@ -84,7 +85,7 @@ def copy_mapping_values_by_string_keys(
8485 except Exception as exc :
8586 try :
8687 key_text = key_display (key )
87- if type (key_text ) is not str :
88+ if not is_plain_string (key_text ):
8889 raise TypeError ("mapping key display must be a string" )
8990 except Exception :
9091 key_text = "<unreadable key>"
0 commit comments