chore(linter): update ruff rules

This commit is contained in:
MingxuanGame
2025-10-03 15:46:53 +00:00
parent b10425ad91
commit d490239f46
59 changed files with 393 additions and 425 deletions

View File

@@ -5,8 +5,6 @@ Periodically update the MaxMind GeoIP database
from __future__ import annotations
import asyncio
from app.config import settings
from app.dependencies.geoip import get_geoip_helper
from app.dependencies.scheduler import get_scheduler
@@ -28,14 +26,10 @@ async def update_geoip_database():
try:
logger.info("Starting scheduled GeoIP database update...")
geoip = get_geoip_helper()
# Run the synchronous update method in a background thread
loop = asyncio.get_event_loop()
await loop.run_in_executor(None, lambda: geoip.update(force=False))
await geoip.update(force=False)
logger.info("Scheduled GeoIP database update completed successfully")
except Exception as e:
logger.error(f"Scheduled GeoIP database update failed: {e}")
except Exception as exc:
logger.error(f"Scheduled GeoIP database update failed: {exc}")
async def init_geoip():
@@ -45,13 +39,8 @@ async def init_geoip():
try:
geoip = get_geoip_helper()
logger.info("Initializing GeoIP database...")
# Run the synchronous update method in a background thread
# force=False means only download if files don't exist or are expired
loop = asyncio.get_event_loop()
await loop.run_in_executor(None, lambda: geoip.update(force=False))
await geoip.update(force=False)
logger.info("GeoIP database initialization completed")
except Exception as e:
logger.error(f"GeoIP database initialization failed: {e}")
except Exception as exc:
logger.error(f"GeoIP database initialization failed: {exc}")
# Do not raise an exception to avoid blocking application startup