Troubleshooting¶
This guide covers common issues you might encounter when using this package and how to resolve them.
Setup Issues¶
Pre-commit Hook Installation Fails¶
Problem: pre-commit install returns an error or hooks don't run on commit.
Solutions:
- Ensure you're in the project root directory
- Verify Python virtual environment is activated
-
Reinstall pre-commit:
pip uninstall pre-commit pip install pre-commit pre-commit install pre-commit install --hook-type commit-msg -
Check if
.gitdirectory exists (must be a git repository) - Try running manually:
pre-commit run --all-files
commitlint Not Running¶
Problem: Commit messages aren't validated despite npm install being run.
Solutions:
-
Verify
npm installwas successful:npm list @commitlint/config-angular -
Re-install commitlint dependencies:
npm install --save-dev @commitlint/cli @commitlint/config-angular -
Reinstall pre-commit hooks:
pre-commit install --hook-type commit-msg -
Test manually:
echo "invalid message" | commitlint echo "feat: valid message" | commitlint
Virtual Environment Issues¶
Problem: Packages can't be found or dependencies conflict.
Solutions:
-
Create a fresh virtual environment:
rm -rf .venv python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Upgrade pip:
python -m pip install --upgrade pip -
Install dependencies:
pip install -e ".[dev,docs,test]" -
Verify installation:
python -c "import your_package; print(your_package.__version__)"
Python Version Mismatch¶
Problem: python -m venv .venv fails or tests don't run with wrong Python
version.
Solutions:
-
Check your Python version:
python --version -
Ensure Python 3.10 or higher is installed
-
Use specific Python version when creating venv:
python3.11 -m venv .venv -
Or use uv for version management:
uv venv --python 3.11 source .venv/bin/activate
Testing Issues¶
Pytest Fails to Collect Tests¶
Problem: pytest returns "no tests collected" or import errors.
Solutions:
- Verify test file naming: Must be
test_*.pyor*_test.py - Verify test function naming: Must start with
test_ - Check
__init__.pyexists in test directory:touch tests/__init__.py -
Run pytest with verbose output:
pytest -vv -
Check test discovery:
pytest --collect-only
Import Errors in Tests¶
Problem: Tests can't import your package modules.
Solutions:
-
Install package in development mode:
pip install -e ".[dev,test]" -
Verify package structure (should have
src/your_package/) - Check
pyproject.tomlhas correctpackagesconfiguration - Run from project root directory
- Verify
__init__.pyexists in package directory
Coverage Report Issues¶
Problem: Coverage report shows 0% or missing files.
Solutions:
-
Run pytest with coverage:
pytest --cov=src/your_package --cov-report=html -
Check
.coveragercorpyproject.tomlcoverage settings - Ensure source files have proper imports
- Verify test files import from
src/layout correctly
Pre-commit Hook Issues¶
Hooks Running Too Slowly¶
Problem: Pre-commit takes a very long time or times out.
Solutions:
-
Check which hooks are slow:
pre-commit run --all-files --verbose -
Consider excluding large files:
exclude: | (?x)^( large_data_file.csv| node_modules/ )$ -
Run specific hooks:
pre-commit run black --all-files # Just black
Formatting Changes After Commit¶
Problem: Pre-commit auto-fixes files, but you didn't expect it.
Solutions:
- This is normal behavior - review the changes
-
Stage the new changes:
git add . git commit -m "your message" # Try again -
Modify tool settings if behavior is unwanted (in
pyproject.toml) -
Disable specific hooks temporarily:
SKIP=black,ruff pre-commit run --all-files
"Unstaged Changes" After Running Hooks¶
Problem: Pre-commit modified files but they're not staged.
Solutions:
-
This is expected - review changes:
git diff -
Stage the changes:
git add . -
Try committing again
- Or use
git add -Ato stage all changes before commit
Dependency Conflicts¶
Problem: pip install fails with conflict messages.
Solutions:
-
Check Python version:
python --version -
Create fresh virtual environment:
rm -rf .venv && python -m venv .venv source .venv/bin/activate -
Upgrade pip:
python -m pip install --upgrade pip -
Install with verbose output to see conflict:
pip install -e ".[dev,docs,test]" -vv -
Check
pyproject.tomlfor overly restrictive version constraints
Newer Version of Tool Breaks Things¶
Problem: Pre-commit hooks or tools updated and now fail.
Solutions:
-
Check what changed:
pre-commit autoupdate --dry-run -
Update individual tool:
pre-commit autoupdate --repo https://github.com/tool-repo -
Test changes:
bash pre-commit run --all-files -
Pin to known-good version in
.pre-commit-config.yaml:rev: v1.0.0 # Specific version instead of latest
Getting Help¶
If you encounter issues not listed here:
- Check existing issues: Search GitHub Issues for your problem
- Review logs carefully: Error messages usually point to the root cause
- Search documentation: Many issues are covered in specific tool docs
- Try minimal reproduction: Isolate the problem to a single file/command
- Ask for help: Open an issue with:
- Your environment (Python version, OS)
- Steps to reproduce
- Full error message/logs
- What you've already tried