Improve clarity of PT006's error message (#10468)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Auguste Lalande 2024-03-20 14:22:02 -04:00 committed by GitHub
parent 954a48b129
commit fd3d272026
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 99 additions and 67 deletions

View file

@ -73,6 +73,7 @@ use super::helpers::{is_pytest_parametrize, split_names};
/// - [`pytest` documentation: How to parametrize fixtures and test functions](https://docs.pytest.org/en/latest/how-to/parametrize.html#pytest-mark-parametrize)
#[violation]
pub struct PytestParametrizeNamesWrongType {
single_argument: bool,
expected: types::ParametrizeNameType,
}
@ -81,13 +82,43 @@ impl Violation for PytestParametrizeNamesWrongType {
#[derive_message_formats]
fn message(&self) -> String {
let PytestParametrizeNamesWrongType { expected } = self;
format!("Wrong name(s) type in `@pytest.mark.parametrize`, expected `{expected}`")
let PytestParametrizeNamesWrongType {
single_argument,
expected,
} = self;
let expected_string = {
if *single_argument {
"`str`".to_string()
} else {
match expected {
types::ParametrizeNameType::Csv => format!("a {expected}"),
types::ParametrizeNameType::Tuple | types::ParametrizeNameType::List => {
format!("`{expected}`")
}
}
}
};
format!("Wrong type passed to first argument of `@pytest.mark.parametrize`; expected {expected_string}")
}
fn fix_title(&self) -> Option<String> {
let PytestParametrizeNamesWrongType { expected } = self;
Some(format!("Use a `{expected}` for parameter names"))
let PytestParametrizeNamesWrongType {
single_argument,
expected,
} = self;
let expected_string = {
if *single_argument {
"string".to_string()
} else {
match expected {
types::ParametrizeNameType::Csv => format!("{expected}"),
types::ParametrizeNameType::Tuple | types::ParametrizeNameType::List => {
format!("`{expected}`")
}
}
}
};
Some(format!("Use a {expected_string} for the first argument"))
}
}
@ -328,6 +359,7 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) {
.unwrap_or(expr.range());
let mut diagnostic = Diagnostic::new(
PytestParametrizeNamesWrongType {
single_argument: false,
expected: names_type,
},
name_range,
@ -362,6 +394,7 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) {
.unwrap_or(expr.range());
let mut diagnostic = Diagnostic::new(
PytestParametrizeNamesWrongType {
single_argument: false,
expected: names_type,
},
name_range,
@ -400,6 +433,7 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) {
types::ParametrizeNameType::List => {
let mut diagnostic = Diagnostic::new(
PytestParametrizeNamesWrongType {
single_argument: false,
expected: names_type,
},
expr.range(),
@ -418,6 +452,7 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) {
types::ParametrizeNameType::Csv => {
let mut diagnostic = Diagnostic::new(
PytestParametrizeNamesWrongType {
single_argument: false,
expected: names_type,
},
expr.range(),
@ -444,6 +479,7 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) {
types::ParametrizeNameType::Tuple => {
let mut diagnostic = Diagnostic::new(
PytestParametrizeNamesWrongType {
single_argument: false,
expected: names_type,
},
expr.range(),
@ -463,6 +499,7 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) {
types::ParametrizeNameType::Csv => {
let mut diagnostic = Diagnostic::new(
PytestParametrizeNamesWrongType {
single_argument: false,
expected: names_type,
},
expr.range(),
@ -657,6 +694,7 @@ fn check_duplicates(checker: &mut Checker, values: &Expr) {
fn handle_single_name(checker: &mut Checker, expr: &Expr, value: &Expr) {
let mut diagnostic = Diagnostic::new(
PytestParametrizeNamesWrongType {
single_argument: true,
expected: types::ParametrizeNameType::Csv,
},
expr.range(),

View file

@ -1,14 +1,14 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected a string of comma-separated values
|
24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^^^^ PT006
25 | def test_tuple(param1, param2):
26 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string of comma-separated values for the first argument
Unsafe fix
21 21 | ...
@ -20,14 +20,14 @@ PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
26 26 | ...
27 27 |
PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str`
|
29 | @pytest.mark.parametrize(("param1",), [1, 2, 3])
| ^^^^^^^^^^^ PT006
30 | def test_tuple_one_elem(param1, param2):
31 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string for the first argument
Safe fix
26 26 | ...
@ -39,14 +39,14 @@ PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
31 31 | ...
32 32 |
PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected a string of comma-separated values
|
34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^^^^ PT006
35 | def test_list(param1, param2):
36 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string of comma-separated values for the first argument
Unsafe fix
31 31 | ...
@ -58,14 +58,14 @@ PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
36 36 | ...
37 37 |
PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str`
|
39 | @pytest.mark.parametrize(["param1"], [1, 2, 3])
| ^^^^^^^^^^ PT006
40 | def test_list_one_elem(param1, param2):
41 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string for the first argument
Safe fix
36 36 | ...
@ -77,22 +77,20 @@ PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
41 41 | ...
42 42 |
PT006.py:44:26: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:44:26: PT006 Wrong type passed to first argument of `@pytest.mark.parametrize`; expected a string of comma-separated values
|
44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3])
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
45 | def test_list_expressions(param1, param2):
46 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string of comma-separated values for the first argument
PT006.py:49:26: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:49:26: PT006 Wrong type passed to first argument of `@pytest.mark.parametrize`; expected a string of comma-separated values
|
49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3])
| ^^^^^^^^^^^^^^^^^^^^^ PT006
50 | def test_list_mixed_expr_literal(param1, param2):
51 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string of comma-separated values for the first argument

View file

@ -1,14 +1,14 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^ PT006
10 | def test_csv(param1, param2):
11 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
6 6 | ...
@ -20,14 +20,14 @@ PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expec
11 11 | ...
12 12 |
PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
15 | def test_csv_with_whitespace(param1, param2):
16 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
11 11 | ...
@ -39,14 +39,14 @@ PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
16 16 | ...
17 17 |
PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^ PT006
20 | def test_csv_bad_quotes(param1, param2):
21 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
16 16 | ...
@ -58,14 +58,14 @@ PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
21 21 | ...
22 22 |
PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str`
|
29 | @pytest.mark.parametrize(("param1",), [1, 2, 3])
| ^^^^^^^^^^^ PT006
30 | def test_tuple_one_elem(param1, param2):
31 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string for the first argument
Safe fix
26 26 | ...
@ -77,14 +77,14 @@ PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
31 31 | ...
32 32 |
PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^^^^ PT006
35 | def test_list(param1, param2):
36 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
31 31 | ...
@ -96,14 +96,14 @@ PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
36 36 | ...
37 37 |
PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str`
|
39 | @pytest.mark.parametrize(["param1"], [1, 2, 3])
| ^^^^^^^^^^ PT006
40 | def test_list_one_elem(param1, param2):
41 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string for the first argument
Safe fix
36 36 | ...
@ -115,14 +115,14 @@ PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
41 41 | ...
42 42 |
PT006.py:44:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:44:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3])
| ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
45 | def test_list_expressions(param1, param2):
46 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
41 41 | ...
@ -134,14 +134,14 @@ PT006.py:44:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
46 46 | ...
47 47 |
PT006.py:49:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:49:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3])
| ^^^^^^^^^^^^^^^^^^^^^ PT006
50 | def test_list_mixed_expr_literal(param1, param2):
51 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
46 46 | ...
@ -153,14 +153,14 @@ PT006.py:49:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
51 51 | ...
52 52 |
PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
55 | def test_implicit_str_concat_with_parens(param1, param2, param3):
56 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
51 51 | ...
@ -172,14 +172,14 @@ PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
56 56 | ...
57 57 |
PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
60 | def test_implicit_str_concat_no_parens(param1, param2, param3):
61 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
56 56 | ...
@ -191,14 +191,14 @@ PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
61 61 | ...
62 62 |
PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3):
66 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
61 61 | ...
@ -210,14 +210,14 @@ PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
66 66 | ...
67 67 |
PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
|
69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^ PT006
70 | def test_csv_with_parens(param1, param2):
71 | ...
|
= help: Use a `tuple` for parameter names
= help: Use a `tuple` for the first argument
Unsafe fix
66 66 | ...
@ -227,5 +227,3 @@ PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
69 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)])
70 70 | def test_csv_with_parens(param1, param2):
71 71 | ...

View file

@ -1,14 +1,14 @@
---
source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs
---
PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^ PT006
10 | def test_csv(param1, param2):
11 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
6 6 | ...
@ -20,14 +20,14 @@ PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expec
11 11 | ...
12 12 |
PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
15 | def test_csv_with_whitespace(param1, param2):
16 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
11 11 | ...
@ -39,14 +39,14 @@ PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
16 16 | ...
17 17 |
PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^ PT006
20 | def test_csv_bad_quotes(param1, param2):
21 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
16 16 | ...
@ -58,14 +58,14 @@ PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
21 21 | ...
22 22 |
PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^^^^ PT006
25 | def test_tuple(param1, param2):
26 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
21 21 | ...
@ -77,14 +77,14 @@ PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
26 26 | ...
27 27 |
PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str`
|
29 | @pytest.mark.parametrize(("param1",), [1, 2, 3])
| ^^^^^^^^^^^ PT006
30 | def test_tuple_one_elem(param1, param2):
31 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string for the first argument
Safe fix
26 26 | ...
@ -96,14 +96,14 @@ PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
31 31 | ...
32 32 |
PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `str`
|
39 | @pytest.mark.parametrize(["param1"], [1, 2, 3])
| ^^^^^^^^^^ PT006
40 | def test_list_one_elem(param1, param2):
41 | ...
|
= help: Use a `csv` for parameter names
= help: Use a string for the first argument
Safe fix
36 36 | ...
@ -115,14 +115,14 @@ PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
41 41 | ...
42 42 |
PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
55 | def test_implicit_str_concat_with_parens(param1, param2, param3):
56 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
51 51 | ...
@ -134,14 +134,14 @@ PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
56 56 | ...
57 57 |
PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
60 | def test_implicit_str_concat_no_parens(param1, param2, param3):
61 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
56 56 | ...
@ -153,14 +153,14 @@ PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
61 61 | ...
62 62 |
PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006
65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3):
66 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
61 61 | ...
@ -172,14 +172,14 @@ PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
66 66 | ...
67 67 |
PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list`
PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `list`
|
69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)])
| ^^^^^^^^^^^^^^^^^ PT006
70 | def test_csv_with_parens(param1, param2):
71 | ...
|
= help: Use a `list` for parameter names
= help: Use a `list` for the first argument
Unsafe fix
66 66 | ...
@ -189,5 +189,3 @@ PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
69 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)])
70 70 | def test_csv_with_parens(param1, param2):
71 71 | ...

View file

@ -24,7 +24,7 @@ impl Default for ParametrizeNameType {
impl Display for ParametrizeNameType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Csv => write!(f, "csv"),
Self::Csv => write!(f, "string of comma-separated values"),
Self::Tuple => write!(f, "tuple"),
Self::List => write!(f, "list"),
}