Make it possible to override the representation function from the outside
A minimal change that makes it possible to override the representation function from the outside. This unblocks us now and could lay the basis for #3393 in the future.
Type of changes
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [x] Other
Checklist
- [x] I've run the latest black with default args on new code.
- [ ] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [ ] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.
Description
Please describe your changes here. If this fixes a bug, please link to the issue, if possible.
Hi @willmcgugan, could you please take a quick look at this one?
Can't accept this I'm afraid. I'm assuming you want to monkey patch get_repr?
Monkey patching isn't good API, but if you are comfortable with it, you could just do this:
globals()['repr'] = lambda obj: "foo"
That said, I think the best approach right now would be to write a method that accepts your objects and returns a proxy with a __rich_repr__.