Skip to content

[flake8-pytest-style] PT001/PT023 fix makes syntax error on parenthesized decorator - #18782

Merged
MichaReiser merged 3 commits into
astral-sh:mainfrom
danparizher:fix-18771
Jun 23, 2025
Merged

MichaReiser merged 3 commits into
astral-sh:mainfrom
danparizher:fix-18771

Conversation

@danparizher

Copy link
Copy Markdown
Contributor

Fixes #18771

Summary

  1. PT001 – @pytest.fixture parentheses style
  • Handles alias-imported fixtures and decorators wrapped in an outer pair of parentheses (e.g. @(pytest.fixture())).
  • Ensures the rule honours the lint.flake8-pytest-style.fixture-parentheses setting for every variant.
  • Updates reference tests (PT001.py) and snapshots.
  1. PT023 – @pytest.mark.<marker> parentheses style
  • Extends the checker so it also flags/removes superfluous parentheses when the mark is applied to classes, nested classes, or is itself wrapped in outer parentheses.
  • Keeps behaviour consistent with lint.flake8-pytest-style.mark-parentheses.
  • Adds/updates fixture file (PT023.py) and snapshots.

Test Plan

  1. Unit / snapshot tests
  • cargo nextest run (or cargo test) — all suites pass.
  • Updated PT001 and PT023 snapshots reviewed and accepted via cargo insta review.
  1. Manual smoke test
  • Ran ruff check on a sample project with mixed fixture/mark styles to confirm that:
  • Unnecessary parentheses are now flagged/auto-fixed in every location.
  • Legitimate calls with arguments remain unaffected.

@github-actions

github-actions Bot commented Jun 19, 2025 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you

@MichaReiser MichaReiser added bug An issue describing something that isn't working, or a PR that fixes a bug fixes Related to suggested fixes for violations labels Jun 23, 2025
@MichaReiser
MichaReiser merged commit 7ec7853 into astral-sh:main Jun 23, 2025
@danparizher
danparizher deleted the fix-18771 branch June 23, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flake8-pytest-style] PT001/PT023 fix makes syntax error on parenthesized decorator

2 participants