-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add isort for import linting #7181
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7181 +/- ##
========================================
Coverage 98.13% 98.14%
========================================
Files 1098 1100 +2
Lines 95812 96191 +379
========================================
+ Hits 94029 94409 +380
+ Misses 1783 1782 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
For some reason this does not recognize Example after isort run: diff --git a/cirq-aqt/cirq_aqt/aqt_device_metadata.py b/cirq-aqt/cirq_aqt/aqt_device_metadata.py
index 82137d37..f75b6e85 100644
--- a/cirq-aqt/cirq_aqt/aqt_device_metadata.py
+++ b/cirq-aqt/cirq_aqt/aqt_device_metadata.py
@@ -19,6 +19,5 @@ from typing import Any, Iterable, Mapping
-import networkx as nx
-
import cirq
from cirq_aqt import aqt_target_gateset
+import networkx as nx
|
@pavoljuhas I added a |
Allow redirect the output to file without terminal color codes.
And disregard extra line in `black --version` output.
Also move the `tool.isort` section in pyproject.toml per alphabetic order.
Yes, looks good. I test ran I took the liberty with adding a few tweaks in 8570d70...e949485, the main one is to ignore the machine-generated |
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, please check if you are OK with a couple of tweaks I pushed to the PR.
Thank you for taking care of this!
The `check/format-incremental` needs more work. isort invocation should skip `__init__.py` files, but it does not. Related to quantumlib#7181
* CI - skip sorting of imports with isort The `check/format-incremental` needs more work. isort invocation should skip `__init__.py` files, but it does not. Related to #7181 * Add TODO note for re-enabling isort
Set the `CI` environment variable to get the `--color` option unconditionally. Also check if `isort` is invoked. Follow-up to quantumlib#7181
This adds information about `isort`'s use in Cirq, now that PR quantumlib#7181 has been merged and `isort` is used in the check/ scripts.
* Add citation for Tesseract Decoder * Add Tesseract Decoder & remove Rigetti * Remove statement about cirq-rigetti It seems like the Docker container may not be used solely for the Rigetti module, so I left the other text about Docker and only removed the statement involving Rigetti. * Add mention of Tesseract & fix a couple of tiny niggles * Remove mention of labels no longer used This entire section still needs a good re-think and more revisions. For now, I just removed mention of the labels that have been changed. * Repeat the statement about vendor modules It's true that the section on what's covered mentioned that vendor modules are not, but it seemed strange that it was not mentioned in the section that is specifically about what's no covered. * Edit for typos Mostly fix capitalization and occasional missing hyphens. * Add notices that cirq-rigetti is deprecated * Small edits for grammar and clarity * Move paragraph about hardware modules higher in the list Putting the bullet item about hardware modules seems higher in the list seems like it's better, so that the flow of concepts goes somewhare more general to somewhat more specific. * Trivial edits to rewrite a phrase & add formatting * Fix trivial typos * Partially rewrite support.md Changes: * There were 3 H1 headings, and at the same time, the first heading did not match what is in the TOC. I changed this to have one H1 heading that matches the TOC text, made the remaining headings H2, and added a lead-in paragaraph * Rewrote the section about using the issue tracker in attempt to be more specific and clear. * Added a section about using the Q.C. Stack Exchange. * Added a section about using email to contact us. * Fix minor inconsistent heading content style A trivial change to match the way other headings were written. * Update triage description Removed more no-longer-existing issue labels, and rewrote section on stale issue/PR heading to be more succinct. * Fix trivial typos Capitalization and placement of colon characters. * Run spell checker * Fix a few more typos * Fix a few more tiny typos * Take out Tesseract for now It has no Cirq interface, and it's a bit too early stage still. * Update list of software * Spell out LBL and ORNL * Mildly edit another description * Fix misspelled name * Remove cirq-rigetti from list of example modules It's not essential, and removing it now will help reduce the number of places we have to update when we remove Rigetti altogether. * Make note of deprecation status in more places * Update the section on Python imports This adds information about `isort`'s use in Cirq, now that PR #7181 has been merged and `isort` is used in the check/ scripts. * Fix typo * Shorten the import ordering section --------- Co-authored-by: Pavol Juhas <juhas@google.com>
* Add isort for import linting * Fix isort color output * Fix np2 test * Add cirq as known first-party * Add "cirq*" as known first-party * Colorize formatters output only if going to terminal or GHA log Allow redirect the output to file without terminal color codes. * Use long-form isort option for verbosity And disregard extra line in `black --version` output. * isort - skip generated Python protobuf sources Also move the `tool.isort` section in pyproject.toml per alphabetic order. --------- Co-authored-by: Pavol Juhas <juhas@google.com>
* CI - skip sorting of imports with isort The `check/format-incremental` needs more work. isort invocation should skip `__init__.py` files, but it does not. Related to quantumlib#7181 * Add TODO note for re-enabling isort
…uantumlib#7196) Set the `CI` environment variable to get the `--color` option unconditionally. Also check if `isort` is invoked. Follow-up to quantumlib#7181
…mlib#7175) * Add citation for Tesseract Decoder * Add Tesseract Decoder & remove Rigetti * Remove statement about cirq-rigetti It seems like the Docker container may not be used solely for the Rigetti module, so I left the other text about Docker and only removed the statement involving Rigetti. * Add mention of Tesseract & fix a couple of tiny niggles * Remove mention of labels no longer used This entire section still needs a good re-think and more revisions. For now, I just removed mention of the labels that have been changed. * Repeat the statement about vendor modules It's true that the section on what's covered mentioned that vendor modules are not, but it seemed strange that it was not mentioned in the section that is specifically about what's no covered. * Edit for typos Mostly fix capitalization and occasional missing hyphens. * Add notices that cirq-rigetti is deprecated * Small edits for grammar and clarity * Move paragraph about hardware modules higher in the list Putting the bullet item about hardware modules seems higher in the list seems like it's better, so that the flow of concepts goes somewhare more general to somewhat more specific. * Trivial edits to rewrite a phrase & add formatting * Fix trivial typos * Partially rewrite support.md Changes: * There were 3 H1 headings, and at the same time, the first heading did not match what is in the TOC. I changed this to have one H1 heading that matches the TOC text, made the remaining headings H2, and added a lead-in paragaraph * Rewrote the section about using the issue tracker in attempt to be more specific and clear. * Added a section about using the Q.C. Stack Exchange. * Added a section about using email to contact us. * Fix minor inconsistent heading content style A trivial change to match the way other headings were written. * Update triage description Removed more no-longer-existing issue labels, and rewrote section on stale issue/PR heading to be more succinct. * Fix trivial typos Capitalization and placement of colon characters. * Run spell checker * Fix a few more typos * Fix a few more tiny typos * Take out Tesseract for now It has no Cirq interface, and it's a bit too early stage still. * Update list of software * Spell out LBL and ORNL * Mildly edit another description * Fix misspelled name * Remove cirq-rigetti from list of example modules It's not essential, and removing it now will help reduce the number of places we have to update when we remove Rigetti altogether. * Make note of deprecation status in more places * Update the section on Python imports This adds information about `isort`'s use in Cirq, now that PR quantumlib#7181 has been merged and `isort` is used in the check/ scripts. * Fix typo * Shorten the import ordering section --------- Co-authored-by: Pavol Juhas <juhas@google.com>
Addresses #4863 with isort, as recommended by @maffoo in that issue's discussion. This PR integrates it into
format-incremental
(and respects the--apply
arg) rather than having its own "sort-imports" script, as it seems like better developer ergonomics.This PR just adds the tool and updates
format-incremental
. It doesn't change any existing imports, since that can be done separately. Once the PR is merged, it will be possible to runisort .
and open a new PR that has all the imports sorted consistently. I've tried this locally and it works (and hits 100+ files).__init__.py
files are excluded for now, because in some of them, reordering the imports breaks things. That should probably be addressed later.Fixes #4863