|
| 1 | +# Contributing to divine-thegraph-token-api |
| 2 | + |
| 3 | +## Development Setup |
| 4 | + |
| 5 | +### 1. Clone the repository |
| 6 | +```bash |
| 7 | +git clone https://github.com/codebydivine/token-api.git |
| 8 | +cd token-api |
| 9 | +``` |
| 10 | + |
| 11 | +### 2. Create a virtual environment |
| 12 | +```bash |
| 13 | +python3 -m venv .venv |
| 14 | +source .venv/bin/activate # On Windows: .venv\Scripts\activate |
| 15 | +``` |
| 16 | + |
| 17 | +### 3. Install development dependencies |
| 18 | +```bash |
| 19 | +pip install -e ".[dev]" |
| 20 | +``` |
| 21 | + |
| 22 | +### 4. Set up pre-commit hooks |
| 23 | +```bash |
| 24 | +# Run the setup script |
| 25 | +./scripts/setup-hooks.sh |
| 26 | + |
| 27 | +# Or manually: |
| 28 | +pre-commit install |
| 29 | +``` |
| 30 | + |
| 31 | +## Code Style |
| 32 | + |
| 33 | +This project uses automated code formatting and linting: |
| 34 | + |
| 35 | +- **ruff**: For code formatting and linting |
| 36 | +- **mypy**: For type checking |
| 37 | +- **pre-commit**: Automatically runs formatters before each commit |
| 38 | + |
| 39 | +### Manual formatting |
| 40 | +```bash |
| 41 | +# Format all files |
| 42 | +pre-commit run --all-files |
| 43 | + |
| 44 | +# Or just ruff |
| 45 | +ruff format . |
| 46 | +ruff check --fix . |
| 47 | +``` |
| 48 | + |
| 49 | +### Commit hooks |
| 50 | +When you commit, pre-commit will automatically: |
| 51 | +1. Format your code with `ruff format` |
| 52 | +2. Fix linting issues with `ruff check --fix` |
| 53 | +3. Remove trailing whitespace |
| 54 | +4. Ensure files end with a newline |
| 55 | +5. Check YAML/JSON/TOML syntax |
| 56 | +6. Run mypy type checking |
| 57 | + |
| 58 | +If any files are modified by the hooks, the commit will fail and you'll need to: |
| 59 | +1. Review the changes |
| 60 | +2. Stage them with `git add` |
| 61 | +3. Commit again |
| 62 | + |
| 63 | +### Bypassing hooks (not recommended) |
| 64 | +```bash |
| 65 | +git commit --no-verify |
| 66 | +``` |
| 67 | + |
| 68 | +## Running Tests |
| 69 | + |
| 70 | +```bash |
| 71 | +# Run all tests with coverage |
| 72 | +pytest |
| 73 | + |
| 74 | +# Run specific test file |
| 75 | +pytest tests/test_evm_api.py |
| 76 | + |
| 77 | +# Run with verbose output |
| 78 | +pytest -v |
| 79 | +``` |
| 80 | + |
| 81 | +## Making Changes |
| 82 | + |
| 83 | +1. Create a new branch: `git checkout -b feature/your-feature` |
| 84 | +2. Make your changes |
| 85 | +3. Ensure tests pass: `pytest` |
| 86 | +4. Commit your changes (pre-commit will format automatically) |
| 87 | +5. Push and create a pull request |
| 88 | + |
| 89 | +## Code Quality Standards |
| 90 | + |
| 91 | +- Maintain >90% test coverage |
| 92 | +- All functions should have type hints |
| 93 | +- Follow the existing code style |
| 94 | +- Add tests for new functionality |
| 95 | +- Update documentation as needed |
0 commit comments