Skip to content

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

@wch

Description

@wch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions