mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 13:05:06 +00:00
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:
parent
fe9590f39f
commit
c7703e205d
7 changed files with 83 additions and 96 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue