-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Change default for PT001 and PT023 #12838
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
138 changes: 102 additions & 36 deletions
138
...pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap
This file contains 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,61 +1,127 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs | ||
--- | ||
PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` | ||
PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | ||
| | ||
9 | @pytest.fixture | ||
| ^^^^^^^^^^^^^^^ PT001 | ||
10 | def no_parentheses(): | ||
11 | return 42 | ||
14 | @pytest.fixture() | ||
| ^^^^^^^^^^^^^^^^^ PT001 | ||
15 | def parentheses_no_params(): | ||
16 | return 42 | ||
| | ||
= help: Add parentheses | ||
= help: Remove parentheses | ||
|
||
ℹ Safe fix | ||
6 6 | # `import pytest` | ||
7 7 | | ||
8 8 | | ||
9 |[email protected] | ||
9 |[email protected]() | ||
10 10 | def no_parentheses(): | ||
11 11 | return 42 | ||
12 12 | | ||
13 13 | | ||
14 |[email protected]() | ||
14 |[email protected] | ||
15 15 | def parentheses_no_params(): | ||
16 16 | return 42 | ||
17 17 | | ||
|
||
PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` | ||
PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | ||
| | ||
34 | @fixture | ||
| ^^^^^^^^ PT001 | ||
35 | def imported_from_no_parentheses(): | ||
36 | return 42 | ||
24 | / @pytest.fixture( | ||
25 | | | ||
26 | | ) | ||
| |_^ PT001 | ||
27 | def parentheses_no_params_multiline(): | ||
28 | return 42 | ||
| | ||
= help: Add parentheses | ||
= help: Remove parentheses | ||
|
||
ℹ Safe fix | ||
21 21 | return 42 | ||
22 22 | | ||
23 23 | | ||
24 |[email protected]( | ||
25 |- | ||
26 |-) | ||
24 |[email protected] | ||
27 25 | def parentheses_no_params_multiline(): | ||
28 26 | return 42 | ||
29 27 | | ||
|
||
PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | ||
| | ||
39 | @fixture() | ||
| ^^^^^^^^^^ PT001 | ||
40 | def imported_from_parentheses_no_params(): | ||
41 | return 42 | ||
| | ||
= help: Remove parentheses | ||
|
||
ℹ Safe fix | ||
31 31 | # `from pytest import fixture` | ||
32 32 | | ||
33 33 | | ||
34 |-@fixture | ||
34 |+@fixture() | ||
35 35 | def imported_from_no_parentheses(): | ||
36 36 | return 42 | ||
37 37 | | ||
38 38 | | ||
39 |-@fixture() | ||
39 |+@fixture | ||
40 40 | def imported_from_parentheses_no_params(): | ||
41 41 | return 42 | ||
42 42 | | ||
|
||
PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` | ||
PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | ||
| | ||
59 | @aliased | ||
| ^^^^^^^^ PT001 | ||
60 | def aliased_no_parentheses(): | ||
61 | return 42 | ||
49 | / @fixture( | ||
50 | | | ||
51 | | ) | ||
| |_^ PT001 | ||
52 | def imported_from_parentheses_no_params_multiline(): | ||
53 | return 42 | ||
| | ||
= help: Add parentheses | ||
= help: Remove parentheses | ||
|
||
ℹ Safe fix | ||
46 46 | return 42 | ||
47 47 | | ||
48 48 | | ||
49 |-@fixture( | ||
50 |- | ||
51 |-) | ||
49 |+@fixture | ||
52 50 | def imported_from_parentheses_no_params_multiline(): | ||
53 51 | return 42 | ||
54 52 | | ||
|
||
PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | ||
| | ||
64 | @aliased() | ||
| ^^^^^^^^^^ PT001 | ||
65 | def aliased_parentheses_no_params(): | ||
66 | return 42 | ||
| | ||
= help: Remove parentheses | ||
|
||
ℹ Safe fix | ||
56 56 | # `from pytest import fixture as aliased` | ||
57 57 | | ||
58 58 | | ||
59 |-@aliased | ||
59 |+@aliased() | ||
60 60 | def aliased_no_parentheses(): | ||
61 61 | return 42 | ||
62 62 | | ||
63 63 | | ||
64 |-@aliased() | ||
64 |+@aliased | ||
65 65 | def aliased_parentheses_no_params(): | ||
66 66 | return 42 | ||
67 67 | | ||
|
||
PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` | ||
| | ||
74 | / @aliased( | ||
75 | | | ||
76 | | ) | ||
| |_^ PT001 | ||
77 | def aliased_parentheses_no_params_multiline(): | ||
78 | return 42 | ||
| | ||
= help: Remove parentheses | ||
|
||
ℹ Safe fix | ||
71 71 | return 42 | ||
72 72 | | ||
73 73 | | ||
74 |-@aliased( | ||
75 |- | ||
76 |-) | ||
74 |+@aliased | ||
77 75 | def aliased_parentheses_no_params_multiline(): | ||
78 76 | return 42 |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that was a bug. It's unclear to me why this rule would depend on enabling that setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's odd. I tried digging through blame but the best I can conclude without spending too much time on it is that it's been this way for a long time xD