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

rich_cli does not properly clean indentations for click >= 8.1.0 #55

Closed
apcamargo opened this issue Apr 13, 2022 · 7 comments · Fixed by #56 or #67
Closed

rich_cli does not properly clean indentations for click >= 8.1.0 #55

apcamargo opened this issue Apr 13, 2022 · 7 comments · Fixed by #56 or #67
Labels
bug Something isn't working high priority

Comments

@apcamargo
Copy link
Contributor

rich_click is not cleaning indentations if click version is ≥ 8.10. The cause is probably this change in the backend.

This code:

def cli():
    """
    Foo: bar

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Pellentesque habitant
    morbi tristique senectus. Leo a diam sollicitudin tempor.
    """

Is generating this:

 Foo: bar
 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod     tempor incididunt ut
 labore et dolore magna aliqua. Pellentesque habitant     morbi tristique senectus. Leo a diam
 sollicitudin tempor.

Instead of this:

 Foo: bar
 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
 et dolore magna aliqua. Pellentesque habitant morbi tristique senectus. Leo a diam sollicitudin
 tempor.
@ewels ewels added bug Something isn't working high priority labels Apr 13, 2022
@ewels
Copy link
Owner

ewels commented Apr 13, 2022

Ok, so we need to run dedent manually now I guess. Thanks for reporting! PRs welcome, I'm away for 2-3 weeks now with holiday and starting a new job but will get to it ASAP.

@apcamargo
Copy link
Contributor Author

I'll try to take a look at the code in the next few days. But it seems to me that the easy way out would be to use inspect.cleandoc within _make_rich_rext. Do you think this would beak something?

@ewels
Copy link
Owner

ewels commented Apr 14, 2022

No, that sounds perfect 👍🏻 I wasn't familiar with inspect.cleandoc, I didn't realise that this was part of the core lib. I've used textwrap.dedent in the past which is why that jumped to mind. But better to use the same approach as Click 👍🏻

@abdusco
Copy link

abdusco commented Apr 25, 2022

@apcamargo 's fix works wonderfully 🚀

@ewels ewels closed this as completed in #56 Apr 27, 2022
@apcamargo
Copy link
Contributor Author

@ewels I'm still having this issue in the latest version :(
@abdusco, how did you test the PR?

@apcamargo
Copy link
Contributor Author

Ok. Apparently the fix worked for the header, but not for the command description.

 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
 labore et dolore magna aliqua. Pellentesque habitant morbi tristique senectus. Leo a diam
 sollicitudin tempor.

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│  --version      Show the version and exit.                                                       │
│  --help     -h  Show this message and exit.                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Modules ────────────────────────────────────────────────────────────────────────────────────────╮
│  download-database          Download the latest version of Genomad's database and save it in     │
│                             the     DESTINATION directory.                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

@ewels
Copy link
Owner

ewels commented May 16, 2022

ah yeah, tests... #25 🙄

Thanks for spotting @apcamargo! I also spotted one other place in the code that needed this before release (0f99123), but missed this one..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
3 participants