Contributor License Agreement (CLA): By contributing to this repository, you agree to the terms outlined in the CLA.md. Please read and ensure you understand and agree to the terms before submitting any contributions.
Thank you for your interest in contributing to the xai-sdk-python project! This guide outlines the process for external developers to add new features, fix bugs, or improve documentation through pull requests (PRs).
As an external contributor, you can propose changes to the codebase, tests, or documentation via PRs. However, version bumps and release processes are managed internally by the project maintainers. Your contributions will be reviewed and, if approved, merged into the main branch.
Note on Contribution Size: If you are considering a larger change or reporting a significant bug, we encourage you to first create a feature request or bug report issue in the repository. This allows for discussion and alignment with the project maintainers before investing time in a pull request. For small fixes, such as correcting typos or making minor documentation improvements, feel free to submit a pull request directly.
- Fork the Repository: If you are an external contributor, start by forking the
xai-sdk-pythonrepository to your own GitHub account. This creates a copy of the repository under your control. - Clone the Repository: Clone the forked repository to your local machine and navigate to the project directory.
- Set Up Python Environment: Ensure you have a version of Python ≥3.10 installed, as this project only supports Python 3.10 and above. The project uses
uvfor dependency management, so you'll also need to install it if not already installed. - Install Dependencies: Run
uv syncto install the project dependencies into a virtual environment.uv syncwill create the virtual environment and install all project dependencies for you. - Install pre-commit hooks: Run
uv run pre-commit installto install the pre-commit hooks. This repo is configured to run pre-commit hooks such as ruff linting, formatting and secret detection preventing you from accidentally committing erroneous changes.
- Branch Off
main: Create a new branch from themainbranch for your feature or fix. Name it descriptively, e.g.,feature/add-support-for-file-uploadsorbugfix/resolve-api-error. - Implement Your Changes: Write your code, add tests, and ensure your changes adhere to the project's coding standards.
- Run Formatting Check: Execute
uv run ruff format --checkto ensure your code adheres to the project's formatting standards. If issues are found, runuv run ruff formatto automatically fix them. - Run Linting Check: Execute
uv run ruff checkto check for code quality and style issues. Address any warnings or errors reported. - Run Type Safety Check: Execute
uv run pyrightto verify type annotations and ensure type safety. - Run Tests: Execute
uv run pytest -n auto -vto run the test suite locally. This ensures your changes don't break existing functionality. - Fix Issues: Address any issues identified by these checks before proceeding to the next step.
Checks Involved:
- These are the same checks as in the
ci.yamlGitHub Actions workflow, allowing you to catch formatting, linting, type safety, and test issues locally before pushing to the remote repository.
- Commit Changes: Commit your changes with meaningful commit messages that clearly describe the purpose of your changes.
- Push to Remote: Push your branch to the remote repository (your fork or the main repository if you have write access).
Checks Involved: None at this stage. Checks will be triggered once a pull request is created.
- Open a PR: Create a pull request from your feature branch in your forked repository to the
mainbranch of thexai-sdk-pythonrepository. - Add a Detailed Description: Provide a high-quality description of the changes in your PR. Explain the purpose, the problem it solves, and any relevant context. This helps maintainers review your contribution effectively.
- Trigger CI Checks: The
ci.yamlworkflow will automatically run on your PR. This includes:- Formatting Check: Ensures code adheres to formatting standards using
ruff format --check. - Linting Check: Checks for code quality and style issues using
ruff check. - Type Safety Check: Verifies type annotations using
pyright. - Tests: Runs the test suite with
pytestacross multiple Python versions (3.10 to 3.13) to ensure compatibility and correctness.
- Formatting Check: Ensures code adheres to formatting standards using
Checks Involved:
ci.yamlensures your code meets quality and compatibility standards.
- Review Feedback: Address any comments or issues raised by reviewers or failing CI checks.
- Re-run Checks: Push updates to your branch, and the CI checks will re-run automatically.
- Merge PR: Once approved by maintainers and all checks pass, your PR will be merged into
main. Note that merging does not trigger a release; release processes are handled internally.
Checks Involved: Same as Step 5, re-triggered on each push to the PR branch.