Skip to content
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

Auto-formatting with black and isort #97

Merged
merged 11 commits into from Jul 16, 2020
Merged

Auto-formatting with black and isort #97

merged 11 commits into from Jul 16, 2020

Conversation

araffin
Copy link
Member

@araffin araffin commented Jul 10, 2020

Description

Motivation and Context

  • I have raised an issue to propose this change (required for new features and bug fixes)

Related to #17

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist:

  • I've read the CONTRIBUTION guide (required)
  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have checked the codestyle using make lint
  • I have ensured make pytest and make type both pass.

@araffin araffin changed the title Feat/auto format Auto-formatting with black and isort Jul 10, 2020
@Miffyli
Copy link
Collaborator

Miffyli commented Jul 10, 2020

Looking at the changes I must say I quite like black's formatting. There are some parts I do not like (much like you discussed in #17), but overall I prefer it much more over not having a fixed standard across the code. I also like how it changes ' to " :).

I give this a green light, but would like someone else to give in a review, given how much this will affect the whole codebase in the future.

@araffin
Copy link
Member Author

araffin commented Jul 10, 2020

Looking at the changes I must say I quite like black's formatting. There are some parts I do not like (much like you discussed in #17), but overall I prefer it much more over not having a fixed standard across the code. I also like how it changes ' to " :).

Yep, same feeling. But it is nice not to worry or waste time about formatting.

I give this a green light, but would like someone else to give in a review, given how much this will affect the whole codebase in the future.

Yep, It would be nice if all maintainers agree for that one.
@AdamGleave already did, but I did not get any feedback from @erniejunior and @hill-a yet.

@m-rph
Copy link
Contributor

m-rph commented Jul 10, 2020

A pre-commit hook that auto-formats would be quite useful.

@araffin
Copy link
Member Author

araffin commented Jul 10, 2020

A pre-commit hook that auto-formats would be quite useful.

not sure about that one... will people also have it when they clone the repo?
Personally, I prefer when nothing is done without me knowing, and doing make format is quite easy.

setup.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@AdamGleave AdamGleave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@AdamGleave
Copy link
Collaborator

A pre-commit hook that auto-formats would be quite useful.

not sure about that one... will people also have it when they clone the repo?
Personally, I prefer when nothing is done without me knowing, and doing make format is quite easy.

I do like having commit hooks to run all the cheap checks so I don't have to remember to do it manually (or wait 30m to see the CI fails), but am also fine with writing one myself.

We could add an entry in the Makefile that just runs all the other quick entries? Something like:

commit-checks: type lint format spelling

@hill-a
Copy link
Collaborator

hill-a commented Jul 16, 2020

LGTM.

Honestly I might just add black and isort to my workspace in general. I didn't realise they existed.

The auto formating looks really good.
My only issue I have is with the function definition format:

    def foo(
        arg1,
        arg2
    ):
        # applies foo to args
        return None

But that probably because I'm not used to it (I keep trying to look for the ): for the end of the function signature).
From what I can tell this is done to avoid large diffs.

@araffin
Copy link
Member Author

araffin commented Jul 16, 2020

But that probably because I'm not used to it (I keep trying to look for the ): for the end of the function signature).
From what I can tell this is done to avoid large diffs.

Yep, that's part of the things I'm not completely ok with it, but that's the compromise (there is no with black ^^").
I guess it will look normal over time.

@araffin
Copy link
Member Author

araffin commented Jul 16, 2020

Can someone tell me why Github CI fails?
For Gitlab, I have an idea... It comes from opencv.

@araffin araffin merged commit 23afedb into master Jul 16, 2020
@araffin araffin deleted the feat/auto-format branch July 16, 2020 14:12
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.

None yet

6 participants