-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix using tuples as positional arguments in rich repr #2379
Fix using tuples as positional arguments in rich repr #2379
Conversation
Currently, it isn't possible to use tuples as positional arguments from `__rich_repr__`, because they are special cased to support adding a key and a default value. This adds support for them, by allowing `None` as a key.
This already works: class Foo:
def __rich_repr__(self):
yield None, (1,)
f=Foo()
from rich import print
print(f) If its not documented, that should certainly be rectified. |
Codecov Report
@@ Coverage Diff @@
## master #2379 +/- ##
==========================================
- Coverage 98.71% 98.67% -0.05%
==========================================
Files 73 72 -1
Lines 7771 7746 -25
==========================================
- Hits 7671 7643 -28
- Misses 100 103 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@willmcgugan Oh whoops! I guess I should have tested it first :) I updated this PR to remove the code changes, but keep the tests and docs. |
Type of changes
Checklist
Description
Currently, it isn't possible to use tuples as positional arguments from
__rich_repr__
, because they are special cased to support adding a key and a default value.This adds support for them, by allowing
None
as a key.