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

Add REPL context #3026

Closed
wants to merge 0 commits into from
Closed

Add REPL context #3026

wants to merge 0 commits into from

Conversation

goodki-d
Copy link
Contributor

@goodki-d goodki-d commented Jan 9, 2025

Introduces REPL context to allow users customise their REPL experience.

Please refer to #3018

API

# variable == module/class/object/callable
app.repl_ctx.add(variable, "<name>", "desc")

Renders in console as:

<name> <type> : <desc>

@goodki-d goodki-d requested a review from a team as a code owner January 9, 2025 12:27
@ahopkins
Copy link
Member

ahopkins commented Jan 9, 2025

I'm wondering if we should get a little smart with this and allow assignment so that in the simplest use case there is just this:

def foo():
    """Some docstring"""


app.repl_ctx.foo = foo

The .add(...) method is just when you want the more fine-grained control.

@goodki-d
Copy link
Contributor Author

goodki-d commented Jan 9, 2025

That'd be somewhat simpler to implement also a simpler API. We'll need to do formatting (like truncating doctoring to fit console) on render time, that's fine.

Should we use an internal state (like currently _locals set) or just iterate the attributes?

@ahopkins ahopkins closed this Mar 5, 2025
@ahopkins ahopkins mentioned this pull request Mar 5, 2025
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