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

invalid escape sequence in documentation #2551

Closed
msyyc opened this issue Apr 29, 2024 · 3 comments · Fixed by #2560
Closed

invalid escape sequence in documentation #2551

msyyc opened this issue Apr 29, 2024 · 3 comments · Fixed by #2560
Assignees
Labels

Comments

@msyyc
Copy link
Member

msyyc commented Apr 29, 2024

If docstring contains \, python will report warning:
image

related SDK issue: Azure/azure-sdk-for-python#35364

@msyyc
Copy link
Member Author

msyyc commented Apr 29, 2024

I have checked that adding r for docstring could fix the issue: Azure/azure-sdk-for-python#35364 (comment)

@iscai-msft
Copy link
Contributor

@msyyc the issue if we switch everything over to raw strings is that strings we have escaped before (with \) will no longer be escaped. Can you go through our autorest code and see where we are currently escaping strings?

@msyyc
Copy link
Member Author

msyyc commented Apr 30, 2024

@iscai-msft I think it is reasonable for regex expression(e.g. \d) or windows path (e.g. C:\dev) in python class description. In such scenario, warning caused by python interpreter is fake warning and we shall avoid them. Currently autorest.python use """ by default in template (e.g. here), I think we could add logic that if docstring contains single slash \ then use r""" instead.

nit: I serach escape in autorest.python and find that current escape logic is not for docstring so the solution shall have no conflict
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants