-
Notifications
You must be signed in to change notification settings - Fork 85
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
Use Black code style #322
Use Black code style #322
Conversation
c20f5fb
to
bb386f7
Compare
I'm going to put this on pause until PR #285 is done, as this will need to get rebased off of that and it will be way easier to resolve conflicts here (default to take all of what is in |
This is mostly following the example in the Black README, and sets the line length to 88 (the default), and skips converting single quotes to double quotes.
Black is Python 3.6+ only. From the README: > It requires Python 3.6.0+ to run but you can reformat Python 2 code > with it, too.
The result of running: black --exclude "pyhf/|tests/|validation/" .
Result of running: black validation/
As Python 2.7 is still supported and support for underscores in numeric literals wasn't added until PEP 515 for Python 3.6+ then by default Black must be run with the --skip-numeric-underscore-normalization option (at least until 2020). c.f. - https://www.python.org/dev/peps/pep-0515/ - https://python3statement.org/
Result of running: black tests/
As Python2 is still supported then the Python 3.6+ option, py36, must be set to false in the default configuration as it will: > will put trailing commas in function signatures and calls also after > *args and **kwargs.
Result of running: black pyhf/modifiers/
Result of running: black pyhf/exceptions/
Result of running: black pyhf/tensor/
Result of running: black pyhf/optimize/
9e13d1c
to
4edba2d
Compare
Also apply Black
4edba2d
to
c03bc2c
Compare
@lukasheinrich @kratsg There are still a few things to iron out to get the tests passing, but as this is changing a lot of files I thought I would ask if you have any thoughts on things you know you want changed now that megachannel PR is in (also huge yay for that!). One thing to mention is that by moving all docstring comments into their places so that they are actually docstrings then |
Only 1 version of the code needs to run it, so there is no harm in setting it to only be run on Python 3.6 and not Python 3.6 or higher
If Black detecs the need to format a file it will show the relevant diff
Description
Let's go
Resolves #185
This is very much a heads up WIP PR that I'm hoping that this will spark some conversation. I think that this is actually something that will be a nice benefit to us in the long run as it will make our commit diffs really only about the code, but we'll have to see everyone's thoughts.
Running Summary:
pyproject.toml
to configure Black using--skip-string-normalization
option to preserve single quotesvalidation/
(04dabde)tests/
(22554c7, bb386f7)pyhf/modifiers/
(31b7513)pyhf/exceptions/
(aed34f2)pyhf/tensor/
(9e13d1c)pyhf/optimize/
(cf1adc8)pyhf/
(067a303)black --check .
to CI to ensure that the code style is BlackREADME
Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees:
Running proposed PR commit log: