This repository contains a small utility used by a research group to summarize temperature readings from laboratory sensors. The program works, but its style has not yet been brought in line with the project's automated checks.
Your job is to use Ruff to format and lint the code, verify that its behavior has not changed, and commit the cleaned-up version.
Create or activate a Python environment, then install the development tools:
python -m pip install -r requirements-dev.txtRun the program and its tests before changing anything:
python sensor_report.py
python -m pytestBoth commands should succeed. Now ask Ruff to report the current problems:
python -m ruff format --check .
python -m ruff check .Read the output. Notice that the formatter and linter report different kinds of problems.
Let Ruff format the Python files:
python -m ruff format .Apply Ruff's safe lint fixes:
python -m ruff check --fix .Inspect what changed:
git diffRun the same checks used by the autograder:
python -m ruff format --check .
python -m ruff check .
python -m pytestAlso run the program once more and compare its output with the baseline. Then commit and submit your work:
git status
git add sensor_report.py
git commit -m "Apply Ruff formatting and lint fixes"After the Ruff checks pass, make them run automatically before future commits. Create .pre-commit-config.yaml with the following content:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.4
hooks:
- id: ruff-check
args: [--fix, --show-fixes]
- id: ruff-formatEnable and exercise the hooks:
pre-commit install
pre-commit run --all-files
git add .pre-commit-config.yaml
git commit -m "Run Ruff with pre-commit"
gh student submitThe hook installation lives inside .git/ and is local to your clone. The YAML configuration is committed so every contributor can install the same hooks.