Contributing to the SDK
We welcome contributions from the community to improve the Hyperliquid Python SDK. This guide outlines the process for setting up your development environment, running tests, and submitting your changes.
Development Environment Setup
The project uses Poetry for dependency management and requires Python 3.10 for development.
-
Fork and Clone the Repository: Start by forking the official repository on GitHub, then clone your fork to your local machine:
git clone https://github.com/YOUR_USERNAME/hyperliquid-python-sdk.git cd hyperliquid-python-sdk
-
Install Poetry: If you don't have Poetry installed, follow the official installation guide.
-
Install Dependencies: The project includes a
Makefile
that simplifies the setup process. This command will create a virtual environment within the project folder and install all necessary dependencies.make install
-
Activate the Virtual Environment: To start working, activate the Poetry-managed virtual environment:
poetry shell
Running Linters and Formatters
We use a set of linters and formatters to maintain code quality and consistency. These are managed through pre-commit
.
To run all checks on all files, use the Makefile
:
make lint
This command executes the pre-commit hooks defined in .pre-commit-config.yaml
, which include:
black
: For code formatting.isort
: For sorting imports.flake8
: For style guide enforcement.mypy
: For static type checking.pylint
: For code analysis.bandit
: For finding common security issues.
We recommend installing the pre-commit hooks to run automatically before each commit:
poetry run pre-commit install
Running Tests
The SDK has a test suite built with pytest
. To run all tests and generate a coverage report:
make test
The tests use pytest-recording
with VCR.py
to record and replay API interactions, allowing tests to run offline without hitting the live API. Test fixtures are stored as .yaml
files in the tests/cassettes
directory.
Submitting Changes
-
Create a new branch for your feature or bug fix:
git checkout -b feature/my-new-feature
-
Make your changes and commit them. Ensure your commit messages are clear and descriptive.
- Make sure all linters and tests pass successfully.
-
Push your branch to your fork on GitHub:
git push origin feature/my-new-feature
-
Open a pull request from your fork to the
master
branch of the official repository. - Provide a detailed description of your changes in the pull request.
Release Process
This project follows the Semantic Versioning specification.
-
Bump the Version: Use Poetry to update the package version in
pyproject.toml
.# Examples: poetry version patch poetry version minor poetry version 1.0.0
-
Commit and Tag: Commit the version change and create a new git tag.
- Create a GitHub Release: A release is automatically drafted by the
Release Drafter
action as pull requests are merged. Publish this draft. - Publish to PyPI: Build and publish the package using Poetry.
poetry publish --build
Reporting Security Issues
If you discover a security vulnerability, please do not open a public issue. Instead, report it privately by following the instructions in the SECURITY.md file.