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

Raise when express.[input,output,session] are used outside of Express app #1067

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

wch
Copy link
Collaborator

@wch wch commented Jan 25, 2024

This closes #1065.

Now, if the user does an import outside of an Express app, it will not throw immediately, but it will throw if they try to use the object.

>>> from shiny.express import *

>>> input
<shiny.express._ExpressOnlyPlaceholder object at 0x1044c0490>
>>> input.d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/winston/Projects/py-shiny/shiny/express/__init__.py", line 73, in __getattr__
    raise RuntimeError(
RuntimeError: shiny.express.input can only be used inside of a Shiny Express app.


>>> session
<shiny.express._ExpressOnlyPlaceholder object at 0x107897a10>
>>> session.d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/winston/Projects/py-shiny/shiny/express/__init__.py", line 73, in __getattr__
    raise RuntimeError(
RuntimeError: shiny.express.session can only be used inside of a Shiny Express app.


>>> output
<shiny.express._ExpressOnlyPlaceholder object at 0x1044c22d0>
>>> output()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/winston/Projects/py-shiny/shiny/express/__init__.py", line 78, in __call__
    raise RuntimeError(
RuntimeError: shiny.express.output can only be used inside of a Shiny Express app.

@wch wch merged commit e6a8984 into main Jan 25, 2024
26 checks passed
@wch wch deleted the express-object-access branch January 25, 2024 16:19
@wch wch mentioned this pull request Jan 25, 2024
55 tasks
@wch wch added this to the v0.7.0 milestone Jan 25, 2024
schloerke added a commit that referenced this pull request Feb 13, 2024
* main: (33 commits)
  test: Test apps locally before deploying via pytest fixtures. (#1055)
  docs: Add ExtendedTask to API index (#1088)
  Fix `render.download` in Shiny Express, take 2 (#1085)
  Bump version to 0.7.0.9000
  Create two different api doc folders, one for Core and one for Express (#1053)
  chore: Pin black to version 23 (#1077)
  chore: Remove github link to shinylive (#1069)
  Bump version to 0.7.0
  Raise when `express.[input,output,session]` are used outside of Express app (#1067)
  Update dashboard template (#1056)
  chore: Remove many broken quartodoc links (#1061)
  Update {bslib} (#1062)
  Update docstrings for `expressify`, `hold`, and `render.express` (#1066)
  Add `fill` to `__all__` in `ui` and `express.ui` (#1064)
  Update shiny.js (#1059)
  docs(examples): Use refactored shinylive syntax (#1048)
  Update `shiny.js` (#1052)
  Add `express.ui.panel_title` (#1039)
  Don't run `effect`s created in a `MockSession` (#1049)
  Delete shiny/api-examples/Calc directory (#1044)
  ...
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.

Wildcard import from express errors out
2 participants