Skip to content

Commit bc9c3be

Browse files
committed
formatting
1 parent 852f42a commit bc9c3be

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

stagehand/browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async def connect_local_browser(
203203
if temp_user_data_dir:
204204
try:
205205
shutil.rmtree(temp_user_data_dir)
206-
except:
206+
except Exception:
207207
pass
208208
raise
209209

stagehand/client.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Stagehand:
4848

4949
# Dictionary to store one lock per session_id
5050
_session_locks = {}
51-
51+
5252
# Flag to track if cleanup has been called
5353
_cleanup_called = False
5454

@@ -194,7 +194,7 @@ def __init__(
194194
raise ValueError(
195195
"browserbase_project_id is required for BROWSERBASE env with existing session_id (or set BROWSERBASE_PROJECT_ID in env)."
196196
)
197-
197+
198198
# Register signal handlers for graceful shutdown
199199
self._register_signal_handlers()
200200

@@ -225,13 +225,16 @@ def __init__(
225225

226226
def _register_signal_handlers(self):
227227
"""Register signal handlers for SIGINT and SIGTERM to ensure proper cleanup."""
228+
228229
def cleanup_handler(sig, frame):
229230
# Prevent multiple cleanup calls
230231
if self.__class__._cleanup_called:
231232
return
232233

233234
self.__class__._cleanup_called = True
234-
print(f"\n[{signal.Signals(sig).name}] received. Ending Browserbase session...")
235+
print(
236+
f"\n[{signal.Signals(sig).name}] received. Ending Browserbase session..."
237+
)
235238

236239
try:
237240
# Try to get the current event loop
@@ -253,11 +256,11 @@ def cleanup_handler(sig, frame):
253256
def schedule_cleanup():
254257
task = asyncio.create_task(self._async_cleanup())
255258
# Shield the task to prevent it from being cancelled
256-
shielded = asyncio.shield(task)
259+
asyncio.shield(task)
257260
# We don't need to await here since we're in call_soon_threadsafe
258-
261+
259262
loop.call_soon_threadsafe(schedule_cleanup)
260-
263+
261264
except Exception as e:
262265
print(f"Error during signal cleanup: {str(e)}")
263266
sys.exit(1)

stagehand/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,8 @@ def transform_url_strings_to_ids(schema):
844844
return transform_model(schema)
845845

846846

847-
def transform_model(model_cls, path=[]):
847+
# TODO: remove path?
848+
def transform_model(model_cls, path=[]): # noqa: F841 B006
848849
"""
849850
Recursively transforms a Pydantic model by replacing URL fields with numeric fields.
850851

0 commit comments

Comments
 (0)