Skip to content

Commit f44dbb2

Browse files
committed
chore: configure Black as the default Python code formatter
1 parent 26e3e7d commit f44dbb2

File tree

7 files changed

+66
-45
lines changed

7 files changed

+66
-45
lines changed

.flake8

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
[flake8]
2-
# Maximum line length allowed
3-
max-line-length = 127
4-
5-
# Maximum allowed code complexity (10 is a reasonable threshold)
2+
max-line-length = 88
63
max-complexity = 10
7-
8-
# Only check for specific error codes:
9-
# - E9 -> Syntax errors
10-
# - F63 -> Issues related to improper usage of `+=`, `-=`, etc.
11-
# - F7 -> Issues related to improper `break`, `continue`, etc.
12-
# - F82 -> Undefined names
13-
select = E9,F63,F7,F82
14-
15-
# Exclude `.venv` from linting (prevents checking dependencies)
4+
select = E,F,W
5+
extend-ignore = E203, W503
166
exclude = .venv
17-
18-
# Print the count of linting errors
197
count = True
20-
21-
# Show the exact source of the error
228
show-source = True
23-
24-
# Display statistics of errors at the end of the report
259
statistics = True
26-
27-
# Enable verbose mode for more detailed output
2810
verbose = True

.github/workflows/python-app.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
python-version: ${{ env.PYTHON_VERSION }}
3232
cache: 'pip'
3333

34-
- name: Install dependencies
34+
- name: Install lint dependencies
3535
run: |
3636
python -m pip install --upgrade pip
3737
pip install -r requirements-lint.txt
@@ -40,6 +40,10 @@ jobs:
4040
run: |
4141
flake8 .
4242
43+
- name: Check code formatting with Black
44+
run: |
45+
black --check .
46+
4347
test:
4448
needs: lint
4549
runs-on: ubuntu-latest
@@ -53,7 +57,7 @@ jobs:
5357
python-version: ${{ env.PYTHON_VERSION }}
5458
cache: 'pip'
5559

56-
- name: Install dependencies
60+
- name: Install test dependencies
5761
run: |
5862
python -m pip install --upgrade pip
5963
pip install -r requirements-test.txt

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"recommendations": [
33
"ms-python.python",
44
"ms-python.vscode-pylance",
5+
"ms-python.black-formatter",
56
"github.vscode-pull-request-github",
67
"github.vscode-github-actions",
78
"ms-azuretools.vscode-containers",

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
"**/.git": true,
88
"**/.DS_Store": true
99
},
10+
"editor.wordWrapColumn": 88,
11+
"editor.rulers": [88],
1012
"[python]": {
11-
"editor.defaultFormatter": "ms-python.autopep8",
13+
"editor.defaultFormatter": "ms-python.black-formatter",
1214
"editor.formatOnSave": true
1315
},
1416
"sonarlint.connectedMode.project": {

CONTRIBUTING.md

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,58 @@ We value **incremental, detail‑first contributions** over big rewrites or abst
1010
## 2. Code & Commit Conventions
1111

1212
- **Conventional Commits**
13-
Follow <https://www.conventionalcommits.org/en/v1.0.0/>:
14-
- `feat: ` for new features
15-
- `fix: ` for bug fixes
16-
- `chore: ` for maintenance
13+
Follow <https://www.conventionalcommits.org/en/v1.0.0/>:
14+
- `feat: ` for new features
15+
- `fix: ` for bug fixes
16+
- `chore: ` for maintenance or tooling
1717

1818
- **Logical Commits**
19-
Group changes by purpose. It’s okay to have multiple commits in a PR, but if they’re mere checkpoints, squash them into a single logical commit.
20-
21-
- **Lint & Tests**
22-
Run existing linters/formatters and ensure all tests pass.
19+
Group changes by purpose. Multiple commits are fine, but avoid noise. Squash when appropriate.
20+
21+
- **Python Formatting & Style**
22+
- Use **[Black](https://black.readthedocs.io/)** for consistent code formatting.
23+
- Black is opinionated: don't argue with it, just run it.
24+
- Line length is set to **88**, matching the default.
25+
- Use **[flake8](https://flake8.pycqa.org/en/latest/)** for static checks.
26+
- Line length also set to 88.
27+
- Some flake8 warnings are disabled (e.g. `E203`, `W503`) to avoid conflicts with Black.
28+
- Run `black .` and `flake8` before submitting.
29+
- Use Python **3.13.x** for local testing and formatting.
30+
31+
- **Testing**
32+
- Run `pytest` before pushing.
33+
- Ensure coverage isn’t regressing.
2334

2435
## 3. Pull Request Workflow
2536

2637
- **One logical change per PR.**
27-
- **Rebase or squash** before opening to keep history concise.
38+
- **Rebase or squash** before opening to keep history clean.
2839
- **Title & Description**
29-
- Title uses Conventional Commits style.
30-
- Description explains _what_ and _why_—keep context minimal.
40+
- Use Conventional Commit format.
41+
- Explain _what_ and _why_ concisely in the PR body.
3142

3243
## 4. Issue Reporting
3344

34-
- Search existing issues first.
35-
- Provide a minimal reproducible example and clear steps.
45+
- Search open issues before creating a new one.
46+
- Include clear steps to reproduce and environment details.
47+
- Prefer **focused** issues—don’t bundle multiple topics.
3648

3749
## 5. Automation & Checks
3850

39-
We enforce quality via CI on every push and PR:
51+
All PRs and pushes go through CI:
4052

41-
- **Commitlint** for commit‑message style
42-
- **Linters/Formatters**
43-
- **Unit tests**
53+
- **Commitlint** for commit style
54+
- **Black** for formatting
55+
- **flake8** for static checks
56+
- **pytest** with coverage
4457

45-
Failures must be fixed before review.
58+
PRs must pass all checks to be reviewed.
4659

4760
## 6. Code of Conduct & Support
4861

49-
- Please see `CODE_OF_CONDUCT.md` for behavioral expectations and reporting.
50-
- For quick questions or discussions, open an issue with the `discussion` label or mention a maintainer.
62+
- See `CODE_OF_CONDUCT.md` for guidelines and reporting.
63+
- For questions or planning, open an issue and use the `discussion` label, or mention a maintainer.
64+
65+
---
5166

52-
Thanks again for helping keep this project small, simple, and impactful!
67+
Thanks again for helping keep this project small, sharp, and focused.

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[tool.black]
2+
line-length = 88
3+
target-version = ['py313']
4+
include = '\.pyi?$'
5+
exclude = '''
6+
/(
7+
\.git
8+
| \.venv
9+
| build
10+
| dist
11+
| __pycache__
12+
| \.eggs
13+
| \.mypy_cache
14+
| \.tox
15+
)/
16+
'''

requirements-lint.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
flake8==7.2.0
2+
black==25.1.0

0 commit comments

Comments
 (0)