Open rengrub opened 1 month ago
Presumably rich.inspect
relies on Python's dir
where the "resulting list is sorted alphabetically"? If that's the case the sort
argument doesn't really make sense!
Presumably
rich.inspect
relies on Python'sdir
Even if the object defines __dir__()
and returns unsorted entries, calling dir()
on it will sort them. So I agree with your analysis.
Ahh interesting, look at that, they will always be sorted. So then, what behavior should I expect from the rich.inspect sort keyword argument?
Describe the bug
Performing rich.inspect() on a class object with sort=False and sort=True results in the same output for class attributes which are not already naturally in alphabetical order (i.e. both appear sorted alphabetically).
Result:![image](https://github.com/user-attachments/assets/998534fe-a858-4ef9-9a50-1d793b821712)
Result:![image](https://github.com/user-attachments/assets/6b724d8e-090c-4eec-8925-dc5593f7ca6b)
Platform Python 3.11.3 WSL: Ubuntu-22.04
If you're using Rich in a terminal:
If you're using Rich in a Jupyter Notebook, run the following snippet in a cell and paste the output in your bug report.