File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 22
22
- Remove support for pre-python 3.7 ` await/async ` as soft keywords/variable names
23
23
(#4676 )
24
24
- Fix crash on parenthesized expression inside a type parameter bound (#4684 )
25
+ - Fix crash when using line ranges excluding indented single line decorated items
26
+ (#4670 )
25
27
26
28
### Preview style
27
29
Original file line number Diff line number Diff line change @@ -330,6 +330,19 @@ def _convert_node_to_standalone_comment(node: LN) -> None:
330
330
first .prefix = ""
331
331
index = node .remove ()
332
332
if index is not None :
333
+ # Because of the special handling of multiple decorators, if the decorated
334
+ # item is a single line then there will be a missing newline between the
335
+ # decorator and item, so add it back. This doesn't affect any other case
336
+ # since a decorated item with a newline would hit the earlier suite case
337
+ # in _convert_unchanged_line_by_line that correctly handles the newlines.
338
+ if node .type == syms .decorated :
339
+ # A leaf of type decorated wouldn't make sense, since it should always
340
+ # have at least the decorator + the decorated item, so if this assert
341
+ # hits that means there's a problem in the parser.
342
+ assert isinstance (node , Node )
343
+ # 1 will always be the correct index since before this function is
344
+ # called all the decorators are collapsed into a single leaf
345
+ node .insert_child (1 , Leaf (NEWLINE , "\n " ))
333
346
# Remove the '\n', as STANDALONE_COMMENT will have '\n' appended when
334
347
# generating the formatted code.
335
348
value = str (node )[:- 1 ]
Original file line number Diff line number Diff line change
1
+ # flags: --line-ranges=6-7
2
+ class Foo :
3
+
4
+ @overload
5
+ def foo (): ...
6
+
7
+ def fox (self ):
8
+ print ()
You can’t perform that action at this time.
0 commit comments