Setup for development

Clone the repository

git clone git@gitlab.com:scimba/scimba.git
cd scimba

Create a virtual environment and install the package in editable mode

uv venv  # create a virtual environment
source .venv/bin/activate  # activate the virtual environment
uv sync --all-groups  # install all dependencies
python3 -m venv .venv  # create a virtual environment
source .venv/bin/activate  # activate the virtual environment
# upgrade pip to the latest version (at least 25.1) to use the --group option
pip install --upgrade pip
# install the package in editable mode with development dependencies
pip install -e . --group dev

Install pre-commit hooks

Pre-commit hooks are used to ensure code quality before committing changes. The sequence of hooks is triggered automatically on git commit. Its configuration is in the .pre-commit-config.yaml file.

Warning

pre-commit may seem restrictive at first, but it is very useful for maintaining code quality and uniformity. If you don’t use it, you risk committing style errors or formatting issues that will cause failures in automated tests. Note that many style issues can be automatically fixed by ruff --fix triggered by pre-commit.

To install the pre-commit hooks, run:

pre-commit install

Except for the test suite and documentation builds, only files that have been indexed (using git add) will be checked by the hooks. To test it manually before committing, you can run:

pre-commit run

To test them on all files, you can run:

pre-commit run --all-files

To test only specific hooks, you can use, for example, for ruff:

pre-commit run ruff --all-files

To skip the pre-commit hooks for a specific commit, let’s say pytest, you can use:

SKIP=pytest git commit -m "Your commit message"

Tip

To execute the test suite pytest in parallel using all available CPU cores (see Run the test suite in parallel), you can use:

export PYTEST_ADDOPTS="$PYTEST_ADDOPTS -n auto"

To make this setting permanent in your VSCode terminal, you can add it to a file named .env in the project root of the repository (make sure to add this file to your .gitignore to avoid committing it).

PYTEST_ADDOPTS="-n auto"