mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-21 11:00:49 +00:00
Fix ArgWithDefault comments handling (#5204)
This commit is contained in:
parent
fde5dbc9aa
commit
e520a3a721
17 changed files with 73 additions and 69 deletions
|
@ -627,17 +627,7 @@ fn handle_positional_only_arguments_separator_comment<'a>(
|
|||
};
|
||||
|
||||
let is_last_positional_argument =
|
||||
// If the preceding node is the identifier for the last positional argument (`a`).
|
||||
// ```python
|
||||
// def test(a, /, b): pass
|
||||
// ```
|
||||
are_same_optional(last_argument_or_default, arguments.posonlyargs.last().map(|arg| &arg.def))
|
||||
// If the preceding node is the default for the last positional argument (`10`).
|
||||
// ```python
|
||||
// def test(a=10, /, b): pass
|
||||
// ```
|
||||
|| are_same_optional(last_argument_or_default, arguments
|
||||
.posonlyargs.last().and_then(|arg| arg.default.as_deref()));
|
||||
are_same_optional(last_argument_or_default, arguments.posonlyargs.last());
|
||||
|
||||
if !is_last_positional_argument {
|
||||
return CommentPlacement::Default(comment);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue