aegisai / fix-imports.ps1
fix-imports.ps1
Raw
# Fix Python Import Warnings
# Run from project root

Write-Host "๐Ÿ”ง Fixing Python Import Warnings" -ForegroundColor Cyan
Write-Host ""

# Check if in virtual environment
$inVenv = $env:VIRTUAL_ENV -ne $null

if (-not $inVenv) {
    Write-Host "โš ๏ธ  Not in virtual environment!" -ForegroundColor Yellow
    Write-Host "Activating virtual environment..." -ForegroundColor Yellow
    
    if (Test-Path "backend\venv\Scripts\Activate.ps1") {
        & "backend\venv\Scripts\Activate.ps1"
        Write-Host "โœ… Virtual environment activated" -ForegroundColor Green
    } else {
        Write-Host "โŒ Virtual environment not found!" -ForegroundColor Red
        Write-Host "Run: python -m venv backend\venv" -ForegroundColor Yellow
        exit 1
    }
}

# Install/upgrade dependencies
Write-Host ""
Write-Host "๐Ÿ“ฆ Installing Python dependencies..." -ForegroundColor Cyan

Push-Location backend

try {
    # Upgrade pip
    python -m pip install --upgrade pip --quiet
    
    # Install all dependencies
    pip install -r requirements.txt --quiet
    
    # Install test dependencies
    pip install pytest pytest-asyncio pytest-cov httpx --quiet
    
    Write-Host "โœ… All dependencies installed" -ForegroundColor Green
    
} catch {
    Write-Host "โŒ Installation failed: $_" -ForegroundColor Red
    exit 1
} finally {
    Pop-Location
}

Write-Host ""
Write-Host "๐Ÿ” Verifying installations..." -ForegroundColor Cyan

$packages = @("fastapi", "uvicorn", "pydantic", "pytest", "google-generativeai")

foreach ($pkg in $packages) {
    $check = pip show $pkg 2>$null
    if ($check) {
        Write-Host "โœ… $pkg" -ForegroundColor Green
    } else {
        Write-Host "โŒ $pkg - NOT FOUND" -ForegroundColor Red
    }
}

Write-Host ""
Write-Host "โœ… Setup complete!" -ForegroundColor Green
Write-Host ""
Write-Host "Note: Pylance warnings are normal and don't affect functionality." -ForegroundColor Yellow
Write-Host "To remove them, restart VS Code after running this script." -ForegroundColor Yellow
Write-Host ""