Skip to content
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

[flake8-pytest-style] Fix single-tuple conversion in pytest-parametrize-values-wrong-type #10862

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,13 @@ def test_single_list_of_lists(param):
@pytest.mark.parametrize("a", [1, 2])
@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
@pytest.mark.parametrize("d", [3,])
def test_multiple_decorators(a, b, c):
@pytest.mark.parametrize(
"d",
[("3", "4")],
)
@pytest.mark.parametrize(
"e",
[("3", "4"),],
)
def test_multiple_decorators(a, b, c, d, e):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ fn check_values(checker: &mut Checker, names: &Expr, values: &Expr) {
// Replace `]` with `)` or `,)`.
let values_end = Edit::replacement(
if needs_trailing_comma {
"),".into()
",)".into()
} else {
")".into()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
| ^^^^^^^^^^^^^^^^ PT007
82 | @pytest.mark.parametrize("d", [3,])
83 | def test_multiple_decorators(a, b, c):
83 | @pytest.mark.parametrize(
|
= help: Use `list` of `list` for parameter values

Expand All @@ -179,16 +179,16 @@ PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
81 |+@pytest.mark.parametrize(("b", "c"), [(3, 4), (5, 6)])
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",

PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`
|
80 | @pytest.mark.parametrize("a", [1, 2])
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
| ^^^^^^ PT007
82 | @pytest.mark.parametrize("d", [3,])
83 | def test_multiple_decorators(a, b, c):
83 | @pytest.mark.parametrize(
|
= help: Use `list` of `list` for parameter values

Expand All @@ -199,16 +199,16 @@ PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
81 |+@pytest.mark.parametrize(("b", "c"), ([3, 4], (5, 6)))
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",

PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `list` of `list`
|
80 | @pytest.mark.parametrize("a", [1, 2])
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
| ^^^^^^ PT007
82 | @pytest.mark.parametrize("d", [3,])
83 | def test_multiple_decorators(a, b, c):
83 | @pytest.mark.parametrize(
|
= help: Use `list` of `list` for parameter values

Expand All @@ -219,5 +219,5 @@ PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
81 |+@pytest.mark.parametrize(("b", "c"), ((3, 4), [5, 6]))
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
| ^^^^^^^^^^^^^^^^ PT007
82 | @pytest.mark.parametrize("d", [3,])
83 | def test_multiple_decorators(a, b, c):
83 | @pytest.mark.parametrize(
|
= help: Use `list` of `tuple` for parameter values

Expand All @@ -221,5 +221,5 @@ PT007.py:81:38: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
81 |+@pytest.mark.parametrize(("b", "c"), [(3, 4), (5, 6)])
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,15 @@ PT007.py:80:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
80 |+@pytest.mark.parametrize("a", (1, 2))
81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
83 83 | @pytest.mark.parametrize(

PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`
|
80 | @pytest.mark.parametrize("a", [1, 2])
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
| ^^^^^^ PT007
82 | @pytest.mark.parametrize("d", [3,])
83 | def test_multiple_decorators(a, b, c):
83 | @pytest.mark.parametrize(
|
= help: Use `tuple` of `list` for parameter values

Expand All @@ -256,16 +256,16 @@ PT007.py:81:39: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
81 |+@pytest.mark.parametrize(("b", "c"), ([3, 4], (5, 6)))
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",

PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`
|
80 | @pytest.mark.parametrize("a", [1, 2])
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
| ^^^^^^ PT007
82 | @pytest.mark.parametrize("d", [3,])
83 | def test_multiple_decorators(a, b, c):
83 | @pytest.mark.parametrize(
|
= help: Use `tuple` of `list` for parameter values

Expand All @@ -276,17 +276,17 @@ PT007.py:81:47: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 |-@pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
81 |+@pytest.mark.parametrize(("b", "c"), ((3, 4), [5, 6]))
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",

PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`
|
80 | @pytest.mark.parametrize("a", [1, 2])
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
82 | @pytest.mark.parametrize("d", [3,])
| ^^^^ PT007
83 | def test_multiple_decorators(a, b, c):
84 | pass
83 | @pytest.mark.parametrize(
84 | "d",
|
= help: Use `tuple` of `list` for parameter values

Expand All @@ -296,5 +296,48 @@ PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
82 |-@pytest.mark.parametrize("d", [3,])
82 |+@pytest.mark.parametrize("d", (3,))
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",
85 85 | [("3", "4")],

PT007.py:85:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`
|
83 | @pytest.mark.parametrize(
84 | "d",
85 | [("3", "4")],
| ^^^^^^^^^^^^ PT007
86 | )
87 | @pytest.mark.parametrize(
|
= help: Use `tuple` of `list` for parameter values

ℹ Unsafe fix
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | @pytest.mark.parametrize(
84 84 | "d",
85 |- [("3", "4")],
85 |+ (("3", "4"),),
86 86 | )
87 87 | @pytest.mark.parametrize(
88 88 | "e",

PT007.py:89:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list`
|
87 | @pytest.mark.parametrize(
88 | "e",
89 | [("3", "4"),],
| ^^^^^^^^^^^^^ PT007
90 | )
91 | def test_multiple_decorators(a, b, c, d, e):
|
= help: Use `tuple` of `list` for parameter values

ℹ Unsafe fix
86 86 | )
87 87 | @pytest.mark.parametrize(
88 88 | "e",
89 |- [("3", "4"),],
89 |+ (("3", "4"),),
90 90 | )
91 91 | def test_multiple_decorators(a, b, c, d, e):
92 92 | pass
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,16 @@ PT007.py:80:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
80 |+@pytest.mark.parametrize("a", (1, 2))
81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | def test_multiple_decorators(a, b, c):
83 83 | @pytest.mark.parametrize(

PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`
|
80 | @pytest.mark.parametrize("a", [1, 2])
81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
82 | @pytest.mark.parametrize("d", [3,])
| ^^^^ PT007
83 | def test_multiple_decorators(a, b, c):
84 | pass
83 | @pytest.mark.parametrize(
84 | "d",
|
= help: Use `tuple` of `tuple` for parameter values

Expand All @@ -298,5 +298,48 @@ PT007.py:82:31: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expect
81 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6)))
82 |-@pytest.mark.parametrize("d", [3,])
82 |+@pytest.mark.parametrize("d", (3,))
83 83 | def test_multiple_decorators(a, b, c):
84 84 | pass
83 83 | @pytest.mark.parametrize(
84 84 | "d",
85 85 | [("3", "4")],

PT007.py:85:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`
|
83 | @pytest.mark.parametrize(
84 | "d",
85 | [("3", "4")],
| ^^^^^^^^^^^^ PT007
86 | )
87 | @pytest.mark.parametrize(
|
= help: Use `tuple` of `tuple` for parameter values

ℹ Unsafe fix
82 82 | @pytest.mark.parametrize("d", [3,])
83 83 | @pytest.mark.parametrize(
84 84 | "d",
85 |- [("3", "4")],
85 |+ (("3", "4"),),
86 86 | )
87 87 | @pytest.mark.parametrize(
88 88 | "e",

PT007.py:89:5: PT007 [*] Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple`
|
87 | @pytest.mark.parametrize(
88 | "e",
89 | [("3", "4"),],
| ^^^^^^^^^^^^^ PT007
90 | )
91 | def test_multiple_decorators(a, b, c, d, e):
|
= help: Use `tuple` of `tuple` for parameter values

ℹ Unsafe fix
86 86 | )
87 87 | @pytest.mark.parametrize(
88 88 | "e",
89 |- [("3", "4"),],
89 |+ (("3", "4"),),
90 90 | )
91 91 | def test_multiple_decorators(a, b, c, d, e):
92 92 | pass