Files
ruff/CLAUDE.md
Charlie Marsh 60f7ec90ef Add a fast-test profile (#22382)
## Summary

We use this profile in uv to create success, as an optimization for the
iterative test loop. We include `opt-level=1` because it ends up being
"worth it" for testing (empirically), even though it means the build is
actually a big slower than `dev` (if you remove `opt-level=1`, clean
compile is about 22% faster than `dev`).

Here are some benchmarks I generated with Claude -- the main motivator
here is the incremental testing for `ty_python_semantic` which is 2.4x
faster:

### `ty_python_semantic`

Full test suite (471 tests):
| Scenario    | dev   | fast-test | Improvement |
|-------------|-------|------------|-------------|
| Clean       | 53s   | 49s        | 8% faster   |
| Incremental | 17.8s | 6.8s       | 2.4x faster |

Single test:
| Scenario    | dev   | fast-test | Improvement |
|-------------|-------|------------|-------------|
| Clean       | 42.5s | 55.3s      | 30% slower  |
| Incremental | 6.5s  | 6.1s       | ~same       |

### `ruff_linter`

Full test suite (2622 tests):
| Scenario    | dev   | fast-test | Improvement |
|-------------|-------|------------|-------------|
| Clean       | 31s   | 41s        | 32% slower  |
| Incremental | 11.9s | 10.5s      | 12% faster  |

Single test:
| Scenario    | dev  | fast-test | Improvement |
|-------------|------|------------|-------------|
| Clean       | 26s  | 36.5s      | 40% slower  |
| Incremental | 4.5s | 5.5s       | 22% slower  |
2026-01-05 19:35:43 +00:00

2.0 KiB

Ruff Repository

This repository contains both Ruff (a Python linter and formatter) and ty (a Python type checker). The crates follow a naming convention: ruff_* for Ruff-specific code and ty_* for ty-specific code. ty reuses several Ruff crates, including the Python parser (ruff_python_parser) and AST definitions (ruff_python_ast).

Running Tests

Run all tests (using nextest for faster execution):

cargo nextest run

For faster test execution, use the fast-test profile which enables optimizations while retaining debug info:

cargo nextest run --cargo-profile fast-test

Run tests for a specific crate:

cargo nextest run -p ty_python_semantic

Run a specific mdtest (use a substring of the test name):

MDTEST_TEST_FILTER="<filter>" cargo nextest run -p ty_python_semantic mdtest

Update snapshots after running tests:

cargo insta accept

Running Clippy

cargo clippy --workspace --all-targets --all-features -- -D warnings

Running Debug Builds

Use debug builds (not --release) when developing, as release builds lack debug assertions and have slower compile times.

Run Ruff:

cargo run --bin ruff -- check path/to/file.py

Run ty:

cargo run --bin ty -- check path/to/file.py

Pull Requests

When working on ty, PR titles should start with [ty] and be tagged with the ty GitHub label.

Development Guidelines

  • All changes must be tested. If you're not testing your changes, you're not done.
  • Get your tests to pass. If you didn't run the tests, your code does not work.
  • Follow existing code style. Check neighboring files for patterns.
  • Always run uvx pre-commit run -a at the end of a task.
  • Avoid writing significant amounts of new code. This is often a sign that we're missing an existing method or mechanism that could help solve the problem. Look for existing utilities first.
  • Avoid falling back to patterns that require panic!, unreachable!, or .unwrap(). Instead, try to encode those constraints in the type system.