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

fix(python): incorrect escaped characters cause warnings #4538

Merged
merged 8 commits into from
Jun 10, 2024
Merged

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Jun 7, 2024

Fixes #4532. Succinctly, the issue is that the README is copied over into the __init__.py file as a python comment. And then python warns that things like \| and \', which while not often, do organically and correctly show up in markdown syntax, are invalid escapes. Some people who have set their python config to error on warnings end up erroring on this. The solution is to mark the README string as a raw string r''' so python does not try to register the escapes.

I'm not sure how to test this in code in this PR. I have done the following to make sure that this works:

I copied the repro repo from #4532 here and got it to show the warning locally. then, I updated the actual file manually from ''' to r''' and got pytest -W error to give me a thumbs up. So that shows that changing ''' to r''' does not expect the escaped characters to be valid.

I tested my local jsii-pacmak by using it to package a module in aws-cdk, and unzipped the python package and confirmed that the r''' raw string indicator shows up for the README string in __init__.py, and nothing else.

These two combined confirms for me that this solution will work. Again I'm not sure of the best way to test that in jsii-pacmak.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jun 7, 2024
Copy link
Contributor

mergify bot commented Jun 10, 2024

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Jun 10, 2024
Copy link
Contributor

mergify bot commented Jun 10, 2024

Merging (with squash)...

@mergify mergify bot merged commit c5975d5 into main Jun 10, 2024
35 checks passed
@mergify mergify bot deleted the conroy/python branch June 10, 2024 15:48
Copy link
Contributor

mergify bot commented Jun 10, 2024

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python aws-cdk-lib: Invalid escape characters
2 participants