Skip to content

Commit 8694597

Browse files
committed
Update guidelines and CI scripts for Python formatting
- Added guidelines for formatting Python scripts in CONTRIBUTING.md. - Updated `.ci/check-format.sh` to streamline the check for Python file formatting.
1 parent 3d9ea88 commit 8694597

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.ci/check-format.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ for file in ${PY_SOURCES}; do
2828
done
2929
PY_MISMATCH_FILE_CNT=0
3030
if [ -n "${PY_SOURCES}" ]; then
31-
PY_MISMATCH_OUTPUT=$(black --check ${PY_SOURCES} 2>&1)
32-
PY_MISMATCH_FILE_CNT=$(echo "${PY_MISMATCH_OUTPUT}" | grep -c "^would reformat ")
31+
PY_MISMATCH_FILE_CNT=$(echo "$(black --check ${PY_SOURCES} 2>&1)" | grep -c "^would reformat ")
3332
fi
3433

3534
exit $((C_MISMATCH_LINE_CNT + SH_MISMATCH_FILE_CNT + PY_MISMATCH_FILE_CNT))

CONTRIBUTING.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ However, participation requires adherence to fundamental ground rules:
3939
While there is some flexibility in basic style, it is crucial to stick to the current coding standards.
4040
Complex algorithmic constructs without proper comments will not be accepted.
4141
* Shell scripts must be formatted before submission. Use consistent flags across the project to ensure uniform formatting.
42+
* Python scripts must be formatted before submission. Use consistent flags across the project to ensure uniform formatting.
4243
* External pull requests should include thorough documentation in the pull request comments for consideration.
4344
* When composing documentation, code comments, and other materials in English,
4445
please adhere to the American English (`en_US`) dialect.
@@ -48,10 +49,14 @@ However, participation requires adherence to fundamental ground rules:
4849
Software requirement:
4950
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html) version 18 or later.
5051
* [shfmt](https://github.com/mvdan/sh).
51-
* [black](https://github.com/psf/black) for Python code formatting.
52+
* [black](https://github.com/psf/black).
53+
54+
To maintain a uniform style across languages, run:
55+
56+
* `clang-format -i *.{c,h}` to apply the project’s C/C++ formatting rules from the up-to-date .clang-format file.
57+
* `shfmt -w $(find . -type f -name "*.sh")` to clean and standardize all shell scripts.
58+
* `black .` to enforce a consistent, idiomatic layout for Python code.
5259

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.
5560

5661
## Coding Style for Shell Script
5762

0 commit comments

Comments
 (0)