-
Notifications
You must be signed in to change notification settings - Fork 5
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 and extra tests for literals #115
base: main
Are you sure you want to change the base?
Conversation
8dab859
to
c2b9cdf
Compare
def my_function(): | ||
a = """ | ||
This is a string that | ||
should align with the function body. | ||
""" | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if you test this with PyCharm you will notice that it doesn't indent the contents of the string literal. This only happens when you remove the assignment, which identifies the string literal as a doc comment.
This is one area where Java text blocks behave differently. Their content is always stripped of all common leading indentation. As a result the text blocks can be indented without the string's runtime value changing. I think this is an extremely useful feature which I miss in Python. But that explains why the formatter must only indent the contents of doc comment string literals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified the test
What's changed?
The
TabsAndIndentsVisitor
cannot correctly handle literals that are not assigned to anything. Currently, this PR add tests to illustrate this behavior.What's your motivation?
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist