Conventions de Code¶
Standards de code pour le projet JARVIS.
Python¶
Type Hints (Obligatoires)¶
# ✅ Correct
def get_user_by_email(email: str) -> Optional[User]:
...
# ❌ Incorrect
def get_user_by_email(email):
...
Docstrings (Google Style)¶
def create_conversation(
user: User,
title: str
) -> Conversation:
"""
Crée une nouvelle conversation.
Args:
user: L'utilisateur propriétaire.
title: Titre de la conversation.
Returns:
La conversation créée.
Raises:
HTTPException: Si erreur de permission.
"""
Imports (isort)¶
# Standard library
import asyncio
from typing import List, Optional
# Third-party
from fastapi import APIRouter, Depends
# Local
from app.models import User
Async/Await¶
# ✅ Async pour toute I/O
async def process_message(content: str) -> str:
tasks = [detect_pii(content), get_context(user_id)]
pii, context = await asyncio.gather(*tasks)
return await generate_response(content, context)
Formatage¶
| Outil | Config |
|---|---|
| Black | --line-length=120 |
| isort | --profile=black |
| Flake8 | --max-line-length=120 |
Commits¶
Format: type(scope): description en français
Types:
feat: Nouvelle fonctionnalitéfix: Correction de bugtest: Ajout de testsdocs: Documentationrefactor: Refactoring