ci: Introduce code formatter
See original GitHub issue🚀 Feature
We’ve spent quite some time on fixing code formatting in code reviews by our own hands, but this should be done automatically by a Python code formatter.
List of formatters
blackby Python Software Foundation (https://github.com/psf/black)- This blog post by DeepSource says
blackis the most popular one.
- This blog post by DeepSource says
yapfby Google (https://github.com/google/yapf)- (
autopep8, …)
Additional context
I have used black with isort (for import formatting) and flake8 (for pep8 check) in Optuna, and it worked really well, so +1 for black.
In PL, black was added in https://github.com/PyTorchLightning/pytorch-lightning/pull/1610, but it hasn’t been really used… We can start to employ the code formatter here, and if there seems no problem with it, we can enable it in PL later, too.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10 (10 by maintainers)
Top Results From Across the Web
ci: Introduce code formatter · Issue #482 - GitHub
I have used black with isort (for import formatting) and flake8 (for pep8 check) in Optuna, and it worked really well, so +1...
Read more >How To Enforce Formatting in Continuous Integration - Medium
This story will cover Java code formatter in IntelliJ and Format check in Continuous Integration pipeline. I picked Java cause there is a ......
Read more >CI: code formatting check added - Developers - Suricata
Hi all, Just a heads up that we now ship a .clang-format file, ... Introducing improperly formatted code is now a reason for...
Read more >Consistent Python code with Black - Matt Layman
This post focuses on Black, a code formatter, how it can improve your project's code style, and how you or your team can...
Read more >Creating a Formatter Extension - Visual Studio Code
Since its introduction, the Visual Studio Code extension API has provided support for source code formatters. The first language extensions ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@oke-aditya @briankosw Thank you both for sharing the useful information! So, as I read your comments, I believe we should do the followings.
To do
blackto pre-commit hooksblackto GitHub Actionsflake8andisortconfigs to avoid conflicts withblackLet’s get to work on this once we have positive comments from other core members :]
I think that we can do this check with
flake8right? but yes, lest try black here :]UPDATE: well just check the listed
yapfand it looks better, seems to be more flexible and particular I likeCOALESCE_BRACKETSsee: https://www.kevinpeters.net/auto-formatters-for-python