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

Applied black formatting #55

Closed
wants to merge 18 commits into from
Closed

Applied black formatting #55

wants to merge 18 commits into from

Conversation

andrewasheridan
Copy link

@andrewasheridan andrewasheridan commented Nov 30, 2019

Bullet Pull Request


Summary

Implements code formatting through the use of the Python code formatter black

Motivation

Reading and working on code that uses a standard formatting is easier.

This PR should satisfy Issue #17

Implementation

  • Each python file was formatted using the command black -l 120 <filename> and committed
  • Zero logic was altered, only formatting

Why use black?

black follows a strict subset of PEP8 and it is easy to use.

What really did black do here?

The biggest changes:

  • Single-quotes ' become double-quotes "
  • Statements that could be written in less than 120 characters, which used to be multi-line, are now single line
  • Files that did not end in a blank line now do
  • Spacing was standardized

How do we use and install black?

to install:
pip install black

to use:
black -l 120 <filename>

What is -l 120?

By passing in the argument -l 120 to black we are telling it to use a 120 length line limit. The default for black is 88 characters, I have found 120 to be more readable.

Is there a way to apply black automatically before a commit?

Yes! We can use a pre-commit hook. There are many ways to set a formatter like black as part of a pre-commit hook. I did not want to include that in this PR because I felt that it was outside the scope of the PR.

I like to use pre-commit for pre-commit hooks. The instructions at their site are adequate, but I would be happy to set them up for this great project.

You could also manually create pre-commit hooks, or add black to your favorite IDE. Black integrates nicely to PyCharm, Sublime, and VSCode.

Note: I have no affiliation with black or pre-commit or anything else. Like bullet, I think they are great projects.


DCO 1.1 Signed-off-by: Andrew A Sheridan sheridan@berkeley.edu

Comment on lines -7 to -8
long_description="Extensive support for Python list prompts \
formatting and colors",
Copy link
Author

Choose a reason for hiding this comment

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

I actually removed the \ and made this a single line string manually. This was the only change that I made manually.

@andrewasheridan andrewasheridan changed the title Feature/black 120 Applied black formatting Nov 30, 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.

None yet

1 participant