@@ -115,10 +115,8 @@ def line(self, indent: int = 0) -> Iterator[Line]:
115
115
self .current_line .depth += indent
116
116
return # Line is empty, don't emit. Creating a new one unnecessary.
117
117
118
- if (
119
- Preview .improved_async_statements_handling in self .mode
120
- and len (self .current_line .leaves ) == 1
121
- and is_async_stmt_or_funcdef (self .current_line .leaves [0 ])
118
+ if len (self .current_line .leaves ) == 1 and is_async_stmt_or_funcdef (
119
+ self .current_line .leaves [0 ]
122
120
):
123
121
# Special case for async def/for/with statements. `visit_async_stmt`
124
122
# adds an `ASYNC` leaf then visits the child def/for/with statement
@@ -164,20 +162,19 @@ def visit_default(self, node: LN) -> Iterator[Line]:
164
162
def visit_test (self , node : Node ) -> Iterator [Line ]:
165
163
"""Visit an `x if y else z` test"""
166
164
167
- if Preview .parenthesize_conditional_expressions in self .mode :
168
- already_parenthesized = (
169
- node .prev_sibling and node .prev_sibling .type == token .LPAR
170
- )
165
+ already_parenthesized = (
166
+ node .prev_sibling and node .prev_sibling .type == token .LPAR
167
+ )
171
168
172
- if not already_parenthesized :
173
- # Similar to logic in wrap_in_parentheses
174
- lpar = Leaf (token .LPAR , "" )
175
- rpar = Leaf (token .RPAR , "" )
176
- prefix = node .prefix
177
- node .prefix = ""
178
- lpar .prefix = prefix
179
- node .insert_child (0 , lpar )
180
- node .append_child (rpar )
169
+ if not already_parenthesized :
170
+ # Similar to logic in wrap_in_parentheses
171
+ lpar = Leaf (token .LPAR , "" )
172
+ rpar = Leaf (token .RPAR , "" )
173
+ prefix = node .prefix
174
+ node .prefix = ""
175
+ lpar .prefix = prefix
176
+ node .insert_child (0 , lpar )
177
+ node .append_child (rpar )
181
178
182
179
yield from self .visit_default (node )
183
180
@@ -292,9 +289,7 @@ def visit_match_case(self, node: Node) -> Iterator[Line]:
292
289
293
290
def visit_suite (self , node : Node ) -> Iterator [Line ]:
294
291
"""Visit a suite."""
295
- if (
296
- self .mode .is_pyi or Preview .dummy_implementations in self .mode
297
- ) and is_stub_suite (node , self .mode ):
292
+ if is_stub_suite (node ):
298
293
yield from self .visit (node .children [2 ])
299
294
else :
300
295
yield from self .visit_default (node )
@@ -308,23 +303,15 @@ def visit_simple_stmt(self, node: Node) -> Iterator[Line]:
308
303
prev_type = child .type
309
304
310
305
if node .parent and node .parent .type in STATEMENT :
311
- if Preview .dummy_implementations in self .mode :
312
- condition = is_parent_function_or_class (node )
313
- else :
314
- condition = self .mode .is_pyi
315
- if condition and is_stub_body (node ):
306
+ if is_parent_function_or_class (node ) and is_stub_body (node ):
316
307
yield from self .visit_default (node )
317
308
else :
318
309
yield from self .line (+ 1 )
319
310
yield from self .visit_default (node )
320
311
yield from self .line (- 1 )
321
312
322
313
else :
323
- if (
324
- not (self .mode .is_pyi or Preview .dummy_implementations in self .mode )
325
- or not node .parent
326
- or not is_stub_suite (node .parent , self .mode )
327
- ):
314
+ if not node .parent or not is_stub_suite (node .parent ):
328
315
yield from self .line ()
329
316
yield from self .visit_default (node )
330
317
@@ -342,11 +329,7 @@ def visit_async_stmt(self, node: Node) -> Iterator[Line]:
342
329
break
343
330
344
331
internal_stmt = next (children )
345
- if Preview .improved_async_statements_handling in self .mode :
346
- yield from self .visit (internal_stmt )
347
- else :
348
- for child in internal_stmt .children :
349
- yield from self .visit (child )
332
+ yield from self .visit (internal_stmt )
350
333
351
334
def visit_decorators (self , node : Node ) -> Iterator [Line ]:
352
335
"""Visit decorators."""
@@ -420,10 +403,9 @@ def foo(a: int, b: float = 7): ...
420
403
421
404
def foo(a: (int), b: (float) = 7): ...
422
405
"""
423
- if Preview .parenthesize_long_type_hints in self .mode :
424
- assert len (node .children ) == 3
425
- if maybe_make_parens_invisible_in_atom (node .children [2 ], parent = node ):
426
- wrap_in_parentheses (node , node .children [2 ], visible = False )
406
+ assert len (node .children ) == 3
407
+ if maybe_make_parens_invisible_in_atom (node .children [2 ], parent = node ):
408
+ wrap_in_parentheses (node , node .children [2 ], visible = False )
427
409
428
410
yield from self .visit_default (node )
429
411
@@ -529,13 +511,7 @@ def __post_init__(self) -> None:
529
511
self .visit_with_stmt = partial (v , keywords = {"with" }, parens = {"with" })
530
512
self .visit_classdef = partial (v , keywords = {"class" }, parens = Ø )
531
513
532
- # When this is moved out of preview, add ":" directly to ASSIGNMENTS in nodes.py
533
- if Preview .parenthesize_long_type_hints in self .mode :
534
- assignments = ASSIGNMENTS | {":" }
535
- else :
536
- assignments = ASSIGNMENTS
537
- self .visit_expr_stmt = partial (v , keywords = Ø , parens = assignments )
538
-
514
+ self .visit_expr_stmt = partial (v , keywords = Ø , parens = ASSIGNMENTS )
539
515
self .visit_return_stmt = partial (v , keywords = {"return" }, parens = {"return" })
540
516
self .visit_import_from = partial (v , keywords = Ø , parens = {"import" })
541
517
self .visit_del_stmt = partial (v , keywords = Ø , parens = {"del" })
@@ -576,9 +552,7 @@ def transform_line(
576
552
# We need the line string when power operators are hugging to determine if we should
577
553
# split the line. Default to line_str, if no power operator are present on the line.
578
554
line_str_hugging_power_ops = (
579
- (_hugging_power_ops_line_to_string (line , features , mode ) or line_str )
580
- if Preview .fix_power_op_line_length in mode
581
- else line_str
555
+ _hugging_power_ops_line_to_string (line , features , mode ) or line_str
582
556
)
583
557
584
558
ll = mode .line_length
@@ -688,9 +662,6 @@ def should_split_funcdef_with_rhs(line: Line, mode: Mode) -> bool:
688
662
"""If a funcdef has a magic trailing comma in the return type, then we should first
689
663
split the line with rhs to respect the comma.
690
664
"""
691
- if Preview .respect_magic_trailing_comma_in_return_type not in mode :
692
- return False
693
-
694
665
return_type_leaves : List [Leaf ] = []
695
666
in_return_type = False
696
667
@@ -919,9 +890,6 @@ def _maybe_split_omitting_optional_parens(
919
890
try :
920
891
# The RHSResult Omitting Optional Parens.
921
892
rhs_oop = _first_right_hand_split (line , omit = omit )
922
- prefer_splitting_rhs_mode = (
923
- Preview .prefer_splitting_right_hand_side_of_assignments in line .mode
924
- )
925
893
is_split_right_after_equal = (
926
894
len (rhs .head .leaves ) >= 2 and rhs .head .leaves [- 2 ].type == token .EQUAL
927
895
)
@@ -937,8 +905,7 @@ def _maybe_split_omitting_optional_parens(
937
905
)
938
906
if (
939
907
not (
940
- prefer_splitting_rhs_mode
941
- and is_split_right_after_equal
908
+ is_split_right_after_equal
942
909
and rhs_head_contains_brackets
943
910
and rhs_head_short_enough
944
911
and rhs_head_explode_blocked_by_magic_trailing_comma
@@ -1224,11 +1191,7 @@ def append_to_line(leaf: Leaf) -> Iterator[Line]:
1224
1191
trailing_comma_safe and Feature .TRAILING_COMMA_IN_CALL in features
1225
1192
)
1226
1193
1227
- if (
1228
- Preview .add_trailing_comma_consistently in mode
1229
- and last_leaf .type == STANDALONE_COMMENT
1230
- and leaf_idx == last_non_comment_leaf
1231
- ):
1194
+ if last_leaf .type == STANDALONE_COMMENT and leaf_idx == last_non_comment_leaf :
1232
1195
current_line = _safe_add_trailing_comma (
1233
1196
trailing_comma_safe , delimiter_priority , current_line
1234
1197
)
@@ -1315,11 +1278,7 @@ def normalize_invisible_parens( # noqa: C901
1315
1278
1316
1279
# Fixes a bug where invisible parens are not properly wrapped around
1317
1280
# case blocks.
1318
- if (
1319
- isinstance (child , Node )
1320
- and child .type == syms .case_block
1321
- and Preview .long_case_block_line_splitting in mode
1322
- ):
1281
+ if isinstance (child , Node ) and child .type == syms .case_block :
1323
1282
normalize_invisible_parens (
1324
1283
child , parens_after = {"case" }, mode = mode , features = features
1325
1284
)
@@ -1374,7 +1333,6 @@ def normalize_invisible_parens( # noqa: C901
1374
1333
and child .next_sibling is not None
1375
1334
and child .next_sibling .type == token .COLON
1376
1335
and child .value == "case"
1377
- and Preview .long_case_block_line_splitting in mode
1378
1336
):
1379
1337
# A special patch for "case case:" scenario, the second occurrence
1380
1338
# of case will be not parsed as a Python keyword.
@@ -1448,7 +1406,6 @@ def _maybe_wrap_cms_in_parens(
1448
1406
"""
1449
1407
if (
1450
1408
Feature .PARENTHESIZED_CONTEXT_MANAGERS not in features
1451
- or Preview .wrap_multiple_context_managers_in_parens not in mode
1452
1409
or len (node .children ) <= 2
1453
1410
# If it's an atom, it's already wrapped in parens.
1454
1411
or node .children [1 ].type == syms .atom
0 commit comments