# Ruff - An extremely fast Python linter and code formatter, written in Rust

## Installation

Using uv:
```bash
uv add --dev ruff     # Add to project
uv tool install ruff  # Install globally
```

Using other package managers:
```bash
pip install ruff                  # Using pip
pipx install ruff                 # Using pipx
brew install ruff                 # Using Homebrew
conda install -c conda-forge ruff # Using Conda
```

## Basic Usage

Lint files:
```bash
ruff check                     # Check current directory
ruff check path/to/file.py    # Check specific file
ruff check --fix              # Auto-fix issues
ruff check --watch           # Watch mode
```

Format files:
```bash
ruff format                  # Format current directory
ruff format path/to/file.py # Format specific file
ruff format --check         # Check formatting without changes
```

## Advanced Features

File selection and fixes:
```bash
ruff check --unsafe-fixes                         # Show unsafe fixes
ruff check --fix --unsafe-fixes                   # Apply unsafe fixes
ruff check path/to/file.py --extend-select RUF100 # Check specific rules
ruff check path/to/file.py --add-noqa             # Add noqa directives
```

Configuration:
```bash
ruff check --config path/to/ruff.toml                      # Use config file
ruff check --config "lint.dummy-variable-rgx = '__.*'"     # Inline config
ruff format --line-length=90                              # Format options
```

Docker usage:
```bash
docker run -v .:/io --rm ghcr.io/astral-sh/ruff check     # Run in Docker
docker run -v .:/io --rm ghcr.io/astral-sh/ruff:0.3.0 check # Specific version
```

## VS Code Integration

```json
{
  "[python]": {
    "editor.codeActionsOnSave": {
      "source.fixAll.ruff": "explicit",
      "source.organizeImports.ruff": "explicit"
    }
  }
}
```

## Common Commands

- `ruff check`: Run linter
- `ruff format`: Run formatter
- `ruff rule`: Explain rules
- `ruff config`: Show configuration
- `ruff clean`: Clear caches
- `ruff version`: Show version
- `ruff help`: Show help
