-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 some files to show style differences #1186
Conversation
Orange is the new black! |
Overall I like it. 👍 |
Shall we adopt this? Given the line length is configurable, I'm okay with us taking this on. |
I haven't heard a strict no yet. There is still some work to do here and we need to figure out a good time to do the flip. I am hoping to have this ready sometime early next week. |
5657b67
to
11b42e8
Compare
This should be ready to go. PR includes:
|
exclude = ''' | ||
|
||
( | ||
/( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also exclude init template directories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. sure can do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have excluded the templates used for sam init
. I will un-format them once, I do the update from develop and rerun black dance.
Makefile
Outdated
# Verifications to run before sending a pull request | ||
pr: init dev | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Makefile
Outdated
@@ -26,5 +26,10 @@ lint: | |||
# Command to run everytime you make changes to verify everything works | |||
dev: flake lint test | |||
|
|||
black-format: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call it just black
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
|
||
[tool.black] | ||
line-length = 120 | ||
target_version = ['py37', 'py27', 'py36'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove py27?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it because we still have py27 support :(. So wasn't comfortable making formatting related this and risk breaking it. I just quickly ran it and the only changes were removing u
from strings like u"help"
. For now, I would prefer to just leave it.
.travis.yml
Outdated
|
||
install: | ||
# Install the code requirements | ||
- make init | ||
|
||
script: | ||
# Verify code is black compliant | ||
- /tmp/black --check setup.py tests samcli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make black
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make black
will format the files are write it back to the filesystem. Instead this commands black --check
makes sure that the files are formatted and if not the build will fail. This ensures our codebase is always formatted. I can create a make black-check
? command or something. I thought about putting it in make pr
but didn't want to go through the hassle of pip installing on appveyor too (you can only [pip] install black in 3.6 or above).
I wonder if we should run |
If we run it as a github post hook, do we still need to run |
| I wonder if we should run make black on a github post hook or something and completely forget about formatting. it gets auto taken care of. @thesriram That is what the | If we run it as a github post hook, do we still need to run make lint/flake ? @viksrivat I think we can remove flake8, but would like to keep pylint around until we know black handles everything. |
DEVELOPMENT_GUIDE.md
Outdated
### 2. Install Additional Tooling | ||
#### Black | ||
We format our code using [Black](https://github.com/python/black) and verify the source code is black compliant | ||
in Travis during PRs. You can find installation instructions on [Black's docs](https://black.readthedocs.io/en/stable/installation_and_usage.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appveyor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
template, | ||
env_vars, | ||
debug_port, | ||
debug_args, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why these random empty lines show up here, github formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any empty lines in the diff. Must be github?
|
||
# Verifications to run before sending a pull request | ||
pr: init dev | ||
pr: init dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't black
run as part of make pr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the make black
command requires you to commit the changes. So I didn't want the make pr
to run that and make it look like it works. I can add another make
command that does the check instead, which is probably what we want anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you install the git hooks, running the check on pr is just redundant. This is because you can't push unless black passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as long as CI passes ⬛️🏴
Issue #, if available:
N/A
Description of changes:
This PR is meant to show what the differences would be if we started to use Black. A good read about benefits and tradeoffs can be found under the Django dep project (dep 0008).
Happy to have a formal write up but wanted to show how this could look in our codebase through a small PR. If the team decides that this is worth while, I can work on formalize this with pre-commit hooks to ensure formatting is always done and therefore we should no longer need to care about formatting :). We could do something similar to how the attrs project is using Black.
Checklist:
make pr
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.