Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,9 @@ fn check_fixture_returns(checker: &Checker, name: &str, body: &[Stmt], returns:
))
});
if let Some(return_type_edit) = return_type_edit {
diagnostic.set_fix(Fix::safe_edits(yield_edit, [return_type_edit]));
diagnostic.set_fix(Fix::unsafe_edits(yield_edit, [return_type_edit]));
} else {
diagnostic.set_fix(Fix::safe_edit(yield_edit));
diagnostic.set_fix(Fix::unsafe_edit(yield_edit));
}
}
}
Expand Down
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:17:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield`
|
15 | def error():
16 | resource = acquire_resource()
17 | yield resource
| ^^^^^^^^^^^^^^
| ^^^^^ PT022
18 |
19 |
|
help: Replace `yield` with `return`
|
15 | def error():
16 | resource = acquire_resource()
- yield resource
17 - yield resource
17 + return resource
18 |
|
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:37: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()
35 | @pytest.fixture
36 | def error():
37 | yield resource
| ^^^^^^^^^^^^^^
| ^^^^^ PT022
38 |
39 |
|
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
35 | @pytest.fixture
36 | def error():
37 - yield resource
37 + return resource
38 |
|
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:43:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield`
|
41 | def error() -> Generator[Resource, None, None]:
42 | resource = acquire_resource()
41 | @pytest.yield_fixture
42 | def error():
43 | 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
41 | @pytest.yield_fixture
42 | def error():
43 - yield resource
43 + return resource
|
note: This is an unsafe fix and may change runtime behavior