Skip to content

[flake8-pytest-style] Don't recommend usefixtures for parametrize values in PT019#17650

Merged
ntBre merged 7 commits intoastral-sh:mainfrom
LaBatata101:fix-PT019
May 14, 2025
Merged

[flake8-pytest-style] Don't recommend usefixtures for parametrize values in PT019#17650
ntBre merged 7 commits intoastral-sh:mainfrom
LaBatata101:fix-PT019

Conversation

@LaBatata101
Copy link
Contributor

Summary

Fixes #17599.

Test Plan

Snapshot tests.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 26, 2025

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+0 -4 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

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

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

- airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:944:89: PT019 Fixture `_json` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
- providers/fab/tests/unit/fab/www/views/test_views_custom_user_views.py:102:71: PT019 Fixture `_` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
- providers/google/tests/unit/google/common/test_deprecated.py:155:61: PT019 Fixture `_str` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
- providers/standard/tests/unit/standard/operators/test_weekday.py:297:57: PT019 Fixture `_` without value is injected as parameter, use `@pytest.mark.usefixtures` instead

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PT019 4 0 4 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -4 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

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

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

- airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:944:89: PT019 Fixture `_json` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
- providers/fab/tests/unit/fab/www/views/test_views_custom_user_views.py:102:71: PT019 Fixture `_` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
- providers/google/tests/unit/google/common/test_deprecated.py:155:61: PT019 Fixture `_str` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
- providers/standard/tests/unit/standard/operators/test_weekday.py:297:57: PT019 Fixture `_` without value is injected as parameter, use `@pytest.mark.usefixtures` instead

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PT019 4 0 4 0 0

@LaBatata101 LaBatata101 changed the title [flake8_pytest_style] Don't recommend usefixtures for parametrize values [flake8_pytest_style] Don't recommend usefixtures for parametrize values in PT019 Apr 26, 2025
@ntBre ntBre added the rule Implementing or modifying a lint rule label Apr 28, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

The logic here looks good. I made a couple of stylistic suggestions and also noted a couple of additional cases we may need to handle for parameterize argument types.

LaBatata101 and others added 4 commits April 30, 2025 18:35
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
@LaBatata101 LaBatata101 requested a review from ntBre April 30, 2025 21:59
@LaBatata101 LaBatata101 changed the title [flake8_pytest_style] Don't recommend usefixtures for parametrize values in PT019 [flake8-pytest-style] Don't recommend usefixtures for parametrize values in PT019 May 1, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a couple small nits and a question. It might also be good to throw in a test for a string where trimming whitespace matters. If we add special handling for Expr::Name, that might deserve a test too.

@LaBatata101 LaBatata101 requested a review from ntBre May 12, 2025 15:03
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just one clarification on the test I was picturing before.

@LaBatata101 LaBatata101 requested a review from ntBre May 12, 2025 19:27
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ntBre ntBre merged commit 9b52ae8 into astral-sh:main May 14, 2025
34 checks passed
@LaBatata101 LaBatata101 deleted the fix-PT019 branch May 14, 2025 15:08
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request May 21, 2025
… values in `PT019` (astral-sh#17650)

<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary
Fixes astral-sh#17599.

## Test Plan

Snapshot tests.

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
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.

PT019 should not recommend usefixtures for parametrize values

2 participants