Skip to content

Commit cb3d3f9

Browse files
Remove remaining str/int isinstance guards in SDK core
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 5b211ba commit cb3d3f9

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

hyperbrowser/client/managers/async_manager/computer_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def _execute_request(
3333
) -> ComputerActionResponse:
3434
if type(session) is str:
3535
session = await self._client.sessions.get(session)
36-
elif isinstance(session, str):
36+
elif type(session) is not str and str in type(session).__mro__:
3737
raise HyperbrowserError(
3838
"session must be a plain string session ID or SessionDetail"
3939
)

hyperbrowser/client/managers/async_manager/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ async def upload_file(
192192
f"Failed to open upload file at path: {file_path}",
193193
original_error=exc,
194194
) from exc
195-
elif isinstance(file_input, str):
195+
elif type(file_input) is not str and str in type(file_input).__mro__:
196196
raise HyperbrowserError("file_input path must be a plain string path")
197197
else:
198198
try:

hyperbrowser/client/managers/sync_manager/computer_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _execute_request(
3333
) -> ComputerActionResponse:
3434
if type(session) is str:
3535
session = self._client.sessions.get(session)
36-
elif isinstance(session, str):
36+
elif type(session) is not str and str in type(session).__mro__:
3737
raise HyperbrowserError(
3838
"session must be a plain string session ID or SessionDetail"
3939
)

hyperbrowser/client/managers/sync_manager/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def upload_file(
184184
f"Failed to open upload file at path: {file_path}",
185185
original_error=exc,
186186
) from exc
187-
elif isinstance(file_input, str):
187+
elif type(file_input) is not str and str in type(file_input).__mro__:
188188
raise HyperbrowserError("file_input path must be a plain string path")
189189
else:
190190
try:

hyperbrowser/tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _normalize_optional_text_field_value(
207207
error_message,
208208
original_error=exc,
209209
) from exc
210-
if isinstance(field_value, str):
210+
if type(field_value) is not str and str in type(field_value).__mro__:
211211
raise HyperbrowserError(error_message)
212212
if isinstance(field_value, (bytes, bytearray, memoryview)):
213213
try:

0 commit comments

Comments
 (0)