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

For Express apps, confusing error if input.x is accessed without importing input #991

Closed
wch opened this issue Jan 10, 2024 · 0 comments · Fixed by #994
Closed

For Express apps, confusing error if input.x is accessed without importing input #991

wch opened this issue Jan 10, 2024 · 0 comments · Fixed by #994
Milestone

Comments

@wch
Copy link
Collaborator

wch commented Jan 10, 2024

If the app tries to access input without importing it from shiny.express, it prints the following confusing error message:

RuntimeError: 'builtin_function_or_method' object has no attribute 'x'

Example app:

from shiny import reactive
from shiny.express import ui
# from shiny.express import input

ui.input_action_button("x", "Click me")

@reactive.Effect()
@reactive.event(input.x)
def foo():
    print("Clicked button")

This is because input is a builtin function in Python, but it doesn't have an attribute named x. So although the error is correct, it is a bit confusing.

I think that while evaluating the code, we could inject a different object named input that will result in a better error message.

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 a pull request may close this issue.

1 participant