Skip to content

fix: Strip backslash before # in generated docstrings#677

Open
Alan4506 wants to merge 1 commit intosmithy-lang:developfrom
Alan4506:fix/docstring-escape-sequences
Open

fix: Strip backslash before # in generated docstrings#677
Alan4506 wants to merge 1 commit intosmithy-lang:developfrom
Alan4506:fix/docstring-escape-sequences

Conversation

@Alan4506
Copy link
Copy Markdown
Contributor

@Alan4506 Alan4506 commented Apr 3, 2026

Description of changes:
The MarkdownConverter strips unnecessary backslash escapes that pandoc adds for markdown syntax characters. However, # was missing from the strip list. When pandoc converts service documentation containing a literal # character, it escapes it to \# because # is a markdown heading marker. This \# then ends up in the generated Python docstring as an invalid escape sequence, causing pyright reportInvalidStringEscapeSequence errors.

This issue was identified during generation of Lex Runtime V2 client using its model file.

This PR adds # to the regex character class in postProcessPandocOutput() so that \# is correctly stripped to # in generated docstrings.

Verified by generating the Lex Runtime V2 client with the fix. smithy build passes ruff and pyright cleanly, and there is no \# in generated code.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Alan4506 Alan4506 requested a review from a team as a code owner April 3, 2026 04:14
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.

1 participant