posit-dev / posit-dev/py-shiny
Remove `session` argument from methods that utilize `require_active_session()`
Open
@schloerke is already working on this.
Since Aug 28, 2023.
Priority: Low
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
Having the session is good for resolving the correct DOM id (such as when in modules), and for sending messages to the browser.
However, some update methods to not utilize the session being sent in:
- https://github.com/rstudio/py-shiny/blob/0bc5ad07bac8dd418d27a848f0234ef6d79a2150/shiny/ui/_input_update.py#L226
- https://github.com/rstudio/py-shiny/blob/0bc5ad07bac8dd418d27a848f0234ef6d79a2150/shiny/ui/_input_update.py#L278
In addition, the session object is something that users shouldn't really be setting.
Proposal:
- Remove
sessionfrom methods whose API hassessionfor context only- Ex:
update_*()methods,notification_{show,remove}(), etc.
- Ex:
- Internally use
session = require_active_session(None)to retrieve the session - Show examples of using
with shiny.session.session_context(session=):to set the context. Such as in an app where a button updates two modules's checkbox group choices.
Doing this would naturally resolve the two situations above and make the API cleaner.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.