Multi-line statements are causing a slicing error. A temporary solution is wrapping each statement into online, so our code slice mechanism should work. Especially when we have meaningless parentheses.
Consider following code
x = 1
y = 2
a = (
x+y
)
arta = lineapy.save(a,'a')
arta.get_code()
currently, we will see error because we only slice out
x = 1
y = 2
x+y
and the indentation is not correct.
This PR is modifying the user code as
x = 1
y = 2
a = x+y
arta = lineapy.save(a,'a')
arta.get_code()
before it goes to the tracer; so we can get the following sliced code
x = 1
y = 2
a = x+y
This will not affect end code generation result, since it is running through black before return.
Some edge cases to consider
The cell end semicolon is removed by black, need to add it back; otherwise might see unexpected cell output in the notebook.
Comment-only lines within the code block might prevent black to collapse the entire statement into one line, need to move these comment lines to the end of the next non-comment line.
Fixes # (issue)
[x] Bug fix (non-breaking change which fixes an issue)
Description
Multi-line statements are causing a slicing error. A temporary solution is wrapping each statement into online, so our code slice mechanism should work. Especially when we have meaningless parentheses.
Consider following code
currently, we will see error because we only slice out
and the indentation is not correct.
This PR is modifying the user code as
before it goes to the tracer; so we can get the following sliced code
This will not affect end code generation result, since it is running through black before return.
Some edge cases to consider
black
, need to add it back; otherwise might see unexpected cell output in the notebook.black
to collapse the entire statement into one line, need to move these comment lines to the end of the next non-comment line.Fixes # (issue)
How Has This Been Tested?
Pass all existing tests