tensorflow / similarity

TensorFlow Similarity is a python package focused on making similarity learning quick and easy.
Apache License 2.0
1.01k stars 104 forks source link

black formatting #274

Closed yonigottesman closed 2 years ago

yonigottesman commented 2 years ago

Hi I noticed the style in the code varies a bit. What do you think of adding a github action that checks the black style + a pre-commit hook to do the formatting on changed file? If you approve ill open a pr with the changes

owenvallis commented 2 years ago

Hi Yoni,

We had started with yapf, but I've been slowly moving to Black for formatting and isort for the import order. This is what kerascv is using and it would be great to be consistent with them.

Looking at their approach, it seems like they provide formatting and linting scripts. It also looks like they run the linting script as a githook pre-commit check and also as part of the github actions.

I think this approach might be cleaner than formatting in the github actions as it still allows users to check the formatting locally when they make the commit. wdyt?

yonigottesman commented 2 years ago

Its a bad idea to format the code for a user without him having the option to review it first. what I meant was the github action will just validate the formatting rules, and the pre-commit hook will format the changed files of the commit and send them back from the staging area, so the user must do git add again on them.

owenvallis commented 2 years ago

Perfect, that sounds great. I'll assign the issue to you, but let me know if you need anything on my side.

owenvallis commented 2 years ago

Merged in #277. Thanks again for this.