chore: enable pytest ruff rule and apply fixes
Description
This PR enables additional Ruff linting rules and applies fixes to the codebase as suggested by Ruff. The changes include:
Enabling PT (pytest-style) rules in pyproject.toml.
fixes issues raised by ruff linter which included:
- PT006: Update @pytest.mark.parametrize to use a tuple for multiple parameters instead of a list or comma-separated strings.
- PT011: Ensure
pytest.raises()is called with amatchparameter to avoid catching overly broad exceptions. - PT012: Ensure
pytest.raises()context managers contains only a single statement.
Related to #4925
Type of change
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Optimization (back-end change that speeds up the code)
- [x] Bug fix (non-breaking change which fixes an issue)
Key checklist:
- [X] No style issues:
$ pre-commit run(or$ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code) - [x] All tests pass:
$ python -m pytest(or$ nox -s tests) - [ ] The documentation builds:
$ python -m pytest --doctest-plus src(or$ nox -s doctests)
You can run integration tests, unit tests, and doctests together at once, using $ nox -s quick.
Further checks:
- [ ] Code is commented, particularly in hard-to-understand areas
- [x] Tests added that prove fix is effective or that feature works
Yes thanks!, would resolve the conflicts and push it
Was thinking to open the PR to enable isort rule along with its suggested fixes as well
Though it does suggest changes in a lot of files, most of them are at the top of the files which shouldn't cause any issues, Do you suggest to go ahead with this @Saransh-cpp ?
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.58%. Comparing base (
54f6e21) to head (5dc454b).
Additional details and impacted files
@@ Coverage Diff @@
## develop #4928 +/- ##
========================================
Coverage 98.58% 98.58%
========================================
Files 304 304
Lines 23689 23689
========================================
Hits 23353 23353
Misses 336 336
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Do you suggest to go ahead with this
Yes, sounds good to me.
pre-commit.ci run
Thanks!