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

Wildcard import from express errors out #1065

Closed
cpsievert opened this issue Jan 24, 2024 · 2 comments · Fixed by #1067
Closed

Wildcard import from express errors out #1065

cpsievert opened this issue Jan 24, 2024 · 2 comments · Fixed by #1067
Labels
Milestone

Comments

@cpsievert
Copy link
Collaborator

from shiny.express import *

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cpsievert/github/py-shiny/shiny/express/__init__.py", line 46, in __getattr__
    return _get_current_session().input  # pyright: ignore
AttributeError: 'NoneType' object has no attribute 'input'
@wch
Copy link
Collaborator

wch commented Jan 25, 2024

I'm not able to reproduce this. Here's a screenshot:

image

When it does the UI rendering pass, get_current_session() should return a MockSession object. For example, with this app:

from shiny.express import *

print(session)
print(input)
"Hello"

it prints the following to the console:

<shiny.express._mock_session.MockSession object at 0x102010f90>
<shiny.session._session.Inputs object at 0x1020110d0>
INFO:     Started server process [95498]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:55016 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:55019 - "GET /?vscodeBrowserReqId=1706155679039 HTTP/1.1" 200 OK
INFO:     ('127.0.0.1', 55022) - "WebSocket /websocket/" [accepted]
INFO:     connection open
<shiny.session._session.Session object at 0x102174550>
<shiny.session._session.Inputs object at 0x10069f8d0>

@wch wch added this to the v0.7.0 milestone Jan 25, 2024
@wch wch mentioned this issue Jan 25, 2024
55 tasks
@wch
Copy link
Collaborator

wch commented Jan 25, 2024

Update: I am able to reproduce this by running it at the console.

>>> from shiny.express import *

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/winston/Projects/py-shiny/shiny/express/__init__.py", line 46, in __getattr__
    return _get_current_session().input  # pyright: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'input'

>>> from shiny.express import input
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'input' from 'shiny.express' (/Users/winston/Projects/py-shiny/shiny/express/__init__.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants