First off, thank you for considering contributing to DeepQuantum! It’s people like you who make the open-source community such an amazing place to learn, inspire, and create.
To maintain high code quality and a consistent developer experience, we have established a modern workflow using Ruff, Jupytext, and pre-commit hooks. Please follow these guidelines to get started.
Before you start coding, ensure you have the development dependencies installed.
We recommend using a Conda environment combined with uv for blazing-fast dependency management.
- Install Dependencies: Navigate to the project root and install the package in editable mode along with development tools.
# Highly Recommended: Using uv
uv pip install -e ".[dev]"
# Fallback: Using pip
pip install -e .
pip install -r requirements-dev.txt- Install pre-commit hooks:
We use
pre-committo automate code linting and formatting. This ensures your code is compliant before every commit. (Note: Our setup includespre-commit-uv, which will automatically utilize theuvengine to execute these hooks at lightning speed!)
pre-commit install- Initialize Environment: It is a good practice to run the hooks against all files once to ensure your local environment is in sync:
pre-commit run --all-filesWe use Ruff as our primary linter and formatter. Our configuration includes:
- Line Length: 120 characters.
- Quote Style: Single quotes (
'). - Imports: Sorted automatically (isort rules).
We enforce a strict set of rules, including Python upgrade suggestions (UP), naming conventions (N), and code simplifications (SIM).
- In the
src/directory: We additionally enforce Google-style docstrings. Please ensure your functions and classes are well-documented.
We recommend installing the Ruff extension for VS Code or your preferred IDE. Enable Format on Save to handle most styling issues automatically.
Our tutorials and examples are managed using Jupytext.
This allows us to maintain Jupyter Notebooks (.ipynb) while tracking version-control-friendly Python scripts (.py:percent).
Maintain the .ipynb files only.
The paired .py files are automatically generated or updated via pre-commit hooks.
We recommend installing the Jupytext extension for VS Code or your preferred IDE to sync files automatically.
Important
Version Consistency: The VS Code Jupytext extension often points to a global path rather than your active Conda environment. Please ensure that the Jupytext version used by your IDE matches the one installed in your environment to avoid formatting discrepancies.
To keep the development tools up to date with the latest security fixes and features, please occasionally update the pre-commit hook versions:
pre-commit autoupdate- Create a Branch: Use a descriptive name like
feat/new-modelorfix/issue-123. - Commit Your Changes:
- If
pre-commitfails during commit, it will often automatically fix the issues. - Simply re-add (
git add) the fixed files and commit again.
- If
- Reference Issues: In your PR description, use keywords like
Closes #123to link the PR to an issue. - Clean History: We prefer a clean commit history.
Please consider squashing your commits or rebasing on
mainbefore the final review.
For source code, we follow the Google Docstring Convention.
D102/D105/D107: We currently ignore missing docstrings in public methods and magic methods to reduce boilerplate, but we highly encourage documenting any complex logic.
If you have questions about the setup or a specific feature, feel free to:
- Open an Issue on GitHub.
Thank you for contributing to the future of quantum computing!