Fix ArgWithDefault comments handling (#5204)

This commit is contained in:
Micha Reiser 2023-06-20 22:48:07 +02:00 committed by GitHub
parent fde5dbc9aa
commit e520a3a721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 73 additions and 69 deletions

View file

@ -34,14 +34,9 @@ impl FormatNodeRule<Arguments> for FormatArguments {
let mut last_node: Option<AnyNodeRef> = None;
for arg_with_default in posonlyargs {
joiner.entry(&arg_with_default.into_format());
joiner.entry(&arg_with_default.format());
last_node = Some(
arg_with_default
.default
.as_deref()
.map_or_else(|| (&arg_with_default.def).into(), AnyNodeRef::from),
);
last_node = Some(arg_with_default.into());
}
if !posonlyargs.is_empty() {
@ -49,14 +44,9 @@ impl FormatNodeRule<Arguments> for FormatArguments {
}
for arg_with_default in args {
joiner.entry(&arg_with_default.into_format());
joiner.entry(&arg_with_default.format());
last_node = Some(
arg_with_default
.default
.as_deref()
.map_or_else(|| (&arg_with_default.def).into(), AnyNodeRef::from),
);
last_node = Some(arg_with_default.into());
}
// kw only args need either a `*args` ahead of them capturing all var args or a `*`
@ -74,14 +64,9 @@ impl FormatNodeRule<Arguments> for FormatArguments {
}
for arg_with_default in kwonlyargs {
joiner.entry(&arg_with_default.into_format());
joiner.entry(&arg_with_default.format());
last_node = Some(
arg_with_default
.default
.as_deref()
.map_or_else(|| (&arg_with_default.def).into(), AnyNodeRef::from),
);
last_node = Some(arg_with_default.into());
}
if let Some(kwarg) = kwarg {