-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ruff - enable and fix rules F401, F601 #7413
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
Executed `ruff check --fix` on changed files
Avoid lint errors on unused imports.
Either add name alias or disable the check for intentionally imported submodules.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7413 +/- ##
==========================================
- Coverage 98.69% 98.69% -0.01%
==========================================
Files 1112 1112
Lines 97747 97745 -2
==========================================
- Hits 96469 96467 -2
Misses 1278 1278 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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, with an optional change at your discretion, noted in a comment.
try: | ||
import qiskit as _ | ||
except ImportError: # pragma: no cover | ||
if importlib.util.find_spec('qiskit') is None: # pragma: no cover |
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'm not disputing this approach but this change seems to go against Python EAFP (easier to ask for forgiveness than permission) coding style. (C.f. https://docs.quantifiedcode.com/python-anti-patterns/readability/asking_for_permission_instead_of_forgiveness_when_working_with_files.html).
(Flagging it here even though I see it's done in other places in this 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.
Ack. I just followed the ruff-check recommendation. I suppose for a linter it is impossible to tell if an import is unused intentionally (as in our case) or if it is a leftover dead code. An import is also potentially expensive operation, so there is a benefit in not importing if we just need to know module availability.
- enable and fix F601 - multi-value-repeated-key-literal - enable and fix F401 - unused-import No change in the effective code. Partially implements quantumlib#7371
No change in the effective code.
Partially implements #7371