-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use black
as the python code formatter.
#159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about following workflow:
- Require each developer to install pre-commit hook to enforce running the code formatter automatically upon every commit. Documentation: https://pre-commit.com.
- Add main branch protection by running "check style" script, to enforce all incoming code is properly formatted.
Rationale for using combination of these two method:
- Developers do not need to manually run code formatter every time
- When developers properly configure pre-commit hook, everything will be automatic; when they haven't configure pre-commit hook, the branch protection will reject merge action.
- There is option to setup CI/CD workflow to auto run code formatter, but it will create code formatting commit upon every push, which I think it's not neat? But not a big concern.
Yes, I also think this is not neat. Previously, I also found an unofficial action that can also reformat the code based on the identified format issue. But I think the change will not be transparent enough to developer and they may fail to test the reformatted code (reformatting the code shall be safe, but just in case).
I can see the benefit, but given this repo mainly hosts a python package, will this "overkill"? Also, I am not sure if everyone is familiar with this. |
More thoughts on this @Yucheng-Jiang ? |
For pre-hook, on our end we just need to add pip install pre-commit
pre-commit install Upon commit, it will run code formatter automatically. |
ok, I will look into this. Thanks |
black
code formatter for this repo to ensure code quality. UpdateREADME.md
andCONTRIBUTING.md
accordingly.knowledge_storm/
usingblack
.