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

Blackify code base #1799

Merged
merged 5 commits into from
Oct 18, 2018
Merged

Blackify code base #1799

merged 5 commits into from
Oct 18, 2018

Conversation

Cnidarias
Copy link
Contributor

Letting black run over everything

  • Add documentation.
  • Add a changelog entry.
  • Add your name in the contributors file.

So in light of my other pull request I suggested that we run black over everything and @leplatrem seemed to be in favor so here we are.

I figured it would be best if we did this before adding all the type annotations to not have too many changes at once.

I let black run over everything, adding a pre-commit (https://pre-commit.com) config file as well as a config file for black.

I also had to add an ignore E203 in order for flake8 to be happy.

If this is okay then I would still have to add some documentation on how to set things up for development but I do think the result is actually quite nice!

Thoughts?

@leplatrem
Copy link
Contributor

leplatrem commented Oct 8, 2018

@Natim @glasserc ?

@leplatrem
Copy link
Contributor

Note: @peterbe recommends therapist https://github.com/peterbe/hashin/pull/80/files

@leplatrem
Copy link
Contributor

Be careful commit edbf3b8 should not be part of this PR

@Cnidarias
Copy link
Contributor Author

So I basically just added the stuff you linked -- not sure I did it correctly though especially regarding therapist/travis/tox

But it seems like its fine?

Still need to add some documentation though.

@leplatrem
Copy link
Contributor

Excellent! Let's get the documentation part updated for developers in the community section and then we can iterate :) We should probably add the necessary deps in the dev-requirements.txt right?

The diff is hard to review 😅

@Cnidarias
Copy link
Contributor Author

Cnidarias commented Oct 11, 2018

Hey,

yes the diff is quite massive.
This does beg another question, when looking at the diffs alot of changes are changing single quotes to double quotes

Black does provide the option to omit normalizing quotes.

After testing it - the diff would still be massive. When omitting the quite normalization black still touches all but 24 files.

I have also added some documentation now.
I would prefer to rebase once we are happy with the documentation and everything else because there will always be merge conflicts as of now.

Edit:
When adding black to the dev-requirements.txt

Travis will fail the py35 build as black requires python 3.6

6. When you're done making changes, format your code with `black <https://github.com/ambv/black>`_ (black requires python >= 3.6)::

python -m pip install black
black .
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to install black only and run it via tox -e lint (tox and therapist will be installed via dev-requirements)

7. Commit your changes and push your branch to GitHub::
8. (Optional) Install a git hook with `therapist <https://github.com/rehandalal/therapist>`_ ::

python -m pip install therapist
Copy link
Contributor

Choose a reason for hiding this comment

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

this line can be omitted since already in dev-requirements

@leplatrem
Copy link
Contributor

Almost there! 🎉

  • I would like to avoid configuration of black if possible. Double quotes are fine.
  • Since python 3.5 is still officially supported, we have to adapt. Suggesting its installation manually in the dev docs is fine IMO

Thanks 🙏

@leplatrem
Copy link
Contributor

Let me know if you need help or support ;)

Actually I would be very interested with this PR, because I started to work on #710 using xargs sed like an animal :)

@Cnidarias
Copy link
Contributor Author

Hey,

sorry about not getting back to you on this earlier.

We should probably move therapist and black to its own requirements.txt file (maybe something like lint-requirements.txt) as, like I said travis will fail the py3.5 build because it cannot install black.

I will adjust the documentation accordingly if that is okay.

I will only be able to work at this later tonight though after work

@Cnidarias
Copy link
Contributor Author

Okay - so I went ahead and got rid of my changes because I did not feel like merging 40+ merge conflicts.

This commit now has everything we had earlier with the additional changes that we now have a lint-requirements.txt file as well as adapting the documentation.

The code has not yet been formatted with black so it will be easier for me to rebase it once we are ready to merge.

Copy link
Contributor

@leplatrem leplatrem left a comment

Choose a reason for hiding this comment

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

Don't you think that we could just get rid of flake8 on py35? I mean, if we do lint check on python 3.6 it's good enough no?

@@ -0,0 +1,2 @@
therapist==1.5.0
black==18.9b0
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could add:

    flake8
    setuptools<36

BTW @Natim do you remember why setuptools<36?

8. (Optional) Install a git hook::

therapist install

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like an extra line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't you have to tell therapist to create the hook in your .git dir?

Copy link
Contributor

Choose a reason for hiding this comment

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

blank line sorry :)

@@ -16,11 +16,12 @@ deps =
statsd
install_command = pip install {opts} {packages}

[testenv:flake8]
commands = flake8 kinto tests docs/conf.py
Copy link
Contributor

@leplatrem leplatrem Oct 18, 2018

Choose a reason for hiding this comment

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

if it's mentioned in travis, we should keep it flake8 (py35).
But I would in favor of removing it in travis too instead :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I should have removed it in travis.

Copy link
Contributor

@leplatrem leplatrem left a comment

Choose a reason for hiding this comment

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

Great!! Thank you for the hard work :) You can format and I'll press the merge button :)

@Cnidarias
Copy link
Contributor Author

Alright - I ran black and merged the conflict

@leplatrem leplatrem merged commit efc027f into Kinto:master Oct 18, 2018
@leplatrem
Copy link
Contributor

:) here we go :) thanks again ;)

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.

2 participants