Skip to content

Commit 6c6db29

Browse files
Use shared plain-string helper in file path validation
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent ea22cff commit 6c6db29

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

hyperbrowser/client/file_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
from typing import Union
44

55
from hyperbrowser.exceptions import HyperbrowserError
6+
from hyperbrowser.type_utils import is_plain_string
67

78

89
def _validate_error_message_text(message_value: str, *, field_name: str) -> None:
9-
if type(message_value) is not str:
10+
if not is_plain_string(message_value):
1011
raise HyperbrowserError(f"{field_name} must be a string")
1112
try:
1213
normalized_message = message_value.strip()
13-
if type(normalized_message) is not str:
14+
if not is_plain_string(normalized_message):
1415
raise TypeError(f"normalized {field_name} must be a string")
1516
is_empty = len(normalized_message) == 0
1617
except HyperbrowserError:
@@ -62,11 +63,11 @@ def ensure_existing_file_path(
6263
) from exc
6364
except Exception as exc:
6465
raise HyperbrowserError("file_path is invalid", original_error=exc) from exc
65-
if type(normalized_path) is not str:
66+
if not is_plain_string(normalized_path):
6667
raise HyperbrowserError("file_path must resolve to a string path")
6768
try:
6869
stripped_normalized_path = normalized_path.strip()
69-
if type(stripped_normalized_path) is not str:
70+
if not is_plain_string(stripped_normalized_path):
7071
raise TypeError("normalized file_path must be a string")
7172
except HyperbrowserError:
7273
raise

0 commit comments

Comments
 (0)