-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Switch to using black for code formatting #6361
Conversation
This commit updates the CI configuration and local tox configuration to leverage black instead of pycodestyle. It adds a check job to ci and the tox lint job so we can quickly check if black has been run. A tox job named 'black' is added to run black on all the code in the repo.
This commit reformats all the code in the qiskit-terra repository to use black. It changes no functionality in the project and just adjusts the code formatting to be consistent and automated. If you are looking at this commit in the git log you can likely safely ignore any diff from this commit as it is just the result of running '`black' on the repo and instead you should look at any commits before or after this for functional changes.
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.
looks good to me
|
||
## Style and lint | ||
|
||
Qiskit Terra uses 2 tools for verify code formatting and lint checking. The |
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'd rather phase out the name Terra from docs that users see - just saying Qiskit (especially as black will likely be done in other repos too).
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.
We can clean this up later, I was planning to update the overall contributing documentation when we've unified on using black everywhere: https://qiskit.org/documentation/contributing_to_qiskit.html#style-guide right now it just says pycodestyle and pylint
This commit adds a new file with the SHA1 of commits to ignore when running git blame. This is important because of the recent adoption of black as our code formatting tool in Qiskit#6361 we caused a large amount of code churn to change the code formatting. However using the ignore file is a local opt-in feature for git and not something we can enable globally by default. To facilitate this a section is added to the bottom of the contributing guide to document how this file can be used.
This commit adds a new file with the SHA1 of commits to ignore when running git blame. This is important because of the recent adoption of black as our code formatting tool in #6361 we caused a large amount of code churn to change the code formatting. However using the ignore file is a local opt-in feature for git and not something we can enable globally by default. To facilitate this a section is added to the bottom of the contributing guide to document how this file can be used.
In #6361 the CONTRIBUTING.md was updated to reflect the use of black for code formatting. However, as part of that change a typo was made in the link to pylint. This commit corrects that issue so the link to pylint works in the rendered markdown.
* make compatible with pylint and pycodestyle * black config * flake8 compatible config * Missing newline * Add black check to CI and dev requirements This commit updates the CI configuration and local tox configuration to leverage black instead of pycodestyle. It adds a check job to ci and the tox lint job so we can quickly check if black has been run. A tox job named 'black' is added to run black on all the code in the repo. * Run black on everything This commit reformats all the code in the qiskit-terra repository to use black. It changes no functionality in the project and just adjusts the code formatting to be consistent and automated. If you are looking at this commit in the git log you can likely safely ignore any diff from this commit as it is just the result of running '`black' on the repo and instead you should look at any commits before or after this for functional changes. Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
* make compatible with pylint and pycodestyle * black config * flake8 compatible config * Missing newline * Add black check to CI and dev requirements This commit updates the CI configuration and local tox configuration to leverage black instead of pycodestyle. It adds a check job to ci and the tox lint job so we can quickly check if black has been run. A tox job named 'black' is added to run black on all the code in the repo. * Run black on everything This commit reformats all the code in the qiskit-terra repository to use black. It changes no functionality in the project and just adjusts the code formatting to be consistent and automated. If you are looking at this commit in the git log you can likely safely ignore any diff from this commit as it is just the result of running '`black' on the repo and instead you should look at any commits before or after this for functional changes. Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
* make compatible with pylint and pycodestyle * black config * flake8 compatible config * Missing newline * Add black check to CI and dev requirements This commit updates the CI configuration and local tox configuration to leverage black instead of pycodestyle. It adds a check job to ci and the tox lint job so we can quickly check if black has been run. A tox job named 'black' is added to run black on all the code in the repo. * Run black on everything This commit reformats all the code in the qiskit-terra repository to use black. It changes no functionality in the project and just adjusts the code formatting to be consistent and automated. If you are looking at this commit in the git log you can likely safely ignore any diff from this commit as it is just the result of running '`black' on the repo and instead you should look at any commits before or after this for functional changes. Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
* make compatible with pylint and pycodestyle * black config * flake8 compatible config * Missing newline * Add black check to CI and dev requirements This commit updates the CI configuration and local tox configuration to leverage black instead of pycodestyle. It adds a check job to ci and the tox lint job so we can quickly check if black has been run. A tox job named 'black' is added to run black on all the code in the repo. * Run black on everything This commit reformats all the code in the qiskit-terra repository to use black. It changes no functionality in the project and just adjusts the code formatting to be consistent and automated. If you are looking at this commit in the git log you can likely safely ignore any diff from this commit as it is just the result of running '`black' on the repo and instead you should look at any commits before or after this for functional changes. Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
Summary
This PR migrates the qiskit-terra repo to use black for code formatting. It replaces our usage of
pycodestyle
for code style enforcement. This removes any questions or uncertainty around code formatting asblack
isautomated and formats the code for us in consistent style. Contributors simply just need to run black locally and the code will
be updated to use a consistent formatting.
This PR runs black on the entire repository (hence the gigantic diff) and updates the CI and local lint configurations to run black
in check mode instead of pycodestyle.
Details and comments
This PR builds on the work done by @levbishop in #6032 and #5883 but also adds the necessary CI configuration and documentation to the contributing guide. It also runs black on the current state of the repository.