Add ruff and mypy to dev dependencies with configuration in pyproject.toml. Add a lint CI job that runs ruff check, ruff format --check, and mypy. Auto-fix import sorting and formatting across the codebase. Exclude alembic/versions from linting (auto-generated migrations). Ignore B008 (FastAPI Depends pattern) and RUF001 (unicode in user-facing strings). 21 ruff lint errors and 50 mypy errors remain for manual review. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
18 lines
613 B
Python
18 lines
613 B
Python
from __future__ import annotations
|
|
|
|
from argon2 import PasswordHasher
|
|
from argon2.exceptions import InvalidHashError, VerificationError
|
|
|
|
|
|
class PasswordService:
|
|
def __init__(self, hasher: PasswordHasher | None = None) -> None:
|
|
self._hasher = hasher or PasswordHasher()
|
|
|
|
def hash_password(self, password: str) -> str:
|
|
return self._hasher.hash(password)
|
|
|
|
def verify_password(self, password_hash: str, password: str) -> bool:
|
|
try:
|
|
return bool(self._hasher.verify(password_hash, password))
|
|
except (InvalidHashError, VerificationError):
|
|
return False
|