Skip to content
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

Make it possible to override the representation function from the outside #3394

Closed
wants to merge 1 commit into from

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
Collaborator

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

@willmcgugan willmcgugan closed this Jul 1, 2024
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.

None yet

2 participants