Move empty_parenthesized into the parentheses.rs (#6403)

## Summary

This PR moves `empty_parenthesized` such that it's peer to
`parenthesized`, and changes the API to better match that of
`parenthesized` (takes `&str` rather than `StaticText`, has a
`with_dangling_comments` method, etc.).

It may be intentionally _not_ part of `parentheses.rs`, but to me
they're so similar that it makes more sense for them to be in the same
module, with the same API, etc.
This commit is contained in:
Charlie Marsh 2023-08-08 15:17:17 -04:00 committed by GitHub
parent fe9590f39f
commit c7703e205d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 83 additions and 96 deletions

View file

@ -6,12 +6,11 @@ use ruff_python_ast::{Parameters, Ranged};
use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer};
use ruff_text_size::{TextRange, TextSize};
use crate::builders::empty_parenthesized_with_dangling_comments;
use crate::comments::{
leading_comments, leading_node_comments, trailing_comments, CommentLinePosition, SourceComment,
};
use crate::context::{NodeLevel, WithNodeLevel};
use crate::expression::parentheses::parenthesized;
use crate::expression::parentheses::{empty_parenthesized, parenthesized};
use crate::prelude::*;
use crate::FormatNodeRule;
@ -245,14 +244,7 @@ impl FormatNodeRule<Parameters> for FormatParameters {
write!(f, [group(&format_inner)])
} else if num_parameters == 0 {
// No parameters, format any dangling comments between `()`
write!(
f,
[empty_parenthesized_with_dangling_comments(
text("("),
dangling,
text(")"),
)]
)
write!(f, [empty_parenthesized("(", dangling, ")")])
} else {
write!(
f,