Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

style: ruff-format adjustments in downloads_watchdog

Jay Ozerb14fef2cf7e3
diff --git a/browser_use/browser/watchdogs/downloads_watchdog.py b/browser_use/browser/watchdogs/downloads_watchdog.py
index 68fa4437d..a3eae8da7 100644
--- a/browser_use/browser/watchdogs/downloads_watchdog.py
+++ b/browser_use/browser/watchdogs/downloads_watchdog.py
@@ -132,6 +132,7 @@ class DownloadsWatchdog(BaseWatchdog):
async def attach_to_target(self, target_id: TargetID) -> None:
"""Set up download monitoring for a specific target."""
+
# Define CDP event handlers outside of try to avoid indentation/scope issues
async def download_will_begin_handler(event: DownloadWillBeginEvent, session_id: SessionID | None):
self.logger.debug(f'[DownloadsWatchdog] Download will begin: {event}')
@@ -228,7 +229,6 @@ class DownloadsWatchdog(BaseWatchdog):
}
)
-
# Register the handlers with CDP
cdp_client.register.Browser.downloadWillBegin(download_will_begin_handler) # type: ignore[arg-type]
cdp_client.register.Browser.downloadProgress(download_progress_handler) # type: ignore[arg-type]