Skip to content

Commit 2ade16e

Browse files
committed
Rework playwright test to be Express; typing workarounds
1 parent 42b08e1 commit 2ade16e

File tree

1 file changed

+13
-23
lines changed
  • tests/playwright/shiny/session/clientdata

1 file changed

+13
-23
lines changed
Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
1+
# pyright: reportUnknownMemberType=false, reportUnknownVariableType=false
12
import matplotlib.pyplot as plt
23
import numpy as np
34

4-
from shiny import App, Inputs, Outputs, Session, render, ui
5+
from shiny.express import input, render, session, ui
56

6-
app_ui = ui.page_sidebar(
7-
ui.sidebar(
8-
ui.input_slider("obs", "Number of observations:", min=0, max=1000, value=500),
9-
open="closed",
10-
),
11-
ui.h3("clientData values"),
12-
ui.output_text_verbatim("clientdatatext"),
13-
ui.output_plot("myplot"),
14-
title="Shiny Client Data",
15-
)
7+
with ui.sidebar(open="closed"):
8+
ui.input_slider("obs", "Number of observations:", min=0, max=1000, value=500)
169

1710

18-
def server(input: Inputs, output: Outputs, session: Session):
19-
@render.text
20-
def clientdatatext():
21-
cdata = session.clientdata
22-
return "\n".join([f"{name} = {cdata[name]()}" for name in reversed(dir(cdata))])
11+
@render.code
12+
def clientdatatext():
13+
cdata = session.clientdata
14+
return "\n".join([f"{name} = {cdata[name]()}" for name in reversed(dir(cdata))])
2315

24-
@render.plot
25-
def myplot():
26-
plt.figure()
27-
plt.hist(np.random.normal(size=input.obs()))
28-
plt.title("This is myplot")
2916

30-
31-
app = App(app_ui, server)
17+
@render.plot
18+
def myplot():
19+
plt.figure()
20+
plt.hist(np.random.normal(size=input.obs())) # type: ignore
21+
plt.title("This is myplot")

0 commit comments

Comments
 (0)