File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111<!-- Changes that affect Black's stable style -->
1212
13+ - Fix a bug where an illegal trailing comma was added to return type annotations using
14+ PEP 604 unions (#3735 )
15+
1316### Preview style
1417
1518<!-- Changes that affect Black's preview style -->
Original file line number Diff line number Diff line change @@ -918,6 +918,13 @@ def bracket_split_build_line(
918918 )
919919 if isinstance (node , Node ) and isinstance (node .prev_sibling , Leaf )
920920 )
921+ # Except the false negatives above for PEP 604 unions where we
922+ # can't add the comma.
923+ and not (
924+ leaves [0 ].parent
925+ and leaves [0 ].parent .next_sibling
926+ and leaves [0 ].parent .next_sibling .type == token .VBAR
927+ )
921928 )
922929
923930 if original .is_import or no_commas :
Original file line number Diff line number Diff line change 1+ def some_very_long_name_function () -> my_module .Asdf | my_module .AnotherType | my_module .YetAnotherType | None :
2+ pass
3+
4+
5+ def some_very_long_name_function () -> my_module .Asdf | my_module .AnotherType | my_module .YetAnotherType | my_module .EvenMoreType | None :
6+ pass
7+
8+
9+ # output
10+
11+
12+ def some_very_long_name_function () -> (
13+ my_module .Asdf | my_module .AnotherType | my_module .YetAnotherType | None
14+ ):
15+ pass
16+
17+
18+ def some_very_long_name_function () -> (
19+ my_module .Asdf
20+ | my_module .AnotherType
21+ | my_module .YetAnotherType
22+ | my_module .EvenMoreType
23+ | None
24+ ):
25+ pass
You can’t perform that action at this time.
0 commit comments