|
| 1 | +# Contributing to ScraperGuard |
| 2 | + |
| 3 | +Thanks for your interest in contributing to ScraperGuard! |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +1. Clone the repository: |
| 8 | + |
| 9 | +```bash |
| 10 | +git clone https://github.com/mostafam-dev/scraperguard.git |
| 11 | +cd scraperguard |
| 12 | +``` |
| 13 | + |
| 14 | +2. Install in development mode: |
| 15 | + |
| 16 | +```bash |
| 17 | +pip install -e ".[dev]" |
| 18 | +``` |
| 19 | + |
| 20 | +Or with uv: |
| 21 | + |
| 22 | +```bash |
| 23 | +uv sync --extra dev |
| 24 | +``` |
| 25 | + |
| 26 | +3. Verify the installation: |
| 27 | + |
| 28 | +```bash |
| 29 | +pytest |
| 30 | +scraperguard --help |
| 31 | +``` |
| 32 | + |
| 33 | +## Running Tests |
| 34 | + |
| 35 | +```bash |
| 36 | +# Run all tests |
| 37 | +pytest |
| 38 | + |
| 39 | +# Run with coverage |
| 40 | +pytest --cov=scraperguard --cov-report=term-missing |
| 41 | + |
| 42 | +# Run a specific test file |
| 43 | +pytest tests/test_health.py |
| 44 | + |
| 45 | +# Run tests matching a pattern |
| 46 | +pytest -k "test_schema" |
| 47 | +``` |
| 48 | + |
| 49 | +## Code Style |
| 50 | + |
| 51 | +We use [ruff](https://docs.astral.sh/ruff/) for linting and formatting: |
| 52 | + |
| 53 | +```bash |
| 54 | +# Check for lint errors |
| 55 | +ruff check src/ tests/ |
| 56 | + |
| 57 | +# Auto-fix lint errors |
| 58 | +ruff check --fix src/ tests/ |
| 59 | + |
| 60 | +# Format code |
| 61 | +ruff format src/ tests/ |
| 62 | +``` |
| 63 | + |
| 64 | +Configuration is in `pyproject.toml` under `[tool.ruff]`. |
| 65 | + |
| 66 | +## Type Checking |
| 67 | + |
| 68 | +We use [mypy](https://mypy.readthedocs.io/) for static type checking: |
| 69 | + |
| 70 | +```bash |
| 71 | +mypy src/scraperguard/ |
| 72 | +``` |
| 73 | + |
| 74 | +Configuration is in `pyproject.toml` under `[tool.mypy]`. |
| 75 | + |
| 76 | +## Submitting Changes |
| 77 | + |
| 78 | +1. Fork the repository and create a feature branch: |
| 79 | + |
| 80 | +```bash |
| 81 | +git checkout -b feature/my-feature |
| 82 | +``` |
| 83 | + |
| 84 | +2. Make your changes, ensuring: |
| 85 | + - All tests pass (`pytest`) |
| 86 | + - Code is formatted (`ruff format`) |
| 87 | + - No lint errors (`ruff check`) |
| 88 | + - Types check cleanly (`mypy src/scraperguard/`) |
| 89 | + |
| 90 | +3. Write tests for new functionality. |
| 91 | + |
| 92 | +4. Commit with a clear message describing the change. |
| 93 | + |
| 94 | +5. Open a pull request against the `main` branch. |
| 95 | + |
| 96 | +## Project Structure |
| 97 | + |
| 98 | +``` |
| 99 | +src/scraperguard/ # Main package source |
| 100 | +tests/ # Test suite (mirrors src/ structure) |
| 101 | +examples/ # Working examples and configs |
| 102 | +docs/ # Documentation |
| 103 | +``` |
| 104 | + |
| 105 | +## Reporting Issues |
| 106 | + |
| 107 | +Please open an issue on GitHub with: |
| 108 | +- A clear description of the problem |
| 109 | +- Steps to reproduce |
| 110 | +- Expected vs actual behavior |
| 111 | +- Python version and OS |
0 commit comments