mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-19 08:40:39 +00:00
Format target: annotation = value?
expressions (#5661)
This commit is contained in:
parent
0c8ec80d7b
commit
f1d367655b
28 changed files with 318 additions and 988 deletions
|
@ -6,20 +6,20 @@ use ruff_text_size::TextSize;
|
|||
use rustpython_parser::ast::Ranged;
|
||||
|
||||
/// Adds parentheses and indents `content` if it doesn't fit on a line.
|
||||
pub(crate) fn optional_parentheses<'ast, T>(content: &T) -> OptionalParentheses<'_, 'ast>
|
||||
pub(crate) fn parenthesize_if_expands<'ast, T>(content: &T) -> ParenthesizeIfExpands<'_, 'ast>
|
||||
where
|
||||
T: Format<PyFormatContext<'ast>>,
|
||||
{
|
||||
OptionalParentheses {
|
||||
ParenthesizeIfExpands {
|
||||
inner: Argument::new(content),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct OptionalParentheses<'a, 'ast> {
|
||||
pub(crate) struct ParenthesizeIfExpands<'a, 'ast> {
|
||||
inner: Argument<'a, PyFormatContext<'ast>>,
|
||||
}
|
||||
|
||||
impl<'ast> Format<PyFormatContext<'ast>> for OptionalParentheses<'_, 'ast> {
|
||||
impl<'ast> Format<PyFormatContext<'ast>> for ParenthesizeIfExpands<'_, 'ast> {
|
||||
fn fmt(&self, f: &mut Formatter<PyFormatContext<'ast>>) -> FormatResult<()> {
|
||||
let saved_level = f.context().node_level();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue