You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Black-based formatting checks for Python files:
- Update `.ci/check-format.sh` to include checks for Python files using Black.
- Modify `.github/workflows/main.yml` to install Python dependencies for formatting.
- Add `pyproject.toml` for configuring Black as the Python code formatter.
- Enhance `CONTRIBUTING.md` with guidelines for Python formatting using Black.
- Refactor Python scripts to adhere to the new formatting rules, including consistent use of quotes and spacing.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+48-2Lines changed: 48 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -48,9 +48,10 @@ However, participation requires adherence to fundamental ground rules:
48
48
Software requirement:
49
49
*[clang-format](https://clang.llvm.org/docs/ClangFormat.html) version 18 or later.
50
50
*[shfmt](https://github.com/mvdan/sh).
51
+
*[black](https://github.com/psf/black) for Python code formatting.
51
52
52
-
This repository consistently contains an up-to-date `.clang-format` file with rules that match the explained ones and uses shell script formatting supported by `shfmt`.
53
-
For maintaining a uniform coding style, execute the command `clang-format -i *.{c,h}` and `shfmt -w $(find . -type f -name "*.sh")`.
53
+
This repository consistently contains an up-to-date `.clang-format` file with rules that match the explained ones, uses shell script formatting supported by `shfmt`, and Python code formatting with `black`.
54
+
For maintaining a uniform coding style, execute the command `clang-format -i *.{c,h}`, `shfmt -w $(find . -type f -name "*.sh")`, and `black .` for Python files.
54
55
55
56
## Coding Style for Shell Script
56
57
@@ -65,6 +66,51 @@ Shell scripts must be clean, consistent, and portable. The following `shfmt` rul
65
66
* Add spaces around redirection operators (e.g., `>`, `>>`).
66
67
* Place binary operators (e.g., `&&`, `|`) on the next line when breaking lines.
67
68
69
+
## Coding Style for Python
70
+
71
+
Python scripts must be clean, consistent, and adhere to modern Python best practices. The following formatting rules are enforced project-wide using `black`:
72
+
73
+
* Use 4 spaces for indentation (never tabs).
74
+
* Limit lines to 88 characters maximum.
75
+
* Use double quotes for strings (unless single quotes avoid escaping).
76
+
* Use trailing commas in multi-line constructs.
77
+
* Format imports according to PEP 8 guidelines.
78
+
* Use Unix-style line endings (LF).
79
+
* Remove trailing whitespace at the end of lines.
80
+
* Ensure files end with a newline.
81
+
82
+
### Configuration
83
+
84
+
Python formatting is configured via the `pyproject.toml` file in the project root:
0 commit comments