Code Style
Each repository enforces consistent code style through automated tools. CI will reject changes that don’t conform.
General Conventions
Section titled “General Conventions”Naming
Section titled “Naming”Use standard naming conventions for Python and TypeScript. Use a _unit suffix in time-related variables e.g. max_idle_seconds.
Type Hints
Section titled “Type Hints”Use type hints on all public functions both in Python and in TypeScript e.g.:
def get_user(id: int) -> User:export const getUser = (id: number): User => { ... }Comments
Section titled “Comments”Use docstrings or JSDocs for all complex functions and classes. Each docstring must include an Args: section that explicitly defines the purpose of every parameter e.g.:
def log_generator(thefile: TextIOWrapper, event: threading.Event = None, max_idle_seconds: float = 3600, polling_interval_seconds: float = 1) -> Iterator[str]: """ Generator equivalent to `tail -f` Linux command. Yields new lines appended to the end of the file. Main purpose is monitoring of the log files.
Args: thefile: File object to read from. event: Threading event to signal when to stop the generator. max_idle_seconds: Maximum time to wait for new data before raising TimeoutError. polling_interval_seconds: Interval between successive file polls while no new data is available. """Python (Backend & Converter)
Section titled “Python (Backend & Converter)”Pre-Commit Hooks
Section titled “Pre-Commit Hooks”Both Python repos use pre-commit to run checks before every commit:
poetry run pre-commit install # Install hooks (once)poetry run pre-commit run --all-files # Run manuallyThe .pre-commit-config.yaml typically includes:
| Hook | Purpose |
|---|---|
yapf | Code formatting |
isort | Import ordering |
trailing-whitespace | Remove trailing spaces |
end-of-file-fixer | Ensure newline at end of file |
check-yaml | Validate YAML files |
check-merge-conflict | Detect leftover merge markers |
TypeScript (Frontend)
Section titled “TypeScript (Frontend)”Linter — ESLint
Section titled “Linter — ESLint”The frontend uses ESLint with a configuration extending CRA defaults:
npm run lint # Check for issuesnpm run lint -- --fix # Auto-fix where possibleFormatter — Prettier
Section titled “Formatter — Prettier”Prettier handles all formatting for TypeScript, JSON, CSS, and Markdown. To apply formatting use:
npm run format