zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

Ignore new ruff rules (ruff 0.12)

Open DimitriPapadopoulos opened this issue 6 months ago • 2 comments

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)

DimitriPapadopoulos avatar Jun 18 '25 07:06 DimitriPapadopoulos

What do these rules do? Can we fix for them instead of ignoring them?

dstansby avatar Jun 18 '25 20:06 dstansby

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

DimitriPapadopoulos avatar Jun 18 '25 22:06 DimitriPapadopoulos

In my opinion:

PT011 pytest.raises(ValueError) is too broad, set the match parameter or use a more specific exception PT030 pytest.warns(DeprecationWarning) is too broad, set the match parameter or use a more specific warning

We should definitely enforce these.

PT012 pytest.raises() block should contain a single simple statement PT031 pytest.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.

dstansby avatar Jul 06 '25 20:07 dstansby

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.

dstansby avatar Jul 06 '25 20:07 dstansby

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.

DimitriPapadopoulos avatar Jul 07 '25 11:07 DimitriPapadopoulos

Superseded by #3214.

DimitriPapadopoulos avatar Jul 07 '25 21:07 DimitriPapadopoulos