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

Pylint configuration to prevent accidentally committing debugging print statements #13796

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Feb 5, 2025

Summary

Adds the bad_builtin extension to pylint and raise a warning when print is used. Add a disable for current cases.

Details and comments

It happens from time to time that we accidentally push for code with debugging print statements. Many times, they are captured during revision. However, sometimes they end up in main. Maybe it helps if pylint tell us.

out-of-scope: evaluate if the current prints are justify. Issues can be submitted for them independently.

@1ucian0 1ucian0 requested review from nonhermitian and a team as code owners February 5, 2025 22:43
@qiskit-bot
Copy link
Collaborator

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

@1ucian0 1ucian0 added type: qa Issues and PRs that relate to testing and code quality Changelog: None Do not include in changelog labels Feb 5, 2025
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

This seems like a reasonable and easy catch for the test suite. We only really rarely use it in library code (mostly just visualisations), so I think it'll probably help more than hurt - it's easy to blanket allow in relevant tools (though it'd be cool if we could more easily configure pylint per directory).

@jakelishman jakelishman enabled auto-merge February 5, 2025 22:52
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13167960236

Details

  • 2 of 6 (33.33%) changed or added relevant lines in 5 files are covered.
  • 9 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.003%) to 88.654%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/quantum_info/operators/operator.py 0 1 0.0%
qiskit/quantum_info/states/densitymatrix.py 0 1 0.0%
qiskit/quantum_info/states/statevector.py 0 1 0.0%
qiskit/visualization/circuit/matplotlib.py 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 92.97%
crates/qasm2/src/lex.rs 2 93.23%
crates/qasm2/src/parse.rs 6 97.15%
Totals Coverage Status
Change from base Build 13165103262: 0.003%
Covered Lines: 79232
Relevant Lines: 89372

💛 - Coveralls

@jakelishman jakelishman added this pull request to the merge queue Feb 6, 2025
Merged via the queue into Qiskit:main with commit 4521122 Feb 6, 2025
18 checks passed
@Cryoris Cryoris mentioned this pull request Feb 6, 2025
@1ucian0
Copy link
Member Author

1ucian0 commented Feb 6, 2025

though it'd be cool if we could more easily configure pylint per directory.

I fully agree. However, I'm hesitant if introducing a plugin just for this is worthy.

@jakelishman
Copy link
Member

Oh yeah, I don't want a plugin really, I kind of wanted it as a pylint builtin. We should probably put more effort in moving to Ruff properly than trying to fix up pylint at this stage - I think I was the last major hold-out a year ago or so.

I have a semi-decent configuration for the basis-constructor plugin repo that we might be able to bring over to Qiskit, though I'm still nervous that it's not as effective as pylint (but it is a hell of a lot faster).

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 type: qa Issues and PRs that relate to testing and code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants