Improve upgrade script to handle list comprehensions as arguments.#7229
Conversation
annarev
left a comment
There was a problem hiding this comment.
Can you add some tests with '[', spaces, and comments?
| if comment_start == -1: | ||
| col = len(prev_line) | ||
| elif find_string_chars.search(prev_line[comment_start:]) is None: | ||
| col = comment_start |
There was a problem hiding this comment.
Should the "col" be one of the return values?
There was a problem hiding this comment.
Tests are forthcoming (I used some to develop this that I haven't codified yet, but work), but I wanted to get this version up asap so that people wouldn't be hit by these problems. I'll put them in now.
There was a problem hiding this comment.
"col" here still looks unused to me. Is it expected?
| if comment_start == -1: | ||
| col = len(prev_line) | ||
| elif find_string_chars.search(prev_line[comment_start:]) is None: | ||
| col = comment_start |
There was a problem hiding this comment.
"col" here still looks unused to me. Is it expected?
| if __name__ == "__main__": | ||
| test_lib.main() | ||
|
|
||
| """tf.concat(0, [tf.concat(0, tiles[y]) for y in range(4)]) |
There was a problem hiding this comment.
Do you plan to use this comment later on? I am just making sure it is not a typo that you planned to remove.
python's ast module does not return the correct location, so we have to do our best to scan backwards to find where the [ token that trully started the list comprehension occurs.
|
I've added tests now. |
python's ast module does not return the correct location, so we
have to do our best to scan backwards to find where the [ token
that trully started the list comprehension occurs.