Coding Standards
Coding standards for the Rhesis project: quality, consistency, and easier reviews.
Code quality Shared conventions reduce bugs and make changes easier to review. Follow these guidelines for all contributions.
Python Standards
Code Style
We follow PEP 8 and use Ruff for formatting and linting.
Basic rules:
- Indentation: 4 spaces (no tabs)
- Line length: 100 characters maximum
- Naming:
snake_casefor variables, functions, and modules - Classes:
PascalCase - Constants:
UPPER_CASE
Type hints
Use type hints on new and updated functions and methods.
Docstrings
Use Google-style docstrings for public functions and classes:
Error handling
Prefer specific exceptions, avoid bare except:, and use raise ... from err when
chaining:
Testing
- Use pytest; put tests under the paths each package documents (e.g.
tests/backend,tests/sdk). - Cover new behavior and regressions; mock external I/O where appropriate.
- Run checks with each app’s Makefile (
make test,make lint, etc.) fromapps/backend,sdk, orapps/frontendas applicable.
JavaScript/TypeScript Standards
Code style
ESLint and Prettier enforce formatting.
Basic rules:
- Indentation: 2 spaces
- Line length: 100 characters maximum
- Naming:
camelCasefor values and functions;PascalCasefor components - Constants:
UPPER_SNAKE_CASE
TypeScript
Use strict typing for new code:
React components
Prefer function components, typed props, and hooks; keep components small:
Custom hooks
Encapsulate data fetching and shared state in hooks (e.g. React Query for server state):
Error handling
Use error boundaries for UI trees; log or report unexpected errors in one place: