Description
This project currently uses flake8 for linting, which is great for enforcing code quality. However, it doesn’t handle code formatting.
Introducing black will enforce a consistent code style across the codebase, reduce style-related discussions in code reviews, and speed up development by automating formatting.
We will add black alongside flake8, not as a replacement.
Proposed Solution
- Add
black to requirements-lint.txt
- Add a
pyproject.toml with basic black configuration (targeting Python 3.13)
- Format the existing codebase using
black
- Add a
black --check . step to the existing CI workflow (alongside flake8)
- Document this in
CONTRIBUTING.md
Suggested Implementation
1. Update requirements-lint.txt
Append:
2. Add pyproject.toml
Create at the repo root:
[tool.black]
line-length = 88
target-version = ['py313']
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.venv
| build
| dist
| __pycache__
| \.eggs
| \.mypy_cache
| \.tox
)/
'''
3. Format the codebase
Run:
4. Update CI Workflow (lint job)
Append this step after flake8:
- name: Check code formatting with black
run: black --check .
5. (Optional) Update CONTRIBUTING.md
Add a new line:
Format your code with black before committing. Run black . from the project root
Acceptance Criteria
- black==25.1.0 is listed in
requirements-lint.txt
pyproject.toml with black config exists
- All Python code is formatted with
black
- CI pipeline checks code formatting with
black
- Contribution guide includes instructions on using
black
Description
This project currently uses
flake8for linting, which is great for enforcing code quality. However, it doesn’t handle code formatting.Introducing
blackwill enforce a consistent code style across the codebase, reduce style-related discussions in code reviews, and speed up development by automating formatting.We will add
blackalongsideflake8, not as a replacement.Proposed Solution
blacktorequirements-lint.txtpyproject.tomlwith basicblackconfiguration (targeting Python 3.13)blackblack --check .step to the existing CI workflow (alongsideflake8)CONTRIBUTING.mdSuggested Implementation
1. Update
requirements-lint.txtAppend:
2. Add
pyproject.tomlCreate at the repo root:
3. Format the codebase
Run:
black .4. Update CI Workflow (lint job)
Append this step after
flake8:5. (Optional) Update CONTRIBUTING.md
Add a new line:
Acceptance Criteria
requirements-lint.txtpyproject.tomlwithblackconfig existsblackblackblack