mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:26:23 +00:00
Fix incorrect Parameter
range for *args
and **kwargs
(#10283)
## Summary Fix #10282 This PR updates the Python grammar to include the `*` character in `*args` `**kwargs` in the range of the `Parameter` ``` def f(*args, **kwargs): pass # ~~~~ ~~~~~~ <-- range before the PR # ^^^^^ ^^^^^^^^ <-- range after ``` The invalid syntax `def f(*, **kwargs): ...` is also now correctly reported. ## Test Plan Test cases were added to `function.rs`.
This commit is contained in:
parent
b64f2ea401
commit
a067d87ccc
23 changed files with 28521 additions and 28529 deletions
|
@ -202,6 +202,14 @@ fn handle_enclosed_comment<'a>(
|
|||
}
|
||||
})
|
||||
}
|
||||
AnyNodeRef::Parameter(parameter) => {
|
||||
// E.g. a comment between the `*` or `**` and the parameter name.
|
||||
if comment.preceding_node().is_none() || comment.following_node().is_none() {
|
||||
CommentPlacement::leading(parameter, comment)
|
||||
} else {
|
||||
CommentPlacement::Default(comment)
|
||||
}
|
||||
}
|
||||
AnyNodeRef::Arguments(_) | AnyNodeRef::TypeParams(_) | AnyNodeRef::PatternArguments(_) => {
|
||||
handle_bracketed_end_of_line_comment(comment, locator)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue