posit-dev / posit-dev/positron

Define Python API hook for third party libraries to control how they display in the variables pane

Open
#5,573 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: variables lang: python
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.