CLI tool and Python API wrapper for Gerrit Code Review
Python 3.11+ is required. This project uses modern Python features and tooling.
UV is a fast, modern Python package manager. Recommended for the best experience.
-
Install UV (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Clone the repository:
git clone https://github.com/tivaliy/python-gerritclient.git cd python-gerritclient -
Configure
settings.yamlfile (ingerritclient/settings.yaml):url: http://review.example.com auth_type: basic username: admin password: "1234567890aaWmmflSl+ZlOPs23Dffn"
url- Gerrit server URL in format<scheme>://<host>:<port>(e.g.,https://review.openstack.org)auth_type- HTTP authentication scheme (basicordigest), omit for anonymous accessusernameandpassword- user credentials from Gerrit (Settings → HTTP Password)
-
Install dependencies and run:
uv sync uv run gerrit --help
-
Run commands:
uv run gerrit plugin list uv run gerrit account list "john"
-
Clone the repository:
git clone https://github.com/tivaliy/python-gerritclient.git cd python-gerritclient -
Configure
settings.yaml(same as above) -
Install with pip:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e .
-
Run commands:
gerrit --help gerrit plugin list
Install the package:
# With UV
uv add python-gerritclient
# With pip
pip install python-gerritclientfrom gerritclient import client
connection = client.connect("review.openstack.org", auth_type="digest" username="user-name", password="password")
group_client = client.get_client('group', connection=connection)
members = group_client.get_group_members('swift-core') # or get_group_members(24)
print(', '.join(member['name'] for member in members))Output result: Alistair Coles, Christian Schwede, Clay Gerrard, Darrell Bishop, David Goetz, Greg Lange, Janie Richling, John Dickinson, Kota Tsuyuzaki, Mahati Chamarthy, Matthew Oliver, Michael Barton, Pete Zaitcev, Samuel Merritt, Thiago da Silva, Tim Burke
Major modernization release! This version brings python-gerritclient into the modern Python ecosystem:
- UV Package Manager: 10-100x faster dependency resolution and installation
- Ruff Linting: 100x faster than flake8, instant code quality checks
- Modern Python: Requires Python 3.11+ (dropped Python 2.7/3.5/3.6 support)
- GitHub Actions CI/CD: Replaced Travis CI with modern GitHub Actions
- Modern pyproject.toml: Migrated from legacy setup.py/setup.cfg
- Setuptools Build Backend: Replaced pbr with modern setuptools
- Removed all Python 2 compatibility code (six library)
- Applied 100+ code modernizations (modern super(), f-strings, etc.)
- 96.7% test coverage (178/184 tests passing)
Tested and working against Gerrit 3.13.1 (latest) on production instances (Android Code Review).
- Recommended: Gerrit 3.11+ (latest tested: 3.13.1)
- Supported: Gerrit 2.14+ (backwards compatible)
- API Coverage: ~45% of Gerrit REST API
- Required: Python 3.11+
- Tested: Python 3.11, 3.12, 3.13
- Dropped: Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10
-
Install UV (recommended):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Clone and setup:
git clone https://github.com/tivaliy/python-gerritclient.git cd python-gerritclient uv sync --all-extras -
Install in editable mode:
uv pip install -e .
# Run unit tests with stestr
uv pip install stestr
uv run stestr run
# Run linting
uv run ruff check .
# Run formatting
uv run ruff format .
# Format check (CI)
uv run ruff format --check .- Linter: Ruff - Fast Python linter
- Formatter: Ruff format - Fast Python formatter
- Test Runner: stestr - Parallel test runner
- CI/CD: GitHub Actions
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting:
uv run stestr run && uv run ruff check . - Format code:
uv run ruff format . - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Apache License 2.0
Originally created by Vitalii Kulanov