Skip to content
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

Remove consider-using-f-string lint rule and updates #12423

Merged
merged 17 commits into from
Jun 19, 2024

Conversation

joesho112358
Copy link
Contributor

Summary

#9614 removing consider-using-f-string

Details and comments

This is a biggie. can break it down into smaller ones if desired... somehow :)

@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label May 17, 2024
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @enavarro51
  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia
  • @levbishop
  • @mtreinish
  • @nkanazawa1989

@joesho112358 joesho112358 marked this pull request as draft May 17, 2024 02:03
@joesho112358 joesho112358 marked this pull request as ready for review May 17, 2024 02:35
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @enavarro51
  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia
  • @levbishop
  • @mtreinish
  • @nkanazawa1989

@coveralls
Copy link

coveralls commented May 17, 2024

Pull Request Test Coverage Report for Build 9575098874

Details

  • 76 of 131 (58.02%) changed or added relevant lines in 55 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 89.773%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/classicalfunction/boolean_expression.py 0 1 0.0%
qiskit/circuit/equivalence.py 0 1 0.0%
qiskit/circuit/gate.py 1 2 50.0%
qiskit/circuit/tools/pi_check.py 3 4 75.0%
qiskit/dagcircuit/dagdependency.py 3 4 75.0%
qiskit/dagcircuit/dagdependency_v2.py 3 4 75.0%
qiskit/dagcircuit/dagdepnode.py 0 1 0.0%
qiskit/providers/basic_provider/basic_provider_tools.py 0 1 0.0%
qiskit/providers/options.py 0 1 0.0%
qiskit/pulse/transforms/alignments.py 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.11%
Totals Coverage Status
Change from base Build 9571576575: 0.02%
Covered Lines: 63579
Relevant Lines: 70822

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

I only got through qiskit/converters so far, but I need to context switch so I decided to leave a comment on the small amount of progress I've made so far. Overall this looks good thanks a ton for doing this, it's often a thankless job to do this kind of modernization.

I'm just curious did you do this all by hand or did you run something like pyupgrade to automate it?

qiskit/circuit/duration.py Outdated Show resolved Hide resolved
@@ -74,7 +74,7 @@ def __init__(self, adjacency_matrix: list | np.ndarray) -> None:
raise CircuitError("The adjacency matrix must be symmetric.")

num_qubits = len(adjacency_matrix)
circuit = QuantumCircuit(num_qubits, name="graph: %s" % (adjacency_matrix))
circuit = QuantumCircuit(num_qubits, name=f"graph: {adjacency_matrix}")
Copy link
Member

Choose a reason for hiding this comment

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

I did not realize the circuit name for GraphState was embedding a string representation of the adjacency matrix. Lol, that could be quite the string.

qiskit/circuit/library/hamiltonian_gate.py Outdated Show resolved Hide resolved
qiskit/circuit/tools/pi_check.py Outdated Show resolved Hide resolved
else:
str_out = "{:.{}g}".format(single_inpt, ndigits)
str_out = f"{single_inpt:.{ndigits}g}"
Copy link
Member

Choose a reason for hiding this comment

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

I didn't realize you could nest variables in an fstring like this for a formatter. That's a neat trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, not my trick, but i thought it was cool, too! :)

qiskit/circuit/tools/pi_check.py Outdated Show resolved Hide resolved
@joesho112358
Copy link
Contributor Author

I'm just curious did you do this all by hand or did you run something like pyupgrade to automate it?

by hand

Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

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

That certainly was a lot of effort, thanks for tackling this! Just some questions otherwise LGTM.

qiskit/providers/models/backendproperties.py Outdated Show resolved Hide resolved
qiskit/pulse/configuration.py Outdated Show resolved Hide resolved
qiskit/qasm2/export.py Outdated Show resolved Hide resolved
qiskit/qasm2/export.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear/cnot_synth.py Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

In this file there are also some f-string disables, is this due to the mix with Latex? In that case couldn't it be resolved with additional braces, like you already did in some cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think some of these changes initially lead to unit test failures. i will at least narrow it down to make sure everything that can be updated is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nevermind! looks like i may have missed the ide adding/not adding brackets. updates inbound

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nevermind again! didn't realize those unit tests were skipped when i ran locally. i'll have to look into it later

@Cryoris Cryoris added type: qa Issues and PRs that relate to testing and code quality Changelog: None Do not include in changelog labels Jun 19, 2024
Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

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

LGTM thanks for all the effort!

@Cryoris Cryoris added this pull request to the merge queue Jun 19, 2024
Merged via the queue into Qiskit:main with commit 53667d1 Jun 19, 2024
15 checks passed
@joesho112358 joesho112358 deleted the remove-consider-using-f-string branch June 19, 2024 17:59
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
* remove consider-using-f-string lint rule and updates

* reverting a latex update

* f-string update based on review

* Update qiskit/circuit/library/hamiltonian_gate.py

Co-authored-by: Matthew Treinish <[email protected]>

* Update qiskit/circuit/tools/pi_check.py

Co-authored-by: Matthew Treinish <[email protected]>

* Update qiskit/circuit/tools/pi_check.py

Co-authored-by: Matthew Treinish <[email protected]>

* updates after merge

* Update qiskit/providers/models/backendproperties.py

Co-authored-by: Julien Gacon <[email protected]>

* Update qiskit/synthesis/linear/cnot_synth.py

Co-authored-by: Julien Gacon <[email protected]>

* updates from PR

* latex fixes

---------

Co-authored-by: Matthew Treinish <[email protected]>
Co-authored-by: Julien Gacon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog Community PR PRs from contributors that are not 'members' of the Qiskit repo type: qa Issues and PRs that relate to testing and code quality
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants