Skip to content

[ruff] Remove pytest-fixture-autouse (RUF076) - #26240

Merged
ntBre merged 3 commits into
mainfrom
brent/revert-ruf076
Jun 25, 2026
Merged

[ruff] Remove pytest-fixture-autouse (RUF076)#26240
ntBre merged 3 commits into
mainfrom
brent/revert-ruf076

Conversation

@ntBre

@ntBre ntBre commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR removes RUF076 that was added in #25477 and closes #26178. It should also reopen #12491.

The reason for the removal is that this rule is very opinionated. I knew that going in, but I failed
to consider the effect of adding a pedantic rule to the RUF selector, which many preview users
enable as a whole.

The implementation was okay otherwise and can be reinstated once we have a better category for the
rule, which #1774 should help with.

We initially opted for a full revert, but marking the rule as removed both avoids an invalid configuration error for projects that already ignore the rule (although they will still see a warning) and prevents another rule in the future from reusing the code.

I don't believe we've done this before, but we can also reinstate the rule simply by switching its metadata back from removed_since to preview_since (and updating the mdtests, which I also opted to preserve).

Summary
--

This PR reverts #25477 and closes #26178. It should also reopen #12491.

The reason for the revert is that this rule is very opinionated. I knew that going in, but I failed
to consider the effect of adding a pedantic rule to the `RUF` selector, which many preview users
enable as a whole.

The implementation was okay otherwise and can be reinstated once we have a better category for the
rule, which #1774 should help with.

The downside of a revert as compared to marking the rule as removed is that it will invalidate any
configs that already `ignore`d the rule, but the rule has only been out for two weeks, so hopefully
this is not too painful. It seems weird to un-remove a rule in the future, so reverting seems
preferable overall.

We should also be careful not to release a different rule under the same code, at least in the same
release as this revert, otherwise such `ignore`s will silently ignore the wrong rule.
@ntBre ntBre added rule Implementing or modifying a lint rule preview Related to preview mode features labels Jun 22, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -1952 violations, +0 -0 fixes in 20 projects; 36 projects unchanged)

RasaHQ/rasa (+0 -6 violations, +0 -0 fixes)

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

- tests/conftest.py:823:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/conftest.py:837:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/conftest.py:881:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/test_telemetry.py:27:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/test_telemetry.py:37:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/utils/test_common.py:29:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators

apache/airflow (+0 -540 violations, +0 -0 fixes)

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

- airflow-core/tests/conftest.py:166:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/system/conftest.py:34:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/always/test_providers_manager.py:346:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/always/test_providers_manager.py:93:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api/common/test_trigger_dag.py:42:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/auth/managers/simple/conftest.py:34:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/auth/test_tokens.py:329:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/common/db/test_dags.py:45:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/common/test_dagbag.py:47:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/common/test_exceptions.py:112:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_asset_state_store.py:57:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py:1515:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py:249:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
... 527 additional changes omitted for project

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

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

- tests/integration_tests/celery_tests.py:71:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/charts/api_tests.py:84:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/charts/data/api_tests.py:91:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/conftest.py:120:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/dao/base_dao_test.py:71:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/dao/conftest.py:46:33: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/dashboards/filter_state/api_tests.py:56:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/dashboards/update_tabs_test.py:39:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/explore/api_tests.py:65:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/integration_tests/explore/form_data/api_tests.py:67:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
... 50 additional changes omitted for project

bokeh/bokeh (+0 -1 violations, +0 -0 fixes)

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

- tests/test_examples.py:114:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators

ibis-project/ibis (+0 -5 violations, +0 -0 fixes)

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

- ibis/backends/flink/tests/conftest.py:201:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- ibis/backends/pyspark/tests/conftest.py:407:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- ibis/backends/pyspark/tests/conftest.py:444:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- ibis/backends/pyspark/tests/conftest.py:475:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- ibis/conftest.py:25:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators

langchain-ai/langchain (+0 -17 violations, +0 -0 fixes)

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

- libs/core/tests/unit_tests/conftest.py:12:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/core/tests/unit_tests/language_models/chat_models/test_rate_limiting.py:12:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/core/tests/unit_tests/load/test_secret_injection.py:35:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/core/tests/unit_tests/runnables/conftest.py:10:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/core/tests/unit_tests/runnables/test_tracing_interops.py:303:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/langchain_v1/tests/unit_tests/conftest.py:20:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/partners/fireworks/tests/integration_tests/conftest.py:35:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/partners/fireworks/tests/unit_tests/test_chat_models.py:640:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/partners/openai/tests/integration_tests/chat_models/conftest.py:27:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- libs/partners/openai/tests/integration_tests/chat_models/conftest.py:65:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
... 7 additional changes omitted for project

lnbits/lnbits (+0 -2 violations, +0 -0 fixes)

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

- tests/conftest.py:80:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/unit/test_fiat_providers.py:60:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators

milvus-io/pymilvus (+0 -5 violations, +0 -0 fixes)

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

- tests/unit/orm/conftest.py:83:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/unit/test_async_milvus_client.py:33:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/unit/test_connection_manager.py:102:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/unit/test_milvus_client.py:40:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/unit/test_repro_issues.py:27:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators

pandas-dev/pandas (+0 -16 violations, +0 -0 fixes)

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

- pandas/conftest.py:279:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/conftest.py:288:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/arithmetic/test_numeric.py:33:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/config/test_config.py:13:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/extension/base/dim2.py:24:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/extension/base/setitem.py:40:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/extension/test_masked.py:167:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/extension/test_string.py:287:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/frame/test_arithmetic.py:50:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- pandas/tests/frame/test_query_eval.py:1651:21: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
... 6 additional changes omitted for project

pypa/build (+0 -4 violations, +0 -0 fixes)

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

- tests/conftest.py:103:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/conftest.py:111:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/conftest.py:118:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- tests/conftest.py:124:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators

pypa/cibuildwheel (+0 -5 violations, +0 -0 fixes)

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

- test/conftest.py:127:34: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- unit_test/main_tests/conftest.py:34:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- unit_test/main_tests/conftest.py:58:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- unit_test/main_tests/conftest.py:63:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators
- unit_test/main_tests/main_requires_python_test.py:18:17: pytest-fixture-autouse Avoid using `autouse=True` in `pytest.fixture` decorators

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
pytest-fixture-autouse 1952 0 1952 0 0

@ntBre

ntBre commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

I guess this is ready for review. The ecosystem check is showing the ignore issue mentioned in the description. indico has already ignored the rule.

@ntBre
ntBre marked this pull request as ready for review June 22, 2026 18:55
@ntBre
ntBre requested a review from MichaReiser June 22, 2026 18:55
@RonnyPfannschmidt

Copy link
Copy Markdown

im aware of a dozens of repos that have this on ignore already, so they would get direct churn

@MichaReiser

Copy link
Copy Markdown
Member

Given that it has already been ignored so actively, I'm leaning towards marking it as removed.

@ntBre

ntBre commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

The churn wouldn't be as bad as I feared as long as #26113 also lands this week, but yeah let's go ahead and mark as removed, otherwise the ecosystem check will continue to fail. That also has the benefit of reserving/blocking the error code from being used by another rule.

@MichaReiser

Copy link
Copy Markdown
Member

Makes sense. We can still remove the removed if #26113 lands before the next release

@ntBre ntBre changed the title Revert "[ruff] Ban pytest autouse fixtures (RUF076) (#25477)" [ruff] Remove pytest-fixture-autouse (RUF076) Jun 23, 2026
@ntBre

ntBre commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Switched this to a removal instead of reverting and updated the summary/title.

@ntBre
ntBre merged commit 572b31e into main Jun 25, 2026
47 checks passed
@ntBre
ntBre deleted the brent/revert-ruf076 branch June 25, 2026 15:35
charliermarsh pushed a commit that referenced this pull request Jun 25, 2026
Summary
--

I didn't think to rebase #26240 after merging #25887 and there was a
conflict in the schema. This should fix the current failure on main.

Test Plan
--

CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUF076: should not fire in conftest.py by default (autouse is the standard pattern there)

3 participants