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

Black #3142

Merged
merged 15 commits into from
Aug 8, 2019
Merged

Black #3142

merged 15 commits into from
Aug 8, 2019

Conversation

max-sixty
Copy link
Collaborator

@max-sixty max-sixty commented Jul 18, 2019

From #3092

  • Reformat code
  • CI checks
  • Short instructions for how to merge an existing PR (i.e. avoid manual merge resolution)
    • Not sure if there's magic here - I think people would just have to format their code and then hope git can resolve (i.e. because there would still be no common parent)?
  • Black badge
  • Do we want to keep flake8 checks? Black is mostly stricter but not always, e.g. on lines at the end of files. (+0.3 from me to use only black and stop using flake8)

- [ ] Do we want to include isort? (-0.1 from me, even though I like the tool)

@max-sixty
Copy link
Collaborator Author

FYI, unfortunately pep8speaks doesn't yet support black

@max-sixty
Copy link
Collaborator Author

I think we can suggest something like this to existing PRs to eliminate manual conflicts, and I'm attempting to find something more official. Let me know if anyone knows of something:

  • Merge master prior to the black commit (any conflicts are real conflicts and require resolving)
  • Apply black . to this branch
  • Merge master at the black commit, resolving in favor of our changes: git merge [black-commit] -X ours
  • Merge current master (any conflicts here are real and again require resolving)

@max-sixty
Copy link
Collaborator Author

What are people's thoughts on doing this now? There are a few big merges happening atm, so could do this after those.

I tested the approach above and it worked well. I don't have any more external validation than my test though. If anyone has experience here, please let us know.

@shoyer
Copy link
Member

shoyer commented Aug 5, 2019 via email

@Zac-HD
Copy link
Contributor

Zac-HD commented Aug 7, 2019

Sadly if there's a way to automatically fix up merge conflicts I don't know of it 😭. However I'd be happy to help anyone who is having trouble rebasing their open PR.

On a different note, have you considered adding the pyupgrade and autoflake8 autoformatters? They go further than Black in that they do change the AST, but it's a nice way to ensure consistency of style, automatically remove unused imports and variables for flake8, and so on.

@crusaderky
Copy link
Contributor

I did a manual pass of pyupgrade (#3190), and it looks good.
+1, but let's avoid bloating and leave it for a later PR

@max-sixty
Copy link
Collaborator Author

On a different note, have you considered adding the pyupgrade and autoflake8 autoformatters?

Nice, I didn't know those. I had use autopep8 before. isort is another I use a lot.

+1, but let's avoid bloating and leave it for a later PR

Yeah - not sure of the balance here.
I think the focus should be on easy initial contributions. Consistent formatting is helpful in reading and reviewing code, and eliminating any formatting iterations.
Each extra tool's benefit needs to be weighed against the startup cost of another install - unless there's a way of eliminating that (e.g. I've seen some bots add the code changes from GH)

An alternative is to run those additional tools across the whole codebase on occasion, assuming this doesn't create too many merge conflicts.

Interested in others' thoughts... (but probably for another PR)

@max-sixty max-sixty changed the title Black (Preparation; no code yet) Black Aug 8, 2019
@max-sixty max-sixty marked this pull request as ready for review August 8, 2019 17:12
@max-sixty
Copy link
Collaborator Author

@pydata/xarray this is ready to go!

Any final comments / thoughts / feedback?

@dcherian
Copy link
Contributor

dcherian commented Aug 8, 2019

image

doc/gallery/plot_cartopy_facetgrid.py Outdated Show resolved Hide resolved
@max-sixty
Copy link
Collaborator Author

OK - going to hit the button as soon as tests pass.

🙏

@max-sixty max-sixty merged commit d089df3 into pydata:master Aug 8, 2019
@max-sixty max-sixty deleted the black branch August 8, 2019 20:54
@max-sixty
Copy link
Collaborator Author

Please ping here / tag me on the relevant PR with any issues, and I'll help!

@Zac-HD Zac-HD mentioned this pull request Aug 8, 2019
dcherian added a commit to dcherian/xarray that referenced this pull request Aug 8, 2019
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.

5 participants