@@ -21,7 +21,7 @@ use crate::expression::parentheses::{
21
21
OptionalParentheses , Parentheses , Parenthesize ,
22
22
} ;
23
23
use crate :: prelude:: * ;
24
- use crate :: PyFormatOptions ;
24
+ use crate :: preview :: is_hug_parens_with_braces_and_square_brackets_enabled ;
25
25
26
26
mod binary_like;
27
27
pub ( crate ) mod expr_attribute;
@@ -129,7 +129,7 @@ impl FormatRule<Expr, PyFormatContext<'_>> for FormatExpr {
129
129
let node_comments = comments. leading_dangling_trailing ( expression) ;
130
130
if !node_comments. has_leading ( ) && !node_comments. has_trailing ( ) {
131
131
parenthesized ( "(" , & format_expr, ")" )
132
- . with_indent ( !is_expression_huggable ( expression, f. options ( ) ) )
132
+ . with_indent ( !is_expression_huggable ( expression, f. context ( ) ) )
133
133
. fmt ( f)
134
134
} else {
135
135
format_with_parentheses_comments ( expression, & node_comments, f)
@@ -448,7 +448,7 @@ impl Format<PyFormatContext<'_>> for MaybeParenthesizeExpression<'_> {
448
448
OptionalParentheses :: Never => match parenthesize {
449
449
Parenthesize :: IfBreaksOrIfRequired => {
450
450
parenthesize_if_expands ( & expression. format ( ) . with_options ( Parentheses :: Never ) )
451
- . with_indent ( !is_expression_huggable ( expression, f. options ( ) ) )
451
+ . with_indent ( !is_expression_huggable ( expression, f. context ( ) ) )
452
452
. fmt ( f)
453
453
}
454
454
@@ -1061,8 +1061,8 @@ pub(crate) fn has_own_parentheses(
1061
1061
/// ]
1062
1062
/// )
1063
1063
/// ```
1064
- pub ( crate ) fn is_expression_huggable ( expr : & Expr , options : & PyFormatOptions ) -> bool {
1065
- if !options . preview ( ) . is_enabled ( ) {
1064
+ pub ( crate ) fn is_expression_huggable ( expr : & Expr , context : & PyFormatContext ) -> bool {
1065
+ if !is_hug_parens_with_braces_and_square_brackets_enabled ( context ) {
1066
1066
return false ;
1067
1067
}
1068
1068
0 commit comments