Skip to content

Stabilize RUF061#22917

Merged
ntBre merged 1 commit intobrent/0.15.0from
brent/ruf061
Jan 29, 2026
Merged

Stabilize RUF061#22917
ntBre merged 1 commit intobrent/0.15.0from
brent/ruf061

Conversation

@ntBre
Copy link
Contributor

@ntBre ntBre commented Jan 28, 2026

I made two small tweaks to the docs, but this otherwise looked good to me.

https://docs.astral.sh/ruff/rules/legacy-form-pytest-raises/

I made two small tweaks to the docs, but this otherwise looked good to me.
@ntBre ntBre added this to the v0.15 milestone Jan 28, 2026
@ntBre ntBre added the rule Implementing or modifying a lint rule label Jan 28, 2026
@ntBre ntBre requested review from amyreese and dylwil3 January 28, 2026 16:15
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 28, 2026

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+206 -0 violations, +0 -0 fixes in 3 projects; 52 projects unchanged)

apache/superset (+3 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --no-preview --select ALL

+ tests/integration_tests/datasource_tests.py:354:9: RUF061 Use context-manager form of `pytest.raises()`
+ tests/integration_tests/datasource_tests.py:502:9: RUF061 Use context-manager form of `pytest.raises()`
+ tests/integration_tests/datasource_tests.py:514:9: RUF061 Use context-manager form of `pytest.raises()`

pytest-dev/pytest (+131 -0 violations, +0 -0 fixes)

+ testing/_py/test_local.py:1093:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/_py/test_local.py:1391:9: RUF061 Use context-manager form of `pytest.raises()`
+ testing/_py/test_local.py:623:9: RUF061 Use context-manager form of `pytest.raises()`
+ testing/_py/test_local.py:992:9: RUF061 Use context-manager form of `pytest.raises()`
+ testing/_py/test_local.py:993:9: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_code.py:91:15: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1019:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1068:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1082:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1101:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1118:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1149:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1182:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1214:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1244:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1271:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1327:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1380:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1473:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:1568:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:225:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:243:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:254:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:276:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:297:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:315:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:331:19: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:336:15: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:346:16: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:357:16: RUF061 Use context-manager form of `pytest.raises()`
+ testing/code/test_excinfo.py:369:15: RUF061 Use context-manager form of `pytest.raises()`
... 100 additional changes omitted for project

astropy/astropy (+72 -0 violations, +0 -0 fixes)

+ astropy/constants/tests/test_constant.py:51:5: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/constants/tests/test_constant.py:55:5: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/constants/tests/test_constant.py:58:5: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/hdu/compressed/tests/test_compressed.py:137:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:1015:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:1016:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:1019:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:1020:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:1158:17: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:336:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:337:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:338:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:339:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:349:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:352:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:374:9: RUF061 Use context-manager form of `pytest.raises()`
+ astropy/io/fits/tests/test_core.py:375:9: RUF061 Use context-manager form of `pytest.raises()`
... 55 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF061 206 206 0 0 0

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre
Copy link
Contributor Author

ntBre commented Jan 28, 2026

This looks like a pedantic rule that I would not vote to enable by default, but all of the ecosystem hits in the comment look like clear true positives.

@amyreese
Copy link
Member

I kind of disagree. Because it's well-targeted, and IMO pushes users towards better code patterns, I think it's a clear win as a default rule.

@ntBre
Copy link
Contributor Author

ntBre commented Jan 28, 2026

I guess I'm just a sucker for code golf 😆 A lot of the ecosystem hits are one-liners that would instead become two-liners, but I definitely agree for longer cases like the very first hit:

        pytest.raises(
            SupersetGenericDBErrorException,
            lambda: db.session.query(SqlaTable)
            .filter_by(id=tbl.id)
            .one_or_none()
            .external_metadata(),
        )

I probably shouldn't over-index on the results on pytest itself anyway.

@ntBre ntBre merged commit 9b88873 into brent/0.15.0 Jan 29, 2026
42 checks passed
@ntBre ntBre deleted the brent/ruf061 branch January 29, 2026 14:02
@ntBre ntBre mentioned this pull request Jan 29, 2026
3 tasks
ntBre added a commit that referenced this pull request Feb 3, 2026
I made two small tweaks to the docs, but this otherwise looked good to
me.

https://docs.astral.sh/ruff/rules/legacy-form-pytest-raises/
ntBre added a commit that referenced this pull request Feb 3, 2026
I made two small tweaks to the docs, but this otherwise looked good to
me.

https://docs.astral.sh/ruff/rules/legacy-form-pytest-raises/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants