Skip to content

Commit

Permalink
[flake8-pytest-style] Fix single-tuple conversion in `pytest-parame…
Browse files Browse the repository at this point in the history
…trize-values-wrong-type` (astral-sh#10862)

## Summary

This looks like a typo (without test coverage).

Closes astral-sh#10861.
  • Loading branch information
charliermarsh authored and Glyphack committed Apr 12, 2024
1 parent c01737d commit c890e15
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 30 deletions.
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

0 comments on commit c890e15

Please sign in to comment.