posit-dev / posit-dev/positron
Define Python API hook for third party libraries to control how they display in the variables pane
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.3k
- Forks
- 184
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 206
Description
Motivated by #5499 -- we can add custom display code in the Positron Python kernel on a case by case basis when we find that __repr__ renders badly or some other reason (performance or unwanted computation). But: dealing with display rendering for third party libraries within Positron has a number of drawbacks:
- We are responsible for maintaining this code, and handling a new third party library requires making changes to Positron and waiting until a new version is released to get the improvement.
- If there is a breaking change to a third party library that causes the display rendering code in Positron to stop working, then the current and all previous versions of Positron will all be broken with the new library version going forward.
Clearly, this is not ideal! IPython / Jupyter in the past had provided a _repr_html_ display hook for third party libraries to provide an HTML rendering for the Jupyter notebook. We could define a similar _repr_positron_ (open to ideas on the name) or similar hook to allow libraries to define how they display in the variables pane. If this method isn't present, we can fall back onto __repr__.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing issue #5499 and the existing Positron Python kernel display-rendering behavior described here. Define the hook's name, contract, and fallback to repr, then document or test the behavior once the relevant entry points are identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100