-
Notifications
You must be signed in to change notification settings - Fork 270
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
Update pytype_runner.py - change escape_ninja_path to escape all the ninja path escape-needing characters #1608
Conversation
…ninja path escape-needing characters
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.
Thanks! A couple suggestions to make the code more concise.
Args: | ||
path: The path. | ||
""" | ||
new_path = '' |
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.
Now that there are multiple special characters involved, I'd prefer to use re.sub
to make the code more concise. This seems to work:
return re.sub(r'(?P<char>[\n :$])', r'$\g<char>', path)
(An import re
line is also needed at the top of the file, of course.)
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.
re.sub(r'([\n :$])', r'$\1', path)
also works equivalently, and reads slightly simpler, if you prefer that. (I don't feel strongly either way.)
…ninja path escape-needing characters (#1608) This fixes #499. Unfortunately, I was not able to get pytype running on my machine, so this commit is just based on what seems like the right idea to me, and hopefully it can be verified to be correct by a maintainer and then merged. Resolves #1608 PiperOrigin-RevId: 623037901
This fixes #499
Unfortunately, I was not able to get pytype running on my machine, so this commit is just based on what seems like the right idea to me, and hopefully it can be verified to be correct by a maintainer and then merged.