feat: add unified linting scripts and git hooks for code quality enforcement
- Introduced `lint` and `lint-fix` applications in `flake.nix` for unified linting of backend (Python) and frontend (TypeScript/Svelte) code. - Added `scripts/lint.sh` for manual linting execution. - Created `scripts/install-hooks.sh` to set up git hooks for automatic linting before commits and optional tests before pushes. - Updated `README.md` with instructions for using the new linting features and git hooks.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
"""User repository for database operations."""
|
||||
from typing import Optional
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.auth.security import hash_password
|
||||
@@ -16,7 +14,7 @@ class UserRepository:
|
||||
def __init__(self, db: Session):
|
||||
"""
|
||||
Initialize repository.
|
||||
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
"""
|
||||
@@ -25,48 +23,45 @@ class UserRepository:
|
||||
def create_user(self, email: str, password: str) -> User:
|
||||
"""
|
||||
Create a new user.
|
||||
|
||||
|
||||
Args:
|
||||
email: User email (will be lowercased)
|
||||
password: Plain text password (will be hashed)
|
||||
|
||||
|
||||
Returns:
|
||||
Created user instance
|
||||
"""
|
||||
email = email.lower()
|
||||
password_hash = hash_password(password)
|
||||
|
||||
user = User(
|
||||
email=email,
|
||||
password_hash=password_hash
|
||||
)
|
||||
|
||||
|
||||
user = User(email=email, password_hash=password_hash)
|
||||
|
||||
self.db.add(user)
|
||||
self.db.commit()
|
||||
self.db.refresh(user)
|
||||
|
||||
|
||||
return user
|
||||
|
||||
def get_user_by_email(self, email: str) -> Optional[User]:
|
||||
def get_user_by_email(self, email: str) -> User | None:
|
||||
"""
|
||||
Get user by email address.
|
||||
|
||||
|
||||
Args:
|
||||
email: User email to search for
|
||||
|
||||
|
||||
Returns:
|
||||
User if found, None otherwise
|
||||
"""
|
||||
email = email.lower()
|
||||
return self.db.query(User).filter(User.email == email).first()
|
||||
|
||||
def get_user_by_id(self, user_id: UUID) -> Optional[User]:
|
||||
def get_user_by_id(self, user_id: UUID) -> User | None:
|
||||
"""
|
||||
Get user by ID.
|
||||
|
||||
|
||||
Args:
|
||||
user_id: User UUID
|
||||
|
||||
|
||||
Returns:
|
||||
User if found, None otherwise
|
||||
"""
|
||||
@@ -75,13 +70,12 @@ class UserRepository:
|
||||
def email_exists(self, email: str) -> bool:
|
||||
"""
|
||||
Check if email already exists.
|
||||
|
||||
|
||||
Args:
|
||||
email: Email to check
|
||||
|
||||
|
||||
Returns:
|
||||
True if email exists, False otherwise
|
||||
"""
|
||||
email = email.lower()
|
||||
return self.db.query(User).filter(User.email == email).first() is not None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user