Skip to content
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

Merged
merged 7 commits into from
Apr 9, 2024

Conversation

wyattscarpenter
Copy link
Contributor

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.

Copy link
Contributor

@rchen152 rchen152 left a 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 = ''
Copy link
Contributor

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.)

Copy link
Contributor Author

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.)

pytype/tools/analyze_project/pytype_runner.py Outdated Show resolved Hide resolved
rchen152 added a commit that referenced this pull request Apr 3, 2024
For #499. Together with
#1608, this should fix the issue.

PiperOrigin-RevId: 621638737
@rchen152 rchen152 merged commit 52d8e44 into google:main Apr 9, 2024
19 checks passed
rchen152 pushed a commit that referenced this pull request Apr 9, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error of paths with spaces (Linux)
2 participants