๐ Add option for panels to fit to content
Provide an option for using Rich Panel.fit() aka Panel(expand=False) for help panels and errors. This was mentioned in discussion #607 and #680. To opt into this new, non-default behavior, just use:
app = typer.Typer(rich_expand=False)
I think this can look nicer on very wide terminals, especially for CLIs with few parameters, or short parameter descriptions, so I would prefer to have the option to choose this style sometimes.
Status
- The code worked fine on all the examples I tried from the Typer tutorial
- The documentation I added is perhaps a little sparse.
- I don't know yet how to capture command output for the Typer docs, and I think an example is needed. Help?
- I'm not sure how to write tests for this. Suggestions are welcome!
Example
๐ Docs preview for commit 1e1a25674a814abedc853398abbe91f538262088 at: https://a93b4aa2.typertiangolo.pages.dev
Modified Pages
- https://a93b4aa2.typertiangolo.pages.dev/tutorial/commands/help/ - (before)
๐ Docs preview for commit b97e79e74cd3a1b1518ac189d36b3a0a3435e7d0 at: https://52aba9d8.typertiangolo.pages.dev
Modified Pages
- https://52aba9d8.typertiangolo.pages.dev/tutorial/commands/help/ - (before)
Any chances to merge this PR soon? Can someone please restart CI?
๐ Docs preview for commit 03860a51404c81fe6882c45306446cf943450aee at: https://7b0a9feb.typertiangolo.pages.dev
Modified Pages
- https://7b0a9feb.typertiangolo.pages.dev/tutorial/commands/help/ - (before)
Any chances to merge this PR soon?
I believe what's missing is test coverage for my new code and logic, which is not my strong suit. I would appreciate any help or suggestions on how to approach writing tests for this.
This pull request has a merge conflict that needs to be resolved.
๐ Docs preview
Last commit 82db16f7d4a177c9e6fc9ee5fa10cf8ae4a5f35c at: https://8ce4e47b.typertiangolo.pages.dev
Modified Pages
- https://8ce4e47b.typertiangolo.pages.dev/tutorial/commands/help/ - (before)
I updated the PR to remove merge conflicts, and:
- Fixed a bug.
- Added rich_expand to
typer.run()for convenience. ๐
Remaining issues:
- I still need help with test coverage. ๐ฌ I'm not familiar enough with the codebase to understand what's going on.
- I have manually tested this code on many of the code samples in the Typer documentation, and some of my own code, with no issues so far.
- As far as I can tell, the only failing CI tests right now are on 3.8 and 3.9, which are end of life. Should we address these? ๐คจ
- I have updated the text of the documentation, but I haven't made any screenshots, because I don't know what procedure you use to make them consistent with the rest of the docs.
the only failing CI tests right now are on 3.8 and 3.9, which are end of life. Should we address these?
Yes, of course, as long as the CI is running 3.8/3.9 tests, that means we're still officially supporting these versions of Python, even if they've become EOL. We'll likely drop them at some point in the near future, but nevertheless every PR should always pass the full test suite.
@svlandeg thanks for your review and suggestions today! ๐
I guess my remaining points are:
- I don't really know how to write the tests to restore 100% coverage. I can try to figure it out.
- I also don't know how to test that the new behavior with
rich_expand=Falseactually works. ๐ - There's no screenshot for the docs. Do we need one? How are those normally generated in this project?
Hi @harkabeeparolus, thanks for the status update! I'll try to look into these issues sometime in the next 10 days.