Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.24k stars 2.36k forks source link

Incrementally enable new Pylint lints #9614

Open Eric-Arellano opened 1 year ago

Eric-Arellano commented 1 year ago

Our previous Pylint version was 2.8, and I recently upgraded it to 2.16 in https://github.com/Qiskit/qiskit-terra/commit/041877bfc436cb7d8ddc799ab663ad1e62c08ff7. To facilitate landing it, I disabled a bunch of checks. But most of them would be good to activate.

Working on this PR means:

  1. Choose one of the checks you want to enable from here:

https://github.com/Qiskit/qiskit-terra/blob/4e3b283157b43687db4260cee6decf17fbb37608/.pylintrc#L77-L109

  1. Delete it from .pylintrc
  2. Run tox -e lint and fix all the issues until tox -e lint succeeds.

To make it easier for code reviewers, it's a good idea to activate 1 or 2 checks at a time.

lambda-knight commented 1 year ago

Fixing consider-using-f-string (C0209) is worth trying ?

Eric-Arellano commented 1 year ago

Yes, @lambda-knight consider-using-f-string looks useful to me. Note though that we are transitioning to Ruff instead of Pylint. So it may be worth double checking that Ruff has a similar lint.

Even if Ruff doesn't have it, I still think it's valuable to fix all our historical instances regardless of if we introduce future "regressions" or not. Let's say we have 200 issues now, and we introduce 50 in the next 60 months. Better to have 200/250 fixed than 0/250.

lambda-knight commented 1 year ago

OK, @Eric-Arellano , Enabling consider-using-f-string, 192 files and 520 warnings are reported. I am fixing code of this warning and will issue PR.

joesho112358 commented 6 months ago

@lambda-knight hi, can i help out with consider-using-f-string?