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

Add --indent-string option to libcst.tool print #525

Merged
merged 1 commit into from
Sep 28, 2021

Conversation

amyreese
Copy link
Member

@amyreese amyreese commented Sep 28, 2021

Summary

Allows passing a custom indent string, like ". ", for easier visual
parsing of the resulting tree.

Test Plan

(.venv) jreese@butterfree ~/workspace/usort imr± » cat > hello.py
print("hello world!")

(.venv) jreese@butterfree ~/workspace/usort imr± » python -m libcst.tool print --show-whitespace --show-syntax --indent-string ".   " hello.py
Module(
.   body=[
.   .   SimpleStatementLine(
.   .   .   body=[
.   .   .   .   Expr(
.   .   .   .   .   value=Call(
.   .   .   .   .   .   func=Name(
.   .   .   .   .   .   .   value='print',
.   .   .   .   .   .   ),
.   .   .   .   .   .   args=[
.   .   .   .   .   .   .   Arg(
.   .   .   .   .   .   .   .   value=SimpleString(
.   .   .   .   .   .   .   .   .   value='"hello world!"',
.   .   .   .   .   .   .   .   ),
.   .   .   .   .   .   .   ),
.   .   .   .   .   .   ],
.   .   .   .   .   ),
.   .   .   .   ),
.   .   .   ],
.   .   ),
.   ],
.   footer=[
.   .   EmptyLine(),
.   ],
)

Allows passing a custom indent string, like ".   ", for easier visual
parsing of the resulting tree.
@amyreese amyreese added the enhancement New feature or request label Sep 28, 2021
@amyreese
Copy link
Member Author

Related: would anyone be interested in changing the default indent string to something more useful than " "?

@codecov-commenter
Copy link

Codecov Report

Merging #525 (2585671) into main (39607ed) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #525      +/-   ##
==========================================
- Coverage   94.77%   94.77%   -0.01%     
==========================================
  Files         235      235              
  Lines       23136    23137       +1     
==========================================
  Hits        21928    21928              
- Misses       1208     1209       +1     
Impacted Files Coverage Δ
libcst/tool.py 33.22% <0.00%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39607ed...2585671. Read the comment docs.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 28, 2021
Copy link
Contributor

@lisroach lisroach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I am +1 on a more readable default

@amyreese amyreese merged commit 71b8002 into Instagram:main Sep 28, 2021
@amyreese amyreese deleted the tool-indent branch September 28, 2021 16:47
@zsol
Copy link
Member

zsol commented Sep 28, 2021

FWIW I agree, sorry for not getting to this in time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants