Skip to content

Commit eda1317

Browse files
committed
Fix version mismatch: update black to 25.9.0 to match local version
- Update black from 24.1.1 to 25.9.0 in pre-commit config - Update black requirement from >=24.1.0 to >=25.9.0 - Add troubleshooting section explaining version mismatch issues - This prevents files from being reformatted repeatedly due to version differences
1 parent 0439334 commit eda1317

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222

2323
# Python code formatting and linting
2424
- repo: https://github.com/psf/black
25-
rev: 24.1.1
25+
rev: 25.9.0
2626
hooks:
2727
- id: black
2828
files: ^\.github/scripts/.*\.py$

docs/development/PRE_COMMIT.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,49 @@ git commit --no-verify -m "message"
107107

108108
## Troubleshooting
109109

110+
### Files Keep Getting Reformatted
111+
112+
If black or ruff-format keep modifying files even after you've formatted them, this is usually due to a **version mismatch**:
113+
114+
**Problem:**
115+
116+
- Your local black/ruff version differs from the pre-commit hook version
117+
- Pre-commit hooks use pinned versions (see `.pre-commit-config.yaml`)
118+
- Local tools might be using different versions
119+
120+
**Solution:**
121+
122+
1. **Check your local versions:**
123+
124+
```bash
125+
python3 -m black --version
126+
python3 -m ruff --version
127+
```
128+
129+
2. **Ensure pre-commit hooks match:**
130+
- Pre-commit hooks download their own versions
131+
- Check `.pre-commit-config.yaml` for pinned versions
132+
- Update if needed: `pre-commit autoupdate`
133+
134+
3. **Run pre-commit before committing:**
135+
136+
```bash
137+
pre-commit run --all-files
138+
```
139+
140+
This formats files using the same versions as CI, preventing reformatting issues.
141+
142+
4. **Don't bypass hooks:**
143+
- Avoid `git commit --no-verify`
144+
- Let hooks format files before commit
145+
- Review changes after hooks run
146+
147+
**Why this happens:**
148+
149+
- Pre-commit hooks run with isolated environments
150+
- They use specific versions defined in `.pre-commit-config.yaml`
151+
- If you format files manually with a different version, they'll be reformatted again
152+
110153
### Deprecation Warnings
111154

112155
If you see warnings about deprecated stage names, they have been addressed in our configuration by explicitly setting `stages: [pre-commit]` for hooks that have this issue. This overrides the deprecated stage names defined in the hook repositories themselves.

requirements-ci.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pytest>=7.4.0
55
pytest-cov>=4.1.0
66
pytest-mock>=3.11.0
77
pre-commit>=3.5.0
8-
black>=24.1.0
8+
black>=25.9.0
99
isort>=5.13.0
1010
ruff>=0.1.9
1111
yamllint>=1.33.0

0 commit comments

Comments
 (0)