Skip to content

Commit

Permalink
[fix] DecoratorProxyList of the last method of a function wasn't hand…
Browse files Browse the repository at this point in the history
…ling correctly the indentation of its last endl token
  • Loading branch information
Psycojoker committed Mar 3, 2015
1 parent 0670d9c commit cb40881
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 3 additions & 4 deletions redbaron.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,10 +1618,9 @@ def generate_separator():
expected_list.append(generate_separator())

if expected_list:
if self.parent.next:
expected_list[-1].indent = self.parent.indentation
else:
expected_list[-1].indent = ""
# decorators always have a next item
# don't break its indentation
expected_list[-1].indent = self.parent.indentation

return expected_list

Expand Down
6 changes: 6 additions & 0 deletions tests/test_proxy_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,3 +1208,9 @@ def test_root_as_line_proxy_list_extend():
red = RedBaron("\n\na\nb\nc\n")
red.extend(["zob"])
assert red.dumps() == "\n\na\nb\nc\nzob\n"


def test_regression_first_method_of_a_class_decorators_append():
red = RedBaron("class A:\n def foo():\n pass")
red.def_.decorators.append("@staticmethod")
assert red.dumps() == "class A:\n @staticmethod\n def foo():\n pass\n"

0 comments on commit cb40881

Please sign in to comment.