Remove rich as required for tree()#3778
Open
ianhi wants to merge 3 commits intozarr-developers:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I often found that when I wanted to use
tree()richwasn't installed. So I started out with this as a fallback but on looking into it I think it can be fully removed in favor a small loop (which we would need anyway for a fallback) to construct the tree and just add in ansi or html bolding codes.One thing I noticed when looking at this is that there is currently no truncation for extremely large hierarchies. I think that is bad for two reasons:
So I've added a simplistic truncation. Note that this can result in nodes that are displayed having missing children.
I also added a
plainflag to give the user explicit control on the bolding html/ansi sequences.Output
Per the tests the output is equivalent, and also looks so to my eyes.
To compare here is a script (runnable with third-wheel)
uvx third-wheel@0.3.0 run compare_trees.pycompare_trees.py
or in jupyter:
TODO:
docs/user-guide/*.mdchanges/