-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[flake8-pytest-style] Mark PT022 fixes as unsafe
#26440
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
+10
−2
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a81ee25
Change diagnostic fix methods to unsafe edits
joshuavetos c88539d
Update ruff_linter__rules__flake8_pytest_style__tests__PT022.snap
joshuavetos d7a2fd0
Update ruff_linter__rules__flake8_pytest_style__tests__PT022.snap
joshuavetos b737b84
Merge branch 'main' into joshuavetos/main
ntBre 435ed98
document fix safety
ntBre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
69 changes: 34 additions & 35 deletions
69
.../flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,54 @@ | ||
| --- | ||
| source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs | ||
| --- | ||
| PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` | ||
| --> PT022.py:17:5 | ||
| PT022.py:15:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` | ||
| | | ||
| 15 | def error(): | ||
| 16 | resource = acquire_resource() | ||
| 17 | yield resource | ||
| | ^^^^^^^^^^^^^^ | ||
| 13 | @pytest.fixture() | ||
| 14 | def error(): | ||
| 15 | yield resource | ||
| | ^^^^^ PT022 | ||
| 16 | | ||
| 17 | | ||
| | | ||
| help: Replace `yield` with `return` | ||
| | | ||
| 16 | resource = acquire_resource() | ||
| - yield resource | ||
| 17 + return resource | ||
| 18 | | ||
| 13 | @pytest.fixture() | ||
| 14 | def error(): | ||
| 15 - yield resource | ||
| 15 + return resource | ||
| | | ||
| note: This is an unsafe fix and may change runtime behavior | ||
|
|
||
| PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` | ||
| --> PT022.py:37:5 | ||
| PT022.py:35:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` | ||
| | | ||
| 35 | def error() -> typing.Generator[typing.Any, None, None]: | ||
| 36 | resource = acquire_resource() | ||
| 37 | yield resource | ||
| | ^^^^^^^^^^^^^^ | ||
| 33 | @pytest.fixture | ||
| 34 | def error(): | ||
| 35 | yield resource | ||
| | ^^^^^ PT022 | ||
| 36 | | ||
| 37 | | ||
| | | ||
| help: Replace `yield` with `return` | ||
| | | ||
| 34 | @pytest.fixture() | ||
| - def error() -> typing.Generator[typing.Any, None, None]: | ||
| 35 + def error() -> typing.Any: | ||
| 36 | resource = acquire_resource() | ||
| - yield resource | ||
| 37 + return resource | ||
| 38 | | ||
| 33 | @pytest.fixture | ||
| 34 | def error(): | ||
| 35 - yield resource | ||
| 35 + return resource | ||
| | | ||
| note: This is an unsafe fix and may change runtime behavior | ||
|
|
||
| PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` | ||
| --> PT022.py:43:5 | ||
| PT022.py:41:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` | ||
| | | ||
| 41 | def error() -> Generator[Resource, None, None]: | ||
| 42 | resource = acquire_resource() | ||
| 43 | yield resource | ||
| | ^^^^^^^^^^^^^^ | ||
| 39 | @pytest.yield_fixture | ||
| 40 | def error(): | ||
| 41 | yield resource | ||
| | ^^^^^ PT022 | ||
| | | ||
| help: Replace `yield` with `return` | ||
| | | ||
| 40 | @pytest.fixture() | ||
| - def error() -> Generator[Resource, None, None]: | ||
| 41 + def error() -> Resource: | ||
| 42 | resource = acquire_resource() | ||
| - yield resource | ||
| 43 + return resource | ||
| 39 | @pytest.yield_fixture | ||
| 40 | def error(): | ||
| 41 - yield resource | ||
| 41 + return resource | ||
| | | ||
| note: This is an unsafe fix and may change runtime behavior | ||
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.
Uh oh!
There was an error while loading. Please reload this page.