Configure precommit as described in this blogpost: https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/ Commands:
- Install precommit:
pip install pre-commit - Make sure to add pre-commit to your path. For example, on a Mac system, pre-commit is installed here:
$HOME/Library/Python/3.8/bin/pre-commit. - Execute
pre-commit installto install git hooks in your.git/directory.
Python tests use Poetry 2.x and pytest. Shell tests live under tests/.
- Python 3.9 or newer
- Poetry 2.x (
pip install "poetry>=2.0,<3.0")
From the repo root:
poetry install --only main,devThis installs runtime and dev dependencies. The optional localdev group (sibling repos such as python-commons) is not required for tests.
poetry run python -m pytestPytest is configured in pyproject.toml to collect tests from scripts/git and scripts/disk_cleanup.
With coverage (same as CI):
mkdir -p junit
poetry run python -m pytest \
--junitxml=junit/test-results.xml \
--cov=scripts/git \
--cov=scripts/disk_cleanup \
--cov-report=xml \
--cov-report=htmlCoverage HTML is written to htmlcov/. JUnit XML goes to junit/test-results.xml.
find tests -type f \( -name "*.sh" -o -name "*.zsh" \) -exec chmod +x {} \;
find tests -type f \( -name "*.sh" -o -name "*.zsh" \) -print0 | while IFS= read -r -d '' script; do
echo "Running $script..."
"$script"
doneOn Ubuntu/Debian, install zsh first if needed (sudo apt-get install -y zsh).
See scripts/disk_cleanup/README.md for usage of cleanup_disk.py.
See scripts/git/git-workflow-for-moving-large-files.md for offloading large archives from a git working tree or specific commits via git_move_large_files.py. Run it with poetry run python scripts/git/git_move_large_files.py ... from this repo so dependencies are available.
The export_claude_sessions.py script (and its session_rename_report.py companion) has been extracted to its own repository:
Full history was preserved via git-filter-repo. Clone it under ~/development/my-repos/claude-session-exporter/ and point your claude-export alias there.
In case you're facing a similar issue:
An error has occurred: InvalidManifestError:
=====> /<userhome>/.cache/pre-commit/repoBP08UH/.pre-commit-hooks.yaml does not exist
Check the log at /<userhome>/.cache/pre-commit/pre-commit.log
, please run: pre-commit autoupdate
More info here: pre-commit/pre-commit#577