Switch to using black for code formatting#6361
Merged
mtreinish merged 6 commits intoQiskit:mainfrom May 5, 2021
Merged
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.
This was referenced May 5, 2021
ajavadia
approved these changes
May 5, 2021
|
|
||
| ## Style and lint | ||
|
|
||
| Qiskit Terra uses 2 tools for verify code formatting and lint checking. The |
Member
There was a problem hiding this comment.
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).
Member
Author
There was a problem hiding this comment.
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
mtreinish
added a commit
to mtreinish/qiskit-core
that referenced
this pull request
May 5, 2021
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.
mergify Bot
pushed a commit
that referenced
this pull request
May 5, 2021
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.
mtreinish
pushed a commit
that referenced
this pull request
May 7, 2021
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.
Merged
This was referenced Nov 15, 2021
ElePT
pushed a commit
to ElePT/qiskit
that referenced
this pull request
Jun 27, 2023
* 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>
ElePT
pushed a commit
to ElePT/qiskit-algorithms-test
that referenced
this pull request
Jul 17, 2023
* 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>
ElePT
pushed a commit
to ElePT/qiskit-algorithms
that referenced
this pull request
Jul 27, 2023
* 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>
ElePT
pushed a commit
to ElePT/qiskit-ibm-provider
that referenced
this pull request
Oct 9, 2023
* 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the qiskit-terra repo to use black for code formatting. It replaces our usage of
pycodestylefor code style enforcement. This removes any questions or uncertainty around code formatting asblackisautomated 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.