Skip to content

Code Style

Each repository enforces consistent code style through automated tools. CI will reject changes that don’t conform.

Use standard naming conventions for Python and TypeScript. Use a _unit suffix in time-related variables e.g. max_idle_seconds.

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 => { ... }

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.
"""

Both Python repos use pre-commit to run checks before every commit:

Terminal window
poetry run pre-commit install # Install hooks (once)
poetry run pre-commit run --all-files # Run manually

The .pre-commit-config.yaml typically includes:

HookPurpose
yapfCode formatting
isortImport ordering
trailing-whitespaceRemove trailing spaces
end-of-file-fixerEnsure newline at end of file
check-yamlValidate YAML files
check-merge-conflictDetect leftover merge markers

The frontend uses ESLint with a configuration extending CRA defaults:

Terminal window
npm run lint # Check for issues
npm run lint -- --fix # Auto-fix where possible

Prettier handles all formatting for TypeScript, JSON, CSS, and Markdown. To apply formatting use:

Terminal window
npm run format