-
Notifications
You must be signed in to change notification settings - Fork 74.7k
Improve upgrade script to handle list comprehensions as arguments. #7229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the "col" be one of the return values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"col" here still looks unused to me. Is it expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding tests! The change looks good to approve only pending the question about "col" variable.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"col" here still looks unused to me. Is it expected?
@@ -134,3 +146,31 @@ def testInplace(self): | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you plan to use this comment later on? I am just making sure it is not a typo that you planned to remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
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.