Create dedicated is_*_enabled functions for each preview style (#8988)

This commit is contained in:
Micha Reiser 2023-12-04 14:38:54 +09:00 committed by GitHub
parent 7e390d3772
commit 0bda1913d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 11 deletions

View file

@ -3,7 +3,7 @@ use std::ops::{Deref, Index};
use smallvec::SmallVec;
use ruff_formatter::{write, FormatContext};
use ruff_formatter::write;
use ruff_python_ast::{
Expr, ExprAttribute, ExprBinOp, ExprBoolOp, ExprCompare, ExprUnaryOp, UnaryOp,
};
@ -21,6 +21,7 @@ use crate::expression::parentheses::{
use crate::expression::string::{AnyString, FormatString, StringLayout};
use crate::expression::OperatorPrecedence;
use crate::prelude::*;
use crate::preview::is_fix_power_op_line_length_enabled;
#[derive(Copy, Clone, Debug)]
pub(super) enum BinaryLike<'a> {
@ -719,7 +720,7 @@ impl Format<PyFormatContext<'_>> for FlatBinaryExpressionSlice<'_> {
{
hard_line_break().fmt(f)?;
} else if is_pow {
if f.context().options().preview().is_enabled() {
if is_fix_power_op_line_length_enabled(f.context()) {
in_parentheses_only_if_group_breaks(&space()).fmt(f)?;
}
} else {