Fix all 33 ruff linting errors causing CI failures

- Remove unused imports (F401) across 17 files
- Fix f-strings without placeholders (F541) in 3 files
- Add noqa: E712 to SQLAlchemy == True comparisons (valid ORM pattern)
- Preserve alembic side-effect import with noqa: F401

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/99c3a25f-3479-473d-ac95-9faaa0ddd55b
This commit is contained in:
copilot-swe-agent[bot]
2026-03-23 10:38:39 +00:00
parent 1463ad225c
commit a918421945
17 changed files with 18 additions and 29 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from app.core.config import settings from app.core.config import settings
from app.core.database import Base from app.core.database import Base
from app.models import database_models # Import all models from app.models import database_models # noqa: F401 - Import all models for Alembic
# this is the Alembic Config object # this is the Alembic Config object
config = context.config config = context.config
@@ -7,7 +7,7 @@ from sqlalchemy import select, desc
from app.core.database import get_db from app.core.database import get_db
from app.core.deps import get_current_active_user from app.core.deps import get_current_active_user
from app.core.security import encrypt_credential, decrypt_credential from app.core.security import encrypt_credential
from app.models.database_models import User, MailAccount from app.models.database_models import User, MailAccount
from app.models.schemas import ( from app.models.schemas import (
MailAccountCreate, MailAccountCreate,
@@ -52,7 +52,7 @@ async def create_mail_account(
if len(existing_accounts) >= max_accounts: if len(existing_accounts) >= max_accounts:
raise HTTPException( raise HTTPException(
status_code=status.HTTP_402_PAYMENT_REQUIRED, status_code=status.HTTP_402_PAYMENT_REQUIRED,
detail=f"Account limit reached. Upgrade your subscription to add more accounts.", detail="Account limit reached. Upgrade your subscription to add more accounts.",
) )
# Encrypt password # Encrypt password
@@ -1,7 +1,7 @@
"""Notification configuration endpoints""" """Notification configuration endpoints"""
from typing import List from typing import List
from fastapi import APIRouter, Depends, HTTPException, status from fastapi import APIRouter, Depends, status
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select from sqlalchemy import select
@@ -11,7 +11,6 @@ from app.models.database_models import User, NotificationConfig
from app.models.schemas import ( from app.models.schemas import (
NotificationConfigCreate, NotificationConfigCreate,
NotificationConfigResponse, NotificationConfigResponse,
NotificationConfigUpdate,
) )
router = APIRouter() router = APIRouter()
+1 -1
View File
@@ -8,7 +8,7 @@ from sqlalchemy import select
from app.core.database import get_db from app.core.database import get_db
from app.core.deps import get_current_active_user from app.core.deps import get_current_active_user
from app.core.security import encrypt_credential, decrypt_credential from app.core.security import encrypt_credential
from app.core.config import settings from app.core.config import settings
from app.models.database_models import User, GmailCredential from app.models.database_models import User, GmailCredential
from app.models.schemas import ( from app.models.schemas import (
@@ -1,7 +1,7 @@
"""Subscription and payment endpoints""" """Subscription and payment endpoints"""
from typing import List from typing import List
from fastapi import APIRouter, Depends, HTTPException, status from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select from sqlalchemy import select
@@ -17,7 +17,7 @@ router = APIRouter()
async def list_subscription_plans(db: AsyncSession = Depends(get_db)): async def list_subscription_plans(db: AsyncSession = Depends(get_db)):
"""List all available subscription plans""" """List all available subscription plans"""
result = await db.execute( result = await db.execute(
select(SubscriptionPlan).where(SubscriptionPlan.is_active == True) select(SubscriptionPlan).where(SubscriptionPlan.is_active == True) # noqa: E712
) )
return result.scalars().all() return result.scalars().all()
+2 -2
View File
@@ -1,12 +1,12 @@
"""User management endpoints""" """User management endpoints"""
from fastapi import APIRouter, Depends, HTTPException, status from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from app.core.database import get_db from app.core.database import get_db
from app.core.deps import get_current_active_user from app.core.deps import get_current_active_user
from app.models.database_models import User from app.models.database_models import User
from app.models.schemas import UserResponse, UserDetailResponse, UserUpdate from app.models.schemas import UserDetailResponse, UserUpdate
router = APIRouter() router = APIRouter()
+1 -1
View File
@@ -5,7 +5,7 @@ Supports environment variables and .env files.
from typing import Optional, List from typing import Optional, List
from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic_settings import BaseSettings, SettingsConfigDict
from pydantic import PostgresDsn, field_validator, ValidationInfo from pydantic import field_validator
class Settings(BaseSettings): class Settings(BaseSettings):
+1 -1
View File
@@ -17,7 +17,7 @@ from app.core.security import decode_token
from app.models.database_models import User from app.models.database_models import User
# OAuth2 scheme for token authentication # OAuth2 scheme for token authentication
oauth2_scheme = OAuth2PasswordBearer(tokenUrl=f"/api/v1/auth/login", auto_error=False) oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/v1/auth/login", auto_error=False)
http_bearer = HTTPBearer(auto_error=False) http_bearer = HTTPBearer(auto_error=False)
+1 -3
View File
@@ -4,8 +4,6 @@ Main FastAPI application.
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.trustedhost import TrustedHostMiddleware
from fastapi.responses import JSONResponse
import logging import logging
from app.core.config import settings from app.core.config import settings
@@ -68,7 +66,7 @@ def create_application() -> FastAPI:
"""Run on application startup""" """Run on application startup"""
logger.info(f"Starting {settings.APP_NAME} v{settings.APP_VERSION}") logger.info(f"Starting {settings.APP_NAME} v{settings.APP_VERSION}")
logger.info(f"Debug mode: {settings.DEBUG}") logger.info(f"Debug mode: {settings.DEBUG}")
logger.info(f"API documentation: /api/docs") logger.info("API documentation: /api/docs")
@app.on_event("shutdown") @app.on_event("shutdown")
async def shutdown_event(): async def shutdown_event():
-1
View File
@@ -3,7 +3,6 @@ Database models for the multi-tenant POP3 forwarder application.
""" """
from datetime import datetime from datetime import datetime
from typing import Optional
from sqlalchemy import ( from sqlalchemy import (
Column, Column,
Integer, Integer,
+1 -1
View File
@@ -4,7 +4,7 @@ Pydantic schemas for API request/response validation.
from datetime import datetime from datetime import datetime
from typing import Optional, Dict, Any, List from typing import Optional, Dict, Any, List
from pydantic import BaseModel, EmailStr, Field, validator from pydantic import BaseModel, EmailStr, Field
from enum import Enum from enum import Enum
+1 -2
View File
@@ -2,8 +2,7 @@
OAuth2 authentication service for Google and other providers. OAuth2 authentication service for Google and other providers.
""" """
from typing import Dict, Any, Optional from typing import Dict, Any
from datetime import datetime
import httpx import httpx
from authlib.integrations.starlette_client import OAuth from authlib.integrations.starlette_client import OAuth
from fastapi import HTTPException, status from fastapi import HTTPException, status
-2
View File
@@ -12,12 +12,10 @@ from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email.utils import formatdate, make_msgid from email.utils import formatdate, make_msgid
from typing import List, Dict, Any, Optional, Tuple from typing import List, Dict, Any, Optional, Tuple
from datetime import datetime
import logging import logging
from aioimaplib import aioimaplib from aioimaplib import aioimaplib
from app.models.database_models import MailAccount, MailProtocol from app.models.database_models import MailAccount, MailProtocol
from app.core.config import settings
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
+2 -4
View File
@@ -5,7 +5,6 @@ Celery tasks for background email processing.
import asyncio import asyncio
import os import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import List
from celery import Task from celery import Task
import logging import logging
@@ -24,7 +23,6 @@ from app.services.mail_processor import MailProcessor
from app.services.gmail_service import GmailService, GmailInjectionError from app.services.gmail_service import GmailService, GmailInjectionError
from app.core.config import settings from app.core.config import settings
from sqlalchemy import select, and_ from sqlalchemy import select, and_
from sqlalchemy.ext.asyncio import AsyncSession
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -94,7 +92,7 @@ async def process_mail_account(account_id: int):
gmail_cred_result = await db.execute( gmail_cred_result = await db.execute(
select(GmailCredential).where( select(GmailCredential).where(
GmailCredential.user_id == account.user_id, GmailCredential.user_id == account.user_id,
GmailCredential.is_valid == True, GmailCredential.is_valid == True, # noqa: E712
) )
) )
gmail_cred = gmail_cred_result.scalar_one_or_none() gmail_cred = gmail_cred_result.scalar_one_or_none()
@@ -222,7 +220,7 @@ async def process_all_enabled_accounts():
result = await db.execute( result = await db.execute(
select(MailAccount).where( select(MailAccount).where(
and_( and_(
MailAccount.is_enabled == True, MailAccount.is_enabled == True, # noqa: E712
MailAccount.status.in_( MailAccount.status.in_(
[AccountStatus.ACTIVE, AccountStatus.TESTING] [AccountStatus.ACTIVE, AccountStatus.TESTING]
), ),
+1 -2
View File
@@ -3,8 +3,7 @@ Test configuration and fixtures.
""" """
import pytest import pytest
import asyncio from typing import AsyncGenerator
from typing import AsyncGenerator, Generator
from httpx import AsyncClient from httpx import AsyncClient
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
from sqlalchemy.pool import NullPool from sqlalchemy.pool import NullPool
+1 -1
View File
@@ -3,7 +3,7 @@ Unit tests for Gmail service module.
""" """
import pytest import pytest
from unittest.mock import MagicMock, patch, AsyncMock from unittest.mock import MagicMock
from app.services.gmail_service import GmailService, GmailInjectionError, GMAIL_SCOPES from app.services.gmail_service import GmailService, GmailInjectionError, GMAIL_SCOPES
@@ -2,7 +2,6 @@
Unit tests for provider presets and mail server auto-detection. Unit tests for provider presets and mail server auto-detection.
""" """
import pytest
from app.services.mail_processor import MailServerAutoDetect from app.services.mail_processor import MailServerAutoDetect