mirror of
https://github.com/crytic/slither.git
synced 2026-10-12 02:12:39 +00:00
1.9 KiB
1.9 KiB
Slither Coding Standards
Runtime
| lang | version | manager |
|---|---|---|
| Python | ≥3.9 | uv |
Required tooling
| purpose | tool |
|---|---|
| deps & venv | uv |
| lint & format | ruff |
| tests | pytest |
Python guidelines
- Always use
uvinstead of pip - Build with
hatchling([build-system]in pyproject.toml) - Use
astral-sh/ruff-action@v3or newer in CI - Let tools auto-detect versions from pyproject.toml
- Verify builds:
uv build,uv tool install dist/*.whl,uv tool install -e .
Version Verification
When adding or updating dependencies, CI actions, or tool versions:
- Always web search for the current stable version before specifying any version number
- Training data versions are stale—never assume a version from memory is current
- Check the official source (PyPI, GitHub releases) for latest stable
- Exception: Only skip web search if user explicitly provides the version to use
Hard rules
- ≤ 80 code lines / function
- Cyclomatic complexity ≤ 8
- ≤ 5 positional params, ≤ 12 branches, ≤ 6 returns
- 100‑char line length
- Ban relative ("..") imports
- Tests in
/tests/mirroring package structure (not beside code) - No scheduled CI without code changes
Bash strict mode
All bash scripts must start with:
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
Common commands
make dev # Create venv and install deps
make lint # Run ruff check
make reformat # Run ruff format
make test # Run all tests
make test TESTS=unit # Run specific test directory
pytest tests/unit/ -q # Fast unit tests only
uv run ruff check --fix . # Auto-fix lint issues
Never commit changes that break any rule above—refactor instead. Never push to GitHub until asked explicitly. Don't be hyperbolic in PR/Issue writeups.