Ignore new ruff rules (ruff 0.12)
TODO:
- [ ] Add unit tests and/or doctests in docstrings
- [ ] Add docstrings and API docs for any new/modified user-facing classes and functions
- [ ] New/modified features documented in
docs/user-guide/*.rst - [ ] Changes documented as a new file in
changes/ - [x] GitHub Actions have all passed
- [x] Test coverage is 100% (Codecov passes)
What do these rules do? Can we fix for them instead of ignoring them?
We could, but some maintainers don't like them:
PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception
PT012 `pytest.raises()` block should contain a single simple statement
PT030 `pytest.warns(DeprecationWarning)` is too broad, set the `match` parameter or use a more specific warning
PT031 `pytest.warns()` block should contain a single simple statement
In my opinion:
PT011
pytest.raises(ValueError)is too broad, set thematchparameter or use a more specific exception PT030pytest.warns(DeprecationWarning)is too broad, set thematchparameter or use a more specific warning
We should definitely enforce these.
PT012
pytest.raises()block should contain a single simple statement PT031pytest.warns()block should contain a single simple statement
I'd be interested to see what needs fixing to enable these, and if it's reasonable changes enforce them.
If you'd be up for it, a PR to fix the first two (adding match to pytest.raises) would be great, and a separate PR to see what fixing the second two would be good too.
I'd rather avoid adding the match argument in this PR, changes are extensive as far as I can remember.
As for the second two, they imply transforming large pytest.raises()/pytest.warns() blocks into a small block that contains only the statement that raises or emits the warning. The rest being is moved outside the block.
Superseded by #3214.