Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 14, 2025

Conversation

LaBatata101
Copy link
Contributor

Summary

Fixes #17599.

Test Plan

Snapshot tests.

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 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
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