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 unstable formatting involving ` # fmt: skip ` comments without internal spaces
14+ (#2970 )
15+
1316### Preview style
1417
1518<!-- Changes that affect Black's preview style -->
Original file line number Diff line number Diff line change @@ -214,8 +214,11 @@ def generate_ignored_nodes(
214214 container : Optional [LN ] = container_of (leaf )
215215 if comment .value in FMT_SKIP :
216216 prev_sibling = leaf .prev_sibling
217- if comment .value in leaf .prefix and prev_sibling is not None :
218- leaf .prefix = leaf .prefix .replace (comment .value , "" )
217+ # Need to properly format the leaf prefix to compare it to comment.value,
218+ # which is also formatted
219+ comments = list_comments (leaf .prefix , is_endmarker = False , preview = preview )
220+ if comments and comment .value == comments [0 ].value and prev_sibling is not None :
221+ leaf .prefix = ""
219222 siblings = [prev_sibling ]
220223 while (
221224 "\n " not in prev_sibling .prefix
Original file line number Diff line number Diff line change 1+ a = "this is some code"
2+ b = 5 #fmt:skip
3+ c = 9 #fmt: skip
4+ d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasuperlongstring" #fmt:skip
5+
6+ # output
7+
8+ a = "this is some code"
9+ b = 5 # fmt:skip
10+ c = 9 # fmt: skip
11+ d = "thisisasuperlongstringthisisasuperlongstringthisisasuperlongstringthisisasuperlongstring" # fmt:skip
Original file line number Diff line number Diff line change 4444 "fmtskip4" ,
4545 "fmtskip5" ,
4646 "fmtskip6" ,
47+ "fmtskip7" ,
4748 "fstring" ,
4849 "function" ,
4950 "function2" ,
You can’t perform that action at this time.
0 commit comments