This project uses Ruff for Python linting and code formatting. All developers must ensure their code passes linting checks before submitting pull requests.
The linting dependencies are already included in pyproject.toml. Install them with:
uv sync --group lintOr install all groups including dev:
uv syncuv run ruff check .uv run ruff check . --fixuv run ruff format --check .uv run ruff format .Ruff configuration is defined in pyproject.toml under [tool.ruff] and [tool.ruff.lint] sections.
- E, W: PEP 8 errors and warnings
- F: Pyflakes (undefined names, unused imports)
- I: isort-style import sorting
- C4: flake8-comprehensions (optimization suggestions)
- UP: pyupgrade (modernize Python code)
- PIE: flake8-pie (misc linting rules)
- RUF: Ruff-specific rules (
not applied currently)
The following directories are excluded from linting:
.git,.venv,.pytest_cache,.ruff_cache,.vscodenode_modules,vdb,ray_mount,model_weights,logs.astro,openrag.egg-info
A GitHub Actions workflow (.github/workflows/lint.yml) automatically runs on every push and pull request. The workflow:
- Checks for linting issues with
ruff check - Verifies code formatting with
ruff format --check - Reports results directly to GitHub (with file and line annotations)
All pull requests must pass the linting CI check. If your PR fails:
- Run
uv run ruff check . --fixto auto-fix issues - Run
uv run ruff format .to format the code - Review any remaining issues that require manual fixes
- Commit and push your changes
One can also setup a pre-commit hook to run linting automatically before each commit.
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
# Get list of staged Python files
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
if [ -z "$FILES" ]; then
exit 0
fi
# Run ruff check (will auto-fix if possible)
echo "Running ruff check..."
uv run ruff check $FILES --fix
# Run ruff format
echo "Running ruff format..."
uv run ruff format $FILES
# Re-add the modified files
git add $FILES
# Run ruff check again without --fix to catch remaining errors
echo "Checking for remaining issues..."
uv run ruff check $FILES
# If ruff check fails, block the commit
if [ $? -ne 0 ]; then
echo "Ruff check failed. Please fix errors before committing."
exit 1
fi
exit 0
EOF
chmod +x .git/hooks/pre-commit- To disable pre-commit
rm .git/hooks/pre-commitMake sure you've installed the lint dependencies:
uv sync --group lintSome issues require manual fixes. Review the error messages and fix them manually, then commit again. Sometimes, you will have to ignore a particular check if deemed unnecessary
# Example: C417 rule suggest that map here is unnecessary
docs_with_tokens = list(map(lambda d: (_length_function(d.page_content), d), docs)) # noqa: C417