Thank you for your interest in contributing to the CardSight AI Python SDK! We welcome contributions from the community and are grateful for your support.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Development Workflow
- Code Standards
- Testing Guidelines
- Documentation
- Submitting Changes
- Release Process
By participating in this project, you agree to maintain a respectful and inclusive environment. We expect all contributors to:
- Be respectful and considerate in all interactions
- Accept constructive criticism gracefully
- Focus on what's best for the community
- Show empathy towards other community members
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/cardsightai-sdk-python.git cd cardsightai-sdk-python - Add the upstream repository:
git remote add upstream https://github.com/CardSightAI/cardsightai-sdk-python.git
- Python 3.10 or higher
- Poetry (package manager)
- Git
-
Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 - -
Install dependencies:
poetry install --with dev,docs
-
Activate the virtual environment:
poetry shell
-
Set up pre-commit hooks (optional but recommended):
make setup-pre-commit
We welcome various types of contributions:
- Bug Reports: Found a bug? Let us know!
- Feature Requests: Have an idea? We'd love to hear it!
- Code Contributions: Bug fixes, new features, or improvements
- Documentation: Improvements to README, code comments, or examples
- Tests: Additional test coverage or test improvements
When filing a bug report, please include:
- Clear title and description
- Python version (
python --version) - SDK version (
pip show cardsightai) - Code sample that reproduces the issue
- Expected behavior vs. actual behavior
- Stack trace if applicable
Use the GitHub issue template when creating a new issue.
For feature requests, please:
- Check if the feature already exists or is planned
- Clearly describe the use case and benefits
- Provide examples of how the feature would be used
- Consider whether it fits the SDK's scope and philosophy
Create a new branch for your work:
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fixBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Test additions or changes
- Write clean, readable code
- Follow the existing code style
- Add or update tests as needed
- Update documentation if required
Run the test suite:
# Run all tests
make test
# Run specific test file
poetry run pytest tests/unit/test_client.py
# Run with coverage
poetry run pytest --cov=cardsightai --cov-report=htmlEnsure code quality:
# Run linting
make lint
# Auto-format code
make format
# Type check
poetry run mypy cardsightai/Write clear, descriptive commit messages:
git add .
git commit -m "feat: add support for new endpoint
- Implement new catalog.parallels endpoint
- Add tests for parallel conversions
- Update documentation with examples"Commit message format:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Test additions or changesrefactor:- Code refactoringchore:- Maintenance tasks
- Follow PEP 8 style guide
- Use type hints for all function signatures
- Maximum line length: 120 characters (configured in ruff)
- Use descriptive variable and function names
All code should include type hints:
from typing import Optional, List, Dict, Any
def process_cards(
card_ids: List[str],
options: Optional[Dict[str, Any]] = None
) -> List[Card]:
"""Process a list of cards."""
...Use Google-style docstrings:
def identify_card(image_path: str, confidence_threshold: float = 0.8) -> Detection:
"""Identify a card from an image.
Args:
image_path: Path to the card image file
confidence_threshold: Minimum confidence level (0.0-1.0)
Returns:
Detection object with card information and confidence
Raises:
ValueError: If image_path doesn't exist
APIError: If the API request fails
Example:
>>> detection = identify_card('card.jpg')
>>> print(detection.card.name)
'Mike Trout Rookie'
"""
...- Use custom exceptions from
cardsightai.exceptions - Provide helpful error messages
- Log errors appropriately
Organize imports in this order:
# Standard library
import os
from typing import Optional
# Third-party
import httpx
from attrs import define
# Local imports
from cardsightai.exceptions import APIError
from cardsightai.models import Card- Unit tests:
tests/unit/ - Integration tests:
tests/integration/ - Fixtures:
tests/fixtures/
import pytest
from cardsightai import CardSightAI
def test_catalog_statistics():
"""Test catalog statistics endpoint."""
client = CardSightAI(api_key='test_key')
# Mock the HTTP response
with respx.mock:
respx.get("https://api.cardsight.ai/v1/catalog/statistics").mock(
return_value=httpx.Response(200, json={'cards': {'total': 1000}})
)
stats = client.catalog.statistics()
assert stats.cards.total == 1000
@pytest.mark.asyncio
async def test_async_catalog_statistics():
"""Test async catalog statistics endpoint."""
async with AsyncCardSightAI(api_key='test_key') as client:
stats = await client.catalog.statistics()
assert stats.cards.total > 0- Aim for >90% code coverage
- Test both success and failure cases
- Test edge cases and error conditions
- Use mocking for API calls in unit tests
- Integration tests should use real API (with proper keys)
- Comment complex logic
- Don't comment obvious code
- Keep comments up-to-date
If your change affects usage:
- Update relevant sections in README.md
- Add examples if introducing new features
- Update the API coverage table if needed
Significant changes should be noted in CHANGELOG.md:
## [Unreleased]
### Added
- New `catalog.parallels` endpoint support
### Fixed
- Fixed event loop handling in sync client
### Changed
- Updated httpx dependency to 0.28.1-
Update your fork:
git fetch upstream git rebase upstream/main
-
Push your changes:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub with:
- Clear title describing the change
- Detailed description of what changed and why
- Reference to related issues (e.g., "Fixes #123")
- Screenshots if UI/output changes
- Checklist of completed tasks
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests pass locally
- [ ] Added new tests for changes
- [ ] Updated documentation
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings generated- Maintainers will review your PR
- Address any feedback or requested changes
- Once approved, a maintainer will merge your PR
(For maintainers)
We follow Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes
- Update version in
cardsightai/version.py - Update
CHANGELOG.md - Create a git tag:
git tag -a v1.2.3 -m "Release version 1.2.3" git push origin v1.2.3 - GitHub Actions will automatically publish to PyPI
- Questions: Open a GitHub Discussion
- Issues: Check existing Issues
- Email: [email protected]
- Discord: Join our community
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to CardSight AI Python SDK! 🎉