[flake8-pytest-style] Make fixes safe by default and unsafe only when comments are present (PT018) - #27201
Merged
Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| pytest-composite-assertion | 106 | 53 | 53 | 0 | 0 |
ntBre
requested changes
Jul 27, 2026
ntBre
left a comment
Contributor
There was a problem hiding this comment.
This is a stable rule, so we have to make this change in preview in accordance with our Versioning policy.
flake8-pytest-style] Make fixes safe by default and unsafe only when comments are present (PT018)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #20698.
PT018rule splits composite assertions into individualassertstatements. Because standard transformations (without custom messages) maintain short-circuiting and original runtime behavior, these fixes are now classified as safe by default, rather than marking every fix as unsafe.Proposed fixed will now composite assertion with an internal comment. Ordinary transformations are safe while the comment-bearing case receives an unsafe fix and this is verified.
Test Plan
cargo test -p ruff_linter --lib rule_pytestcompositeassertion_path_new_pt018_py_settings_default_pt018_expectscargo fmt --all --check