Contributing to PyPinergy
Thank you for your interest in contributing to PyPinergy!
Development Setup
-
Clone the repository:
git clone https://github.com/irishsmurf/pypinergy.git cd pypinergy -
Install in editable mode with dev dependencies:
pip install -e ".[dev]"
Coding Standards
- Type Hints: All public methods and functions must have type hints.
- Linting: We use Ruff for linting and formatting. Run it with:
ruff check . ruff format . - Static Analysis: Use
mypyto verify types:mypy src/pypinergy
Testing
We use pytest for all tests.
Unit Tests
Unit tests use the responses library to mock API calls. They do not require an internet connection or Pinergy credentials.
pytest tests/unit/
Integration Tests
Integration tests hit the real Pinergy API.
- Network-only (no credentials):
pytest tests/integration/ -m network - Full (requires credentials):
export PINERGY_EMAIL="your-email" export PINERGY_PASSWORD="your-password" pytest tests/integration/
Adding a New Endpoint
- Model: Add a new dataclass to
src/pypinergy/models.pywith a_from_dictmethod. - Client: Add the corresponding method to
PinergyClientinsrc/pypinergy/client.py. - Export: Export the new model in
src/pypinergy/__init__.py. - Test: Add a unit test in
tests/unit/test_client.pyusing a mock response.
Pull Request Process
- Create a branch for your feature or bugfix.
- Ensure all tests pass and linting is clean.
- Update the
CHANGELOG.mdwith your changes. - Submit the PR against the
mainbranch.