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] box.py susceptible to breakage when commited with trailing-whitespace pre-commit hook #3049

Open
2 tasks done
robinbowes opened this issue Jul 21, 2023 · 11 comments
Open
2 tasks done

Comments

@robinbowes
Copy link

robinbowes commented Jul 21, 2023

Describe the bug

We committed a copy of the rich module to a git repo as part of building an AWS lambda layer.

box.py got mangled by the pre-commit trailing-whitespace hook.

Would it be possible to redefine the box character definitions in a way that does not have trailing white space?

Platform

Click to expand This was on a Mac, with python 3.10.12 and rich v13.4.2

Other details not relevant to this issue.

@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

I guess implicit line continuations would address that. I'd accept a PR.

@robinbowes
Copy link
Author

Any preferred style?

eg. this works:

box = "\n".join(
    [
        "  ╷ ",
        "  │ ",
        "╶─┼╴",
        "  │ ",
        "╶─┼╴",
        "╶─┼╴",
        "  │ ",
        "  ╵ ",
    ]
)

@willmcgugan
Copy link
Collaborator

I was thinking this, so there would be no work at runtime:

box = (
        "  ╷ "
        "  │ "
        "╶─┼╴"
        "  │ "
        "╶─┼╴"
        "╶─┼╴"
        "  │ "
        "  ╵ "
)

I hope black doesn't mangle that. If it does you may have to disable formatting for those lines.

@robinbowes
Copy link
Author

Black mangles that to one line.

@willmcgugan
Copy link
Collaborator

There's a comment you can add to disable formatting for a given block. Something line # fmt: off IIRC.

@robinbowes
Copy link
Author

Also, it doesn't work anyway - it is read as a single line.

@willmcgugan
Copy link
Collaborator

I forgot the\n characters, but I think it should work.

@robinbowes
Copy link
Author

Ah yes - will work with \n characeters embedded in the strings.

@robinbowes
Copy link
Author

robinbowes commented Jul 21, 2023

This sort of thing works:

# fmt: off
box = (
    "  ╷ \n"
    "  │ \n"
    "╶─┼╴\n"
    "  │ \n"
    "╶─┼╴\n"
    "╶─┼╴\n"
    "  │ \n"
    "  ╵ \n"
)
# fmt: on

If that looks OK, I'll knock up a PR that changes all box definitions to use that format.

@willmcgugan
Copy link
Collaborator

Works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants