feat: add pre-commit hooks for local CI checks

- Black (auto-fix formatting on commit)
- Flake8 (block on syntax errors and undefined names)
- Bandit (security scan, non-blocking to match CI)
- Tests (run on pre-push only)
- Apply Black formatting fixes caught by the new hooks
This commit is contained in:
Vito Sansevero
2026-02-08 05:27:03 -08:00
parent ed40be066c
commit be205f3dcc
6 changed files with 110 additions and 39 deletions
+12 -6
View File
@@ -137,10 +137,12 @@ class GalleryDiagnostics:
self.logger.info(f" [NOTE] Prompts in database: {prompt_count}")
# Check if generated_images table exists
cursor = conn.execute("""
cursor = conn.execute(
"""
SELECT name FROM sqlite_master
WHERE type='table' AND name='generated_images'
""")
"""
)
has_images_table = cursor.fetchone() is not None
self.logger.info(f" [IMG] Images table exists: {has_images_table}")
@@ -174,10 +176,12 @@ class GalleryDiagnostics:
conn.row_factory = sqlite3.Row
# Check if table exists
cursor = conn.execute("""
cursor = conn.execute(
"""
SELECT name FROM sqlite_master
WHERE type='table' AND name='generated_images'
""")
"""
)
if not cursor.fetchone():
return {
@@ -191,13 +195,15 @@ class GalleryDiagnostics:
self.logger.info(f" [STATS] Images in database: {image_count}")
# Get recent images
cursor = conn.execute("""
cursor = conn.execute(
"""
SELECT gi.*, p.text
FROM generated_images gi
LEFT JOIN prompts p ON gi.prompt_id = p.id
ORDER BY gi.generation_time DESC
LIMIT 5
""")
"""
)
recent_images = [dict(row) for row in cursor.fetchall()]
self.logger.info(f" [TIME] Recent images: {len(recent_images)}")