Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix(lint): address ruff linting and formatting issues
ShawnPana4935afbf44ce
diff --git a/browser_use/skill_cli/commands/profile.py b/browser_use/skill_cli/commands/profile.pyindex 06771fe2c..7756cd98e 100644--- a/browser_use/skill_cli/commands/profile.py+++ b/browser_use/skill_cli/commands/profile.py@@ -64,9 +64,7 @@ def get_profile_mode(args: argparse.Namespace) -> ProfileMode:'Specify -b real for local Chrome profiles or -b remote for cloud profiles.')else:- raise ProfileModeError(- 'No profile modes available. Run browser-use setup first.'- )+ raise ProfileModeError('No profile modes available. Run browser-use setup first.')def handle_profile_command(args: argparse.Namespace) -> int:@@ -472,7 +470,7 @@ def _list_profile_cookies(args: argparse.Namespace) -> int:if len(sorted_domains) > 20:print(f' ... and {len(sorted_domains) - 20} more domains')- print(f'\nTo sync cookies to cloud:')+ print('\nTo sync cookies to cloud:')print(f' browser-use profile sync --from "{profile_id}" --domain <domain>')return 0@@ -605,6 +603,7 @@ def _handle_sync(args: argparse.Namespace) -> int:loop = asyncio.get_event_loop()if loop.is_running():import concurrent.futures+with concurrent.futures.ThreadPoolExecutor() as executor:future = executor.submit(asyncio.run, sync_cookies())cookie_count, cookies_file = future.result()@@ -634,6 +633,7 @@ def _handle_sync(args: argparse.Namespace) -> int:loop = asyncio.get_event_loop()if loop.is_running():import concurrent.futures+with concurrent.futures.ThreadPoolExecutor() as executor:future = executor.submit(asyncio.run, import_to_cloud())future.result()diff --git a/browser_use/skill_cli/commands/setup.py b/browser_use/skill_cli/commands/setup.pyindex a8592ec83..8b4ac5f68 100644--- a/browser_use/skill_cli/commands/setup.py+++ b/browser_use/skill_cli/commands/setup.py@@ -76,9 +76,12 @@ async def run_checks(mode: Literal['local', 'remote', 'full']) -> dict[str, Any]# Package checktry:import browser_use+checks['browser_use_package'] = {'status': 'ok',- 'message': f'browser-use {browser_use.__version__}' if hasattr(browser_use, '__version__') else 'browser-use installed',+ 'message': f'browser-use {browser_use.__version__}'+ if hasattr(browser_use, '__version__')+ else 'browser-use installed',}except ImportError:checks['browser_use_package'] = {@@ -155,39 +158,47 @@ def plan_actions(if mode in ('local', 'full'):browser_check = checks.get('browser', {})if browser_check.get('status') != 'ok':- actions.append({- 'type': 'install_browser',- 'description': 'Install browser (Chromium)',- 'required': True,- })+ actions.append(+ {+ 'type': 'install_browser',+ 'description': 'Install browser (Chromium)',+ 'required': True,+ }+ )# API key configuration (remote/full)if mode in ('remote', 'full'):api_check = checks.get('api_key', {})if api_check.get('status') != 'ok':if api_key:- actions.append({- 'type': 'configure_api_key',- 'description': 'Configure API key',- 'required': True,- 'api_key': api_key,- })+ actions.append(+ {+ 'type': 'configure_api_key',+ 'description': 'Configure API key',+ 'required': True,+ 'api_key': api_key,+ }+ )elif not yes:- actions.append({- 'type': 'prompt_api_key',- 'description': 'Prompt for API key',- 'required': False,- })+ actions.append(+ {+ 'type': 'prompt_api_key',+ 'description': 'Prompt for API key',+ 'required': False,+ }+ )# Cloudflared (remote/full)if mode in ('remote', 'full'):cloudflared_check = checks.get('cloudflared', {})if cloudflared_check.get('status') != 'ok':- actions.append({- 'type': 'install_cloudflared',- 'description': 'Install cloudflared (for tunneling)',- 'required': True,- })+ actions.append(+ {+ 'type': 'install_cloudflared',+ 'description': 'Install cloudflared (for tunneling)',+ 'required': True,+ }+ )return actions@@ -237,7 +248,9 @@ async def execute_actions(print('⚠ cloudflared not installed')print(' Install via:')print(' macOS: brew install cloudflared')- print(' Linux: curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o ~/.local/bin/cloudflared && chmod +x ~/.local/bin/cloudflared')+ print(+ ' Linux: curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o ~/.local/bin/cloudflared && chmod +x ~/.local/bin/cloudflared'+ )print(' Windows: winget install Cloudflare.cloudflared')print()print(' Or re-run install.sh which installs cloudflared automatically.')@@ -255,7 +268,8 @@ async def validate_setup(# Check importstry:- import browser_use+ import browser_use # noqa: F401+results['browser_use_import'] = 'ok'except ImportError:results['browser_use_import'] = 'failed'diff --git a/browser_use/skill_cli/tunnel_manager.py b/browser_use/skill_cli/tunnel_manager.pyindex 06eeb44b3..53fd55f55 100644--- a/browser_use/skill_cli/tunnel_manager.py+++ b/browser_use/skill_cli/tunnel_manager.py@@ -202,7 +202,7 @@ async def start_tunnel(port: int) -> dict[str, Any]:# Create log file for cloudflared stderr (avoids SIGPIPE when parent exits)_TUNNELS_DIR.mkdir(parents=True, exist_ok=True)log_file_path = _TUNNELS_DIR / f'{port}.log'- log_file = open(log_file_path, 'w')+ log_file = open(log_file_path, 'w') # noqa: ASYNC230# Spawn cloudflared as a daemon# - start_new_session=True: survives parent exit