Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.38 KB

ASTRAL_RUFF_UV.md

File metadata and controls

55 lines (40 loc) · 1.38 KB

Astral Tool Chain

https://astral.sh/ are the makers of:

  • ruff
    • drop in replacements for a bunch of Python linting and formatting tools but rewritten in Rust.
  • uv
    • drop in replacement for pip and piptools

This section needs to get fleshed out better.

Precommit setup

.pre-commit-config.yml

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
  # Ruff version.
  rev: v0.4.4
  hooks:
    # Run the formatter.
    - id: ruff-format
      types_or: [ python, pyi, jupyter ]
    # Run the linter.
    - id: ruff
      types_or: [ python, pyi, jupyter ]
      args: [ --fix ]

Installing Precommit and Astral tool chain

Example Makefile steps:

# Depends if the virtual environment has been setup
init: .venv/bin/python3

# The output of this step is ensuring the virtual environment is setup correctly
# It is here we guarantee uv and pre-commit get installed.
.venv/bin/python3:
	[ ! -d ".venv" ] && python3 -m venv .venv || echo ".venv already setup"
	.venv/bin/python3 -m pip install -qq --upgrade pip uv wheel pre-commit
	.venv/bin/pre-commit install