Skip to content

Contributing

pyhood is in early development and we welcome contributions.

Development Setup

git clone https://github.com/jamestford/pyhood.git
cd pyhood
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pip install responses  # for tests

Running Tests

# All tests
pytest -v

# With coverage
pytest --cov=pyhood --cov-report=term-missing -v

# Single test file
pytest tests/test_auth.py -v

Auditing Against the Live API

The tests mock Robinhood's responses. A parser that reads a field Robinhood does not send still passes, as long as its mock has the same made-up field. That has happened more than once.

scripts/field_audit.py checks the parsers against real responses. It runs the read-only methods on a live account, records every field they ask for, and reports the ones that were never there:

python scripts/field_audit.py          # problems only
python scripts/field_audit.py --all    # every method audited

It makes GET requests only, and prints field names and counts, never values, so its output is safe to paste into an issue. Run it before a release, and when you add a parser, add the method to its audit() function.

When you write a test for a parser, build the mock from a real response rather than from the fields the parser reads.

Linting

# Check
ruff check pyhood/

# Auto-fix
ruff check --fix pyhood/

Project Structure

pyhood/
├── pyhood/
│   ├── __init__.py      # Public API (login, logout, refresh)
│   ├── auth.py          # Authentication + token management
│   ├── client.py        # PyhoodClient — high-level API
│   ├── exceptions.py    # Exception hierarchy
│   ├── http.py          # HTTP session, rate limiting, retries
│   ├── models.py        # Typed dataclasses
│   └── urls.py          # Robinhood API endpoints
├── tests/               # Test suite (responses-based mocking)
├── examples/            # Scripts that check a session against the live API
├── scripts/             # Maintainer tools (field_audit.py)
├── docs/                # MkDocs documentation
└── .github/
    └── workflows/
        └── ci.yml       # GitHub Actions CI

Guidelines

  • Type hints on all public functions and methods
  • Docstrings in Google style
  • Tests for new functionality (aim for >80% coverage)
  • No credentials in code, tests, or docs — use placeholder values
  • Run ruff check and pytest before submitting a PR

Reporting Issues