mirror of https://github.com/astral-sh/ruff
Check for keyword arguments before the last star argument (#1420)
This commit is contained in:
parent
1822b57ed5
commit
a8cde5a936
|
|
@ -5,9 +5,11 @@ def f(*args, **kwargs):
|
|||
a = (1, 2)
|
||||
b = (3, 4)
|
||||
c = (5, 6)
|
||||
d = (7, 8)
|
||||
|
||||
f(a, b)
|
||||
f(a, kw=b)
|
||||
f(*a, kw=b)
|
||||
f(kw=a, *b)
|
||||
f(kw=a, *b, *c)
|
||||
f(*a, kw=b, *c, kw1=d)
|
||||
|
|
|
|||
|
|
@ -1686,7 +1686,7 @@ pub fn keyword_argument_before_star_argument(args: &[Expr], keywords: &[Keyword]
|
|||
let mut checks = vec![];
|
||||
if let Some(arg) = args
|
||||
.iter()
|
||||
.find(|arg| matches!(arg.node, ExprKind::Starred { .. }))
|
||||
.rfind(|arg| matches!(arg.node, ExprKind::Starred { .. }))
|
||||
{
|
||||
for keyword in keywords {
|
||||
if keyword.location < arg.location {
|
||||
|
|
|
|||
|
|
@ -5,19 +5,28 @@ expression: checks
|
|||
- kind:
|
||||
KeywordArgumentBeforeStarArgument: kw
|
||||
location:
|
||||
row: 12
|
||||
row: 13
|
||||
column: 2
|
||||
end_location:
|
||||
row: 12
|
||||
row: 13
|
||||
column: 6
|
||||
fix: ~
|
||||
- kind:
|
||||
KeywordArgumentBeforeStarArgument: kw
|
||||
location:
|
||||
row: 13
|
||||
row: 14
|
||||
column: 2
|
||||
end_location:
|
||||
row: 13
|
||||
row: 14
|
||||
column: 6
|
||||
fix: ~
|
||||
- kind:
|
||||
KeywordArgumentBeforeStarArgument: kw
|
||||
location:
|
||||
row: 15
|
||||
column: 6
|
||||
end_location:
|
||||
row: 15
|
||||
column: 10
|
||||
fix: ~
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue