## Summary AFAIK, many of us on the team are using prek now. It seems appropriate to modify the docs to formalize it.
2.1 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 prek run -aat 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. - Prefer let chains (
if letcombined with&&) over nestedif letstatements to reduce indentation and improve readability.