Refactor imports for PEP 8 compliance and clarity

- Organized imports in browser_manager.py by category (stdlib, 3rd-party, local)
- Organized imports in browser_profiler.py by category
- Cleaned up test file imports for consistency
- All imports alphabetized within their categories

Co-authored-by: Ahmed-Tawfik94 <106467151+Ahmed-Tawfik94@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-06 08:18:48 +00:00
parent 7037021496
commit 2507720cc7
3 changed files with 35 additions and 22 deletions

View File

@@ -1,21 +1,26 @@
# Standard library imports
import asyncio import asyncio
import time import hashlib
from typing import List, Optional
import os import os
import sys import shlex
import shutil import shutil
import tempfile
import psutil
import signal import signal
import subprocess import subprocess
import shlex import sys
from playwright.async_api import BrowserContext import tempfile
import hashlib import time
from .js_snippet import load_js_script
from .config import DOWNLOAD_PAGE_TIMEOUT
from .async_configs import BrowserConfig, CrawlerRunConfig
from .utils import get_chromium_path
import warnings import warnings
from typing import List, Optional
# Third-party imports
import psutil
from playwright.async_api import BrowserContext
# Local imports
from .async_configs import BrowserConfig, CrawlerRunConfig
from .config import DOWNLOAD_PAGE_TIMEOUT
from .js_snippet import load_js_script
from .utils import get_chromium_path
BROWSER_DISABLE_OPTIONS = [ BROWSER_DISABLE_OPTIONS = [

View File

@@ -5,22 +5,26 @@ This module provides a dedicated class for managing browser profiles
that can be used for identity-based crawling with Crawl4AI. that can be used for identity-based crawling with Crawl4AI.
""" """
import os # Standard library imports
import asyncio import asyncio
import signal
import sys
import datetime import datetime
import uuid
import shutil
import json import json
import os
import shutil
import signal
import subprocess import subprocess
import sys
import time import time
from typing import List, Dict, Optional, Any import uuid
from typing import Any, Dict, List, Optional
# Third-party imports
from rich.console import Console from rich.console import Console
# Local imports
from .async_configs import BrowserConfig from .async_configs import BrowserConfig
from .browser_manager import ManagedBrowser
from .async_logger import AsyncLogger, AsyncLoggerBase, LogColor from .async_logger import AsyncLogger, AsyncLoggerBase, LogColor
from .browser_manager import ManagedBrowser
from .utils import get_home_folder from .utils import get_home_folder

View File

@@ -8,15 +8,19 @@ in managed browsers (CDP mode) work correctly, particularly:
3. Multiple concurrent arun_many calls work correctly 3. Multiple concurrent arun_many calls work correctly
""" """
# Standard library imports
import asyncio import asyncio
import pytest
import sys
import os import os
import sys
# Third-party imports
import pytest
# Add the project root to Python path # Add the project root to Python path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode # Local imports
from crawl4ai import AsyncWebCrawler, BrowserConfig, CacheMode, CrawlerRunConfig
@pytest.mark.asyncio @pytest.mark.asyncio