-
Notifications
You must be signed in to change notification settings - Fork 100
Issues with positional arguments and shiny.express.ui
components
#947
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
Comments
shiny.express.ui
functions probably shouldn't have named positional argumentsshiny.express.ui
components
…xt managers to their functional component signature
…xt managers to their functional component signature
Even if the above were not true, I don't love--if I understand correctly--that functions won't be able to take non-child positional arguments anymore. In the |
My apologies if this is off base, but would it be helpful to maybe write a document expressing the line between Core and Express? I feel like some of these API decisions might be getting a bit muddy because as we're trying to do a bit too much with Express layouts. We're going to need that documentation anyway to tell people when they should switch to Core, and I think it would clarify some of these questions because we'd have more consensus on what we need to make easy in Express and what we can allow to be a bit more difficult. |
I'd be curious to hear more of the reasoning behind this. From my limited understanding, it seems these costs outweigh the benefits:
If we do, however, decide that erroring is desirable, seems we could improve the error message. Also, I think the
Not necessarily for solving this problem, but I do think that'll be helpful to do at some point. I would also be surprised if we have a clear vision for that line at this point :) |
…xt managers to their functional component signature
Uh oh!
There was an error while loading. Please reload this page.
Problem
I can see two issues with how
shiny.express.ui
handles positional arguments:*
instead of*args
in their signature). This means you can't currently use things likeui.card()
the "functional" way:value_box()
hastitle
/value
as named positional args, usage must look like this:...which is unfortunate, especially when you want to a dynamically rendered value.
Proposal
I think we can solve both issues by taking inspiration from how
card_header()
currently works. That is, if the underlying UI function takes any positional arguments, we always start the express function with*args
and pass those args to the underlying UI functionpy-shiny/shiny/express/ui/_cm_components.py
Lines 455 to 487 in b61452d
This does lead to the question of whether functions like
nav_panel()
should be(title, *args, **kwargs)
or(*args, **kwargs)
, but it seems pretty sensible to me (for consistency sake) that we go in the latter direction.The text was updated successfully, but these errors were encountered: