Skip to content

Conversation

@danijar
Copy link

@danijar danijar commented Jun 20, 2024

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
  • Other

Checklist

  • 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.
  • 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.

@danijar
Copy link
Author

danijar commented Jun 20, 2024

Hi @willmcgugan, could you please take a quick look at this one?

@willmcgugan
Copy link
Member

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__.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants