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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user