Skip to content

Conversation

@dodo920306
Copy link
Contributor

@dodo920306 dodo920306 commented Jun 29, 2025

According to docs/index.md, Cello uses Black code style.

...
## [Contribute to the Project](contributing.md)
* [How to Contribute](contributing.md)
* [Code Style Guide](https://black.readthedocs.io/en/stable/the_black_code_style.html)

## Design Documentation
* [Architecture Design](design/arch.md)
...

Moreover, there is a .pre-commit-config.yaml file about this.

However, the current code here doesn't seem to be like that.

This PR is about whether to keep Black usage as recorded, or is simply using tox with flake8 in the CI pipeline enough?

To use it, you must run

$ pip install pre-commit black
$ pre-commit install

so that the hook can be applied every time you commit. (Check out https://github.com/pre-commit/pre-commit for more info.)

Optionally, you can run

$ pre-commit run --all-files

to trigger this without commit.

`24.8.0` is the last version that supports python 3.8. The stable version of black currently
supports versions newer than python 3.9 only.

Also, adding paths after the hook entry is meaningless because pre-commit will append
all staged files behind the black command automatically.

The version of python black expects is bumped to 3.8.

Signed-off-by: dodo920306 <[email protected]>
According to `docs/index.md`, Cello uses `black` code style. However, the code here
doesn't really complies with that.

This commit reformats all the Python codes here by `black`.

Signed-off-by: dodo920306 <[email protected]>
@dodo920306 dodo920306 changed the title Re-adopt Black reformatter Re-adopt Black reformatter (or not?) Jun 29, 2025
@dodo920306
Copy link
Contributor Author

Please consider and answer the question before merging this.

Also, another problem is should this be integrated with the CI pipeline?

@dodo920306 dodo920306 changed the title Re-adopt Black reformatter (or not?) Re-adopt pre-commit hook with Black reformatter (or not?) Jun 29, 2025
@yeasy
Copy link
Contributor

yeasy commented Jun 30, 2025

I think using tox with flake8 in the CI pipeline is enough? @YoungHypo what is your favor?

@YoungHypo
Copy link
Contributor

I think using tox with flake8 in the CI pipeline is enough? @YoungHypo what is your favor?

If we decide to adopt black for code formatting, adding a black check step in the CI could help us catch unformatted code early, before it gets merged. @yeasy @dodo920306

@dodo920306
Copy link
Contributor Author

I think using tox with flake8 in the CI pipeline is enough? @YoungHypo what is your favor?

If we decide to adopt black for code formatting, adding a black check step in the CI could help us catch unformatted code early, before it gets merged. @yeasy @dodo920306

I have no opinion. If we want to do it, we have to make a new pipeline step to execute black at first before flake8 checks and then commit the changes if any.

@yeasy
Copy link
Contributor

yeasy commented Jul 19, 2025

after discussion, we will take:

  • pre-commit hook: black + flake8 (into make check)
  • CI: flake8

yeasy
yeasy previously approved these changes Jul 19, 2025
@yeasy yeasy merged commit 7f9055c into hyperledger-cello:main Aug 7, 2025
3 checks passed
@dodo920306 dodo920306 deleted the fix/usage-of-black-formatter branch August 8, 2025 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants