Skip to content

Commit 7721761

Browse files
committed
[fix] def formating was put before :
1 parent 34f5ed7 commit 7721761

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

baron/formatting_grouper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@ def group_generator(sequence):
141141
# not really happy about this solution but that avoid a broken release
142142
if current[0] == "COLON" and iterator.show_next() and iterator.show_next()[0] == "COMMENT":
143143
comment = next(iterator)
144-
current = (current[0], current[1], ((current[2]) if len(current) > 3 else []) + [comment])
144+
current = (current[0], current[1], ((current[2]) if len(current) > 2 else []), ((current[3]) if len(current) > 3 else []) + [comment])
145145

146146
yield current

tests/test_regression.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from baron import parse
1+
from baron import parse, dumps
22

33

44
def test_regression_trailing_comment_after_colon():
@@ -7,3 +7,13 @@ def test_regression_trailing_comment_after_colon():
77

88
def test_regression_trailing_comment_after_colon_no_space():
99
assert parse("def a():# pouf\n pass")
10+
11+
12+
def test_regression_trailing_comment_after_colon_dump():
13+
code = "def a(): # pouf\n pass\n"
14+
assert dumps(parse(code)) == code
15+
16+
17+
def test_regression_trailing_comment_after_colon_no_space_dump():
18+
code = "def a():# pouf\n pass\n"
19+
assert dumps(parse(code)) == code

0 commit comments

Comments
 (0)