-
Notifications
You must be signed in to change notification settings - Fork 288
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
for code auto formatting
#810
Comments
I prefer black as well, we want to align with the overall tensorflow community so that common issues might be resolved together. |
It will be good to be on the same page as the rest of the community, so sounds good to me. Thanks @terrytangyuan ! |
If you guys are interested, in Addons, we managed to do a progressive (graceful) migration to black without git conflicts and without stopping anyone from working. See tensorflow/addons#988 and tensorflow/addons#932 |
@gabrieldemarmiesse Thanks! That’s a good idea. I’ll take a closer look on the details when I get a chance. |
Now that @yongtang has added black check in our bazel scripts #837. It might be better for individual developers to run black check on their new PRs instead of doing everything at once (like in #812) to avoid conflicts. If everyone agrees, I'll close #812 and then everyone can contribute towards this. WDYT? |
SGTM, thanks @terrytangyuan ! |
Thanks sounds good to me. @terrytangyuan @BryanCutler I think what we could do, is in build.yml's
Then we could run black (and pyupgrade) for those python files from the above list. |
@yongtang Good idea. |
Looks like pylint from Google requires 2 space while Black needs 4 spaces. This is causing issues and we may need to find a way to get around. |
4 spaces FTW |
It looks like pylint disagree with black in quite a few places. The biggest issue is the Another issue is that black will format line exceeding 80 in certain situations with causes Google's pylint rc file also uses 2 space, though we could override this behavior with:
However, other than 2 spaces, the first two issues are really hard to fix in a way both black and pylint are happy. Since both tensorflow_addon and tensorflow_tensorboard only uses black, I am inclined to drop pylint, and in favor of black only. Any concerns about that? |
@yongtang In addons, we didn't drop code linting entirely, we replaced it by flake8 and we changed some default settings. We didn't have any issues yet with it, as we took it from the black documentation. See https://github.com/tensorflow/addons/blob/master/.flake8 |
Yes I agree. I've had good experience with the combination of black and flake8 but not with pylint. We can drop it. |
Thanks @gabrieldemarmiesse @terrytangyuan, I made some adjustment to pylint with the following overrides:
That makes both black and pylint happy. Created a PR #860 with black. We can look into flake8 later. |
It would be good to use auto formatting for our current Python codebase so the style is consistent among developers without having to manually fixing lint, etc. I've had good experience using black for other projects and it looks like both tensorflow/addons and TensorBoard are already using it.
Let's use this issue to discuss this and I am happy to work on this once we reach a consensus.
The text was updated successfully, but these errors were encountered: