Skip to content

ruff - enable and fix selected RUF rules#7883

Merged
pavoljuhas merged 25 commits intoquantumlib:mainfrom
joesho112358:ruff-ruf-implementation
Feb 25, 2026
Merged

ruff - enable and fix selected RUF rules#7883
pavoljuhas merged 25 commits intoquantumlib:mainfrom
joesho112358:ruff-ruf-implementation

Conversation

@joesho112358
Copy link
Contributor

@joesho112358 joesho112358 commented Feb 6, 2026

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added the size: L 250< lines changed <1000 label Feb 6, 2026
@joesho112358
Copy link
Contributor Author

@pavoljuhas I would like some input on this. It seems like this is one of those things that might not be wanted. Obviously this PR needs more work to move forward, but I wanted to call it out because it also might be a big changed for some people. A gist of the changes:

tail[::-1] + [n1, n0] + inner
# becomes
[*tail[::-1], n1, n0, *inner]

and

list(sweep.points)[0]
# becomes
next(iter(sweep.points))

I guess the call outs are GridQubits being flagged as tuples:
Example 1

Example 2

and some formatting weirdness:
Example

@pavoljuhas
Copy link
Collaborator

pavoljuhas commented Feb 13, 2026

I guess the call outs are GridQubits being flagged as tuples: Example 1

You'd need to use your judgement to accept or ignore such matches. In some cases the addition should be left as is for example for GridQubit(x, y) + (a, b) which gives an offset GridQubit(x+a, y+b). Elsewhere, where the result is a tuple it makes sense to replace t1 + t2 with (*t1, *t2).

Example 2

Same thing, it should be left alone from the linter POV. BTW, that code is a bit buggy so I will submit a separate PR for that soon.

and some formatting weirdness: Example

I don't know where does that come from, perhaps some formatting feature in IDE? If you run formatter localy, make sure it is black-26.1.0.
If I restore that file back and leave only the change at line 2439

imported = next(iter(parsed_qasm.circuit.all_operations())).gate

the black --check cirq-core/cirq/contrib/qasm_import/_parser_test.py does not complain.
BTW, the iter(...) call on that line is redundant, because circuit.all_operations() is already iterator.
Please correct and look out for similar ruff-generated fixes.

@joesho112358
Copy link
Contributor Author

Will be able to address the comments and pick this up within a week, I hope

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.62%. Comparing base (912a76e) to head (0bd2aa9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7883      +/-   ##
==========================================
- Coverage   99.62%   99.62%   -0.01%     
==========================================
  Files        1104     1104              
  Lines       99317    99322       +5     
==========================================
+ Hits        98944    98947       +3     
- Misses        373      375       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joesho112358 joesho112358 marked this pull request as ready for review February 19, 2026 04:10
@joesho112358
Copy link
Contributor Author

@pavoljuhas this looks to be the last part of #7505 (for now, i assume). feel free to flag me on anything you'd like me to update and I will get to it over the next few days

@pavoljuhas pavoljuhas self-assigned this Feb 24, 2026
Disable RUF005 locally instead.
And fix annotation for `observables_to_settings` which produces
an iterator.
Keep iteration over all results from `Engine.run` so that
the run is completely finished as before.
Block-disables are by default reversed after their block.
Their items can be star-expanded without collecting in temporary container.
@pavoljuhas pavoljuhas changed the title Ruff ruf implementation ruff - enable and fix selected RUF rules Feb 25, 2026
Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple of tweaks pushed in.

Thank you for chipping away this stone!

@pavoljuhas pavoljuhas added this pull request to the merge queue Feb 25, 2026
@pavoljuhas pavoljuhas removed this pull request from the merge queue due to a manual request Feb 25, 2026
@pavoljuhas pavoljuhas enabled auto-merge February 25, 2026 02:12
@pavoljuhas pavoljuhas added this pull request to the merge queue Feb 25, 2026
Merged via the queue into quantumlib:main with commit d837721 Feb 25, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L 250< lines changed <1000

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable more ruff rules for the CI

2 participants