Change default for PT001 and PT023 (#12838)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Micha Reiser 2024-08-13 17:54:36 +02:00
parent 9fd8aaaf29
commit 2e211c5c22
15 changed files with 351 additions and 390 deletions

View file

@ -264,7 +264,7 @@ linter.flake8_import_conventions.aliases = {
}
linter.flake8_import_conventions.banned_aliases = {}
linter.flake8_import_conventions.banned_from = []
linter.flake8_pytest_style.fixture_parentheses = true
linter.flake8_pytest_style.fixture_parentheses = false
linter.flake8_pytest_style.parametrize_names_type = tuple
linter.flake8_pytest_style.parametrize_values_type = list
linter.flake8_pytest_style.parametrize_values_row_type = tuple
@ -278,7 +278,7 @@ linter.flake8_pytest_style.raises_require_match_for = [
socket.error,
]
linter.flake8_pytest_style.raises_extend_require_match_for = []
linter.flake8_pytest_style.mark_parentheses = true
linter.flake8_pytest_style.mark_parentheses = false
linter.flake8_quotes.inline_quotes = double
linter.flake8_quotes.multiline_quotes = double
linter.flake8_quotes.docstring_quotes = double

View file

@ -28,10 +28,10 @@ mod tests {
Rule::PytestFixtureIncorrectParenthesesStyle,
Path::new("PT001.py"),
Settings {
fixture_parentheses: false,
fixture_parentheses: true,
..Settings::default()
},
"PT001_no_parentheses"
"PT001_parentheses"
)]
#[test_case(
Rule::PytestFixturePositionalArgs,
@ -252,10 +252,10 @@ mod tests {
Rule::PytestIncorrectMarkParenthesesStyle,
Path::new("PT023.py"),
Settings {
mark_parentheses: false,
mark_parentheses: true,
..Settings::default()
},
"PT023_no_parentheses"
"PT023_parentheses"
)]
#[test_case(
Rule::PytestUnnecessaryAsyncioMarkOnFixture,

View file

@ -32,10 +32,9 @@ use super::helpers::{
/// optional.
///
/// Either removing those unnecessary parentheses _or_ requiring them for all
/// fixtures is fine, but it's best to be consistent.
///
/// In [preview], this rule defaults to removing unnecessary parentheses, to match
/// the behavior of official pytest projects.
/// fixtures is fine, but it's best to be consistent. The rule defaults to
/// removing unnecessary parentheses, to match the documentation of the
/// official pytest projects.
///
/// ## Example
///
@ -62,8 +61,6 @@ use super::helpers::{
///
/// ## References
/// - [`pytest` documentation: API Reference: Fixtures](https://docs.pytest.org/en/latest/reference/reference.html#fixtures-api)
///
/// [preview]: https://docs.astral.sh/ruff/preview/
#[violation]
pub struct PytestFixtureIncorrectParenthesesStyle {
expected: Parentheses,
@ -938,9 +935,7 @@ pub(crate) fn fixture(
check_fixture_decorator(checker, name, decorator);
}
if checker.enabled(Rule::PytestDeprecatedYieldFixture)
&& checker.settings.flake8_pytest_style.fixture_parentheses
{
if checker.enabled(Rule::PytestDeprecatedYieldFixture) {
check_fixture_decorator_name(checker, decorator);
}

View file

@ -14,8 +14,8 @@ use super::helpers::get_mark_decorators;
/// without parentheses, depending on the [`lint.flake8-pytest-style.mark-parentheses`]
/// setting.
///
/// In [preview], this rule defaults to removing unnecessary parentheses, to match
/// the behavior of official pytest projects.
/// The rule defaults to removing unnecessary parentheses,
/// to match the documentation of the official pytest projects.
///
/// ## Why is this bad?
/// If a `@pytest.mark.<marker>()` doesn't take any arguments, the parentheses are
@ -49,8 +49,6 @@ use super::helpers::get_mark_decorators;
///
/// ## References
/// - [`pytest` documentation: Marks](https://docs.pytest.org/en/latest/reference/reference.html#marks)
///
/// [preview]: https://docs.astral.sh/ruff/preview/
#[violation]
pub struct PytestIncorrectMarkParenthesesStyle {
mark_name: String,

View file

@ -6,7 +6,7 @@ use std::fmt::Formatter;
use crate::display_settings;
use ruff_macros::CacheKey;
use crate::settings::types::{IdentifierPattern, PreviewMode};
use crate::settings::types::IdentifierPattern;
use super::types;
@ -38,27 +38,13 @@ pub struct Settings {
impl Default for Settings {
fn default() -> Self {
Self {
fixture_parentheses: true,
fixture_parentheses: false,
parametrize_names_type: types::ParametrizeNameType::default(),
parametrize_values_type: types::ParametrizeValuesType::default(),
parametrize_values_row_type: types::ParametrizeValuesRowType::default(),
raises_require_match_for: default_broad_exceptions(),
raises_extend_require_match_for: vec![],
mark_parentheses: true,
}
}
}
impl Settings {
pub fn resolve_default(preview: PreviewMode) -> Self {
if preview.is_enabled() {
Self {
fixture_parentheses: false,
mark_parentheses: false,
..Default::default()
}
} else {
Self::default()
mark_parentheses: false,
}
}
}

View file

@ -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 |-@pytest.fixture
9 |+@pytest.fixture()
10 10 | def no_parentheses():
11 11 | return 42
12 12 |
13 13 |
14 |-@pytest.fixture()
14 |+@pytest.fixture
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 |-@pytest.fixture(
25 |-
26 |-)
24 |+@pytest.fixture
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

View file

@ -1,129 +0,0 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
14 | @pytest.fixture()
| ^^^^^^^^^^^^^^^^^ PT001
15 | def parentheses_no_params():
16 | return 42
|
= help: Remove parentheses
Safe fix
11 11 | return 42
12 12 |
13 13 |
14 |-@pytest.fixture()
14 |+@pytest.fixture
15 15 | def parentheses_no_params():
16 16 | return 42
17 17 |
PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
24 | / @pytest.fixture(
25 | |
26 | | )
| |_^ PT001
27 | def parentheses_no_params_multiline():
28 | return 42
|
= help: Remove parentheses
Safe fix
21 21 | return 42
22 22 |
23 23 |
24 |-@pytest.fixture(
25 |-
26 |-)
24 |+@pytest.fixture
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
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:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
49 | / @fixture(
50 | |
51 | | )
| |_^ PT001
52 | def imported_from_parentheses_no_params_multiline():
53 | return 42
|
= 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
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

View file

@ -0,0 +1,59 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
|
9 | @pytest.fixture
| ^^^^^^^^^^^^^^^ PT001
10 | def no_parentheses():
11 | return 42
|
= help: Add parentheses
Safe fix
6 6 | # `import pytest`
7 7 |
8 8 |
9 |-@pytest.fixture
9 |+@pytest.fixture()
10 10 | def no_parentheses():
11 11 | return 42
12 12 |
PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
|
34 | @fixture
| ^^^^^^^^ PT001
35 | def imported_from_no_parentheses():
36 | return 42
|
= help: Add 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 |
PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
|
59 | @aliased
| ^^^^^^^^ PT001
60 | def aliased_no_parentheses():
61 | return 42
|
= help: Add 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 |

View file

@ -16,5 +16,3 @@ PT020.py:19:1: PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture
20 | def error_with_parens():
21 | return 0
|

View file

@ -1,103 +1,100 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT023.py:12:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
PT023.py:46:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
12 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
13 | def test_something():
14 | pass
46 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
47 | def test_something():
48 | pass
|
= help: Add/remove parentheses
Safe fix
9 9 | # Without parentheses
10 10 |
11 11 |
12 |-@pytest.mark.foo
12 |+@pytest.mark.foo()
13 13 | def test_something():
14 14 | pass
15 15 |
43 43 | # With parentheses
44 44 |
45 45 |
46 |-@pytest.mark.foo()
46 |+@pytest.mark.foo
47 47 | def test_something():
48 48 | pass
49 49 |
PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
17 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
18 | class TestClass:
19 | def test_something():
51 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
52 | class TestClass:
53 | def test_something():
|
= help: Add/remove parentheses
Safe fix
14 14 | pass
15 15 |
16 16 |
17 |-@pytest.mark.foo
17 |+@pytest.mark.foo()
18 18 | class TestClass:
19 19 | def test_something():
20 20 | pass
48 48 | pass
49 49 |
50 50 |
51 |-@pytest.mark.foo()
51 |+@pytest.mark.foo
52 52 | class TestClass:
53 53 | def test_something():
54 54 | pass
PT023.py:24:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
PT023.py:58:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
23 | class TestClass:
24 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
25 | def test_something():
26 | pass
57 | class TestClass:
58 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
59 | def test_something():
60 | pass
|
= help: Add/remove parentheses
Safe fix
21 21 |
22 22 |
23 23 | class TestClass:
24 |- @pytest.mark.foo
24 |+ @pytest.mark.foo()
25 25 | def test_something():
26 26 | pass
27 27 |
55 55 |
56 56 |
57 57 | class TestClass:
58 |- @pytest.mark.foo()
58 |+ @pytest.mark.foo
59 59 | def test_something():
60 60 | pass
61 61 |
PT023.py:30:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
PT023.py:64:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
29 | class TestClass:
30 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
31 | class TestNestedClass:
32 | def test_something():
63 | class TestClass:
64 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
65 | class TestNestedClass:
66 | def test_something():
|
= help: Add/remove parentheses
Safe fix
27 27 |
28 28 |
29 29 | class TestClass:
30 |- @pytest.mark.foo
30 |+ @pytest.mark.foo()
31 31 | class TestNestedClass:
32 32 | def test_something():
33 33 | pass
61 61 |
62 62 |
63 63 | class TestClass:
64 |- @pytest.mark.foo()
64 |+ @pytest.mark.foo
65 65 | class TestNestedClass:
66 66 | def test_something():
67 67 | pass
PT023.py:38:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
PT023.py:72:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
36 | class TestClass:
37 | class TestNestedClass:
38 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
39 | def test_something():
40 | pass
70 | class TestClass:
71 | class TestNestedClass:
72 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
73 | def test_something():
74 | pass
|
= help: Add/remove parentheses
Safe fix
35 35 |
36 36 | class TestClass:
37 37 | class TestNestedClass:
38 |- @pytest.mark.foo
38 |+ @pytest.mark.foo()
39 39 | def test_something():
40 40 | pass
41 41 |
69 69 |
70 70 | class TestClass:
71 71 | class TestNestedClass:
72 |- @pytest.mark.foo()
72 |+ @pytest.mark.foo
73 73 | def test_something():
74 74 | pass

View file

@ -1,102 +0,0 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT023.py:46:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
46 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
47 | def test_something():
48 | pass
|
= help: Add/remove parentheses
Safe fix
43 43 | # With parentheses
44 44 |
45 45 |
46 |-@pytest.mark.foo()
46 |+@pytest.mark.foo
47 47 | def test_something():
48 48 | pass
49 49 |
PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
51 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
52 | class TestClass:
53 | def test_something():
|
= help: Add/remove parentheses
Safe fix
48 48 | pass
49 49 |
50 50 |
51 |-@pytest.mark.foo()
51 |+@pytest.mark.foo
52 52 | class TestClass:
53 53 | def test_something():
54 54 | pass
PT023.py:58:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
57 | class TestClass:
58 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
59 | def test_something():
60 | pass
|
= help: Add/remove parentheses
Safe fix
55 55 |
56 56 |
57 57 | class TestClass:
58 |- @pytest.mark.foo()
58 |+ @pytest.mark.foo
59 59 | def test_something():
60 60 | pass
61 61 |
PT023.py:64:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
63 | class TestClass:
64 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
65 | class TestNestedClass:
66 | def test_something():
|
= help: Add/remove parentheses
Safe fix
61 61 |
62 62 |
63 63 | class TestClass:
64 |- @pytest.mark.foo()
64 |+ @pytest.mark.foo
65 65 | class TestNestedClass:
66 66 | def test_something():
67 67 | pass
PT023.py:72:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
70 | class TestClass:
71 | class TestNestedClass:
72 | @pytest.mark.foo()
| ^^^^^^^^^^^^^^^^^^ PT023
73 | def test_something():
74 | pass
|
= help: Add/remove parentheses
Safe fix
69 69 |
70 70 | class TestClass:
71 71 | class TestNestedClass:
72 |- @pytest.mark.foo()
72 |+ @pytest.mark.foo
73 73 | def test_something():
74 74 | pass

View file

@ -0,0 +1,101 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT023.py:12:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
12 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
13 | def test_something():
14 | pass
|
= help: Add/remove parentheses
Safe fix
9 9 | # Without parentheses
10 10 |
11 11 |
12 |-@pytest.mark.foo
12 |+@pytest.mark.foo()
13 13 | def test_something():
14 14 | pass
15 15 |
PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
17 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
18 | class TestClass:
19 | def test_something():
|
= help: Add/remove parentheses
Safe fix
14 14 | pass
15 15 |
16 16 |
17 |-@pytest.mark.foo
17 |+@pytest.mark.foo()
18 18 | class TestClass:
19 19 | def test_something():
20 20 | pass
PT023.py:24:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
23 | class TestClass:
24 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
25 | def test_something():
26 | pass
|
= help: Add/remove parentheses
Safe fix
21 21 |
22 22 |
23 23 | class TestClass:
24 |- @pytest.mark.foo
24 |+ @pytest.mark.foo()
25 25 | def test_something():
26 26 | pass
27 27 |
PT023.py:30:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
29 | class TestClass:
30 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
31 | class TestNestedClass:
32 | def test_something():
|
= help: Add/remove parentheses
Safe fix
27 27 |
28 28 |
29 29 | class TestClass:
30 |- @pytest.mark.foo
30 |+ @pytest.mark.foo()
31 31 | class TestNestedClass:
32 32 | def test_something():
33 33 | pass
PT023.py:38:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
36 | class TestClass:
37 | class TestNestedClass:
38 | @pytest.mark.foo
| ^^^^^^^^^^^^^^^^ PT023
39 | def test_something():
40 | pass
|
= help: Add/remove parentheses
Safe fix
35 35 |
36 36 | class TestClass:
37 37 | class TestNestedClass:
38 |- @pytest.mark.foo
38 |+ @pytest.mark.foo()
39 39 | def test_something():
40 40 | pass
41 41 |

View file

@ -23,7 +23,7 @@ use ruff_linter::line_width::{IndentWidth, LineLength};
use ruff_linter::registry::RuleNamespace;
use ruff_linter::registry::{Rule, RuleSet, INCOMPATIBLE_CODES};
use ruff_linter::rule_selector::{PreviewOptions, Specificity};
use ruff_linter::rules::{flake8_pytest_style, pycodestyle};
use ruff_linter::rules::pycodestyle;
use ruff_linter::settings::fix_safety_table::FixSafetyTable;
use ruff_linter::settings::rule_table::RuleTable;
use ruff_linter::settings::types::{
@ -337,9 +337,7 @@ impl Configuration {
Flake8PytestStyleOptions::try_into_settings(options, lint_preview)
})
.transpose()?
.unwrap_or_else(|| {
flake8_pytest_style::settings::Settings::resolve_default(lint_preview)
}),
.unwrap_or_default(),
flake8_quotes: lint
.flake8_quotes
.map(Flake8QuotesOptions::into_settings)

View file

@ -1390,11 +1390,8 @@ pub struct Flake8PytestStyleOptions {
/// default), `@pytest.fixture()` is valid and `@pytest.fixture` is
/// invalid. If set to `false`, `@pytest.fixture` is valid and
/// `@pytest.fixture()` is invalid.
///
/// If [preview](https://docs.astral.sh/ruff/preview/) is enabled, defaults to
/// `false`.
#[option(
default = "true",
default = "false",
value_type = "bool",
example = "fixture-parentheses = true"
)]
@ -1476,11 +1473,8 @@ pub struct Flake8PytestStyleOptions {
/// default), `@pytest.mark.foo()` is valid and `@pytest.mark.foo` is
/// invalid. If set to `false`, `@pytest.mark.foo` is valid and
/// `@pytest.mark.foo()` is invalid.
///
/// If [preview](https://docs.astral.sh/ruff/preview/) is enabled, defaults to
/// `false`.
#[option(
default = "true",
default = "false",
value_type = "bool",
example = "mark-parentheses = true"
)]

4
ruff.schema.json generated
View file

@ -1103,14 +1103,14 @@
"type": "object",
"properties": {
"fixture-parentheses": {
"description": "Boolean flag specifying whether `@pytest.fixture()` without parameters should have parentheses. If the option is set to `true` (the default), `@pytest.fixture()` is valid and `@pytest.fixture` is invalid. If set to `false`, `@pytest.fixture` is valid and `@pytest.fixture()` is invalid.\n\nIf [preview](https://docs.astral.sh/ruff/preview/) is enabled, defaults to `false`.",
"description": "Boolean flag specifying whether `@pytest.fixture()` without parameters should have parentheses. If the option is set to `true` (the default), `@pytest.fixture()` is valid and `@pytest.fixture` is invalid. If set to `false`, `@pytest.fixture` is valid and `@pytest.fixture()` is invalid.",
"type": [
"boolean",
"null"
]
},
"mark-parentheses": {
"description": "Boolean flag specifying whether `@pytest.mark.foo()` without parameters should have parentheses. If the option is set to `true` (the default), `@pytest.mark.foo()` is valid and `@pytest.mark.foo` is invalid. If set to `false`, `@pytest.mark.foo` is valid and `@pytest.mark.foo()` is invalid.\n\nIf [preview](https://docs.astral.sh/ruff/preview/) is enabled, defaults to `false`.",
"description": "Boolean flag specifying whether `@pytest.mark.foo()` without parameters should have parentheses. If the option is set to `true` (the default), `@pytest.mark.foo()` is valid and `@pytest.mark.foo` is invalid. If set to `false`, `@pytest.mark.foo` is valid and `@pytest.mark.foo()` is invalid.",
"type": [
"boolean",
"null"