Open rengrub opened 3 months 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?
I suspect in an older version, the output could be unsorted. But it does seem redundant now.
Removing the option would be sensible, but that would constitute a breaking change.
Out of curiosity, I went looking through the old Python docs and it looks like the results of dir()
have been sorted for a long time! https://docs.python.org/release/1.4/lib/node26.html#1169
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:
Result:
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.