Thank you for your interest in contributing to the Langbase Python SDK! We welcome contributions from the community.
- Python 3.7 or higher
- pip package manager
- git
-
Fork and clone the repository
git clone https://github.com/langbase/langbase-python-sdk cd langbase-python-sdk -
Create a virtual environment
python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
Check version of pip
pip --version
If it's pip 21.3 or lower, you need to upgrade it.
pip install --upgrade pip
-
Install the package in development mode
pip install -e . -
Install development dependencies
pip install -r requirements-dev.txt
-
Install pre-commit hooks
pre-commit install
IMPORTANT: All code must pass quality checks before committing. Run these commands:
# Auto-format with Black (required)
black langbase/ tests/ examples/
# Sort imports with isort (required)
isort langbase/ tests/ examples/# Run all tests
pytest
# Run with coverage
pytest --cov=langbase
# Run specific test file
pytest tests/test_pipes.py
# Run in verbose mode
pytest -v# This runs all pre-commit hooks (black, isort)
pre-commit run --all-filespython release.pypython -m build
twine upload dist/*
Before pushing your changes, ensure:
- ✅ Code is formatted with
black - ✅ Imports are sorted with
isort - ✅ All tests pass with
pytest - ✅ New features have tests
- ✅ New features have type hints
- ✅ Documentation is updated if needed
git checkout -b feature/your-feature-name- Write clean, readable code
- Add type hints to all functions
- Follow existing code patterns
- Add docstrings to public functions
- Write tests for new features
- Ensure existing tests still pass
- Aim for good test coverage
- Update README.md if adding new features
- Update docstrings
- Add examples if applicable
# Stage your changes
git add .
# Commit with a descriptive message
git commit -m "📖 DOC: Improved contribution docs"Follow conventional commit format:
📦 NEW:New feature🐛 BUG:Bug fix📖 Docs:Documentation changes👌🏻 IMP:Improvements
git push origin feature/your-feature-nameThen create a Pull Request on GitHub.
All functions should have type hints:
def process_data(input_text: str, max_length: int = 100) -> Dict[str, Any]:
"""Process input text and return results."""
...Use Google-style docstrings:
def my_function(param1: str, param2: int) -> bool:
"""
Brief description of function.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of return value
...- Use pytest for all tests
- Use descriptive test names
- Test both success and error cases
- Use fixtures for common setup
Example:
def test_pipe_run_with_invalid_name_raises_error(langbase_client):
"""Test that running a pipe with invalid name raises appropriate error."""
with pytest.raises(NotFoundError) as exc_info:
langbase_client.pipes.run(name="non-existent-pipe")
assert "404" in str(exc_info.value)- Check existing issues and PRs
- Read the documentation
- Ask in our Discord community
- Open an issue for bugs or feature requests
By contributing, you agree that your contributions will be licensed under the MIT License.