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

[Bug]: Docstring generated without expected escape character (or with an unnecessary one?) #6084

Open
4 tasks done
trangevi opened this issue Feb 20, 2025 · 0 comments
Open
4 tasks done
Labels
bug Something isn't working emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Comments

@trangevi
Copy link

Describe the bug

Generating our python SDK, we're running into a case where a docstring is generated with either a missing escape character, or an unnecessary one.

Our typespec contains the following sentence in a docstring for one of the properties of a model:
"Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length."

When generated, this shows up in two different places. The first is the docstring for the class the model is being generated into
Also note that the message content may be partially cut off if ``finish_reason="length"``\\ , which indicates the generation exceeded ``max_tokens`` or the conversation exceeded the max context length. In this case, it has the double escape characters in the middle of the sentence, and then a space, before the comma. It's unclear to me why those are there, as the typespec docstring has no space, or new line or anything at that point in the docstring which would seemingly need to be escaped. But this doesn't actually cause any issues.

The second place it shows up is as a comment under the actual property, within the generated class, and looks like
Also note that the message content may be partially cut off if ``finish_reason=\"length\"``\ , which indicates the generation exceeded ``max_tokens`` or the conversation exceeded the max context length. In this case, it only generated a single escape character (and additional ones for the quotes around "length"), which is causing pylint to error out.

Reproduction

I've created a branch where the generated code can be seen. This is the first location (which is fine, albeit odd), and this is the second (which breaks pylint). Here is a pointer to the typespec docstring.

Checklist

@trangevi trangevi added the bug Something isn't working label Feb 20, 2025
@timotheeguerin timotheeguerin added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working emitter:client:python Issue for the Python client emitter: @typespec/http-client-python
Projects
None yet
Development

No branches or pull requests

2 participants