Open free2dog opened 5 years ago
Thank you for your report! I think #75 was meant to fix cases like this. I will work on that after we release 0.8 next month.
The statement mock.Mock = annotations.annot_aiohttp_test_utils_make_mocked_request_mock_Mock()
is exactly 80 chars without indentation. Hence, astor.to_source(fundefNode.body[0])
output meets @bryce-ma's expectation.
With indentation of 4 spaces, the same statement is 84 chars. Hence, the line is broken and, instead of adding a line continuation character ('\'), the pretty printer wraps the rhs expression in parenthesis.
So, I think the perceived "incorrectness" of the breaks is due to the length of the statement when used in isolation and when used inside a function.
That said, to help users, astor should commit to either use of parenthesis or use of line continuation or be explicit about when would each be supported.
Same ast node in memory.
expected output source code(arguments list omitted):
actually I got parentheses around the _ast.Call:
when I use debugger to print source using astor.to_source() on this specific _ast.Assign node,
I use these in my debugger console
I got the correct version
But when I print all functionDef node,
I got the wrong version