From 336e8d855689fe14e023049d4afa7a56e188f984 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Mon, 14 Aug 2023 19:25:03 -0700 Subject: [PATCH 1/3] Fix pyright error Seems to have been introduce by new pandas type stubs? --- shiny/plotutils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shiny/plotutils.py b/shiny/plotutils.py index 05c3f1fad..a7e7bca68 100644 --- a/shiny/plotutils.py +++ b/shiny/plotutils.py @@ -104,7 +104,10 @@ def brushed_points( use_y = "y" in brush["direction"] # Filter out x and y values - keep_rows: pd.Series[bool] = pd.Series(True, index=new_df.index) + keep_rows: pd.Series[bool] = pd.Series( + True, + index=new_df.index, # pyright: ignore[reportUnknownMemberType] + ) if use_x: if xvar is None and "x" in brush["mapping"]: xvar = brush["mapping"]["x"] From 3dcc6a6769a04528dfc630f173baaa774b63656c Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Mon, 14 Aug 2023 19:32:05 -0700 Subject: [PATCH 2/3] Fix pyright error in input_file app --- shiny/examples/input_file/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shiny/examples/input_file/app.py b/shiny/examples/input_file/app.py index 0b754bafa..742f06df9 100644 --- a/shiny/examples/input_file/app.py +++ b/shiny/examples/input_file/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pandas as pd from shiny import App, Inputs, Outputs, Session, reactive, render, ui From bf01f654b5b7a71785a5f80b57553257df9a7e7f Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Tue, 15 Aug 2023 11:47:18 -0700 Subject: [PATCH 3/3] Remove shiny/examples; it was renamed to shiny/api-examples --- shiny/examples/input_file/app.py | 58 -------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 shiny/examples/input_file/app.py diff --git a/shiny/examples/input_file/app.py b/shiny/examples/input_file/app.py deleted file mode 100644 index 742f06df9..000000000 --- a/shiny/examples/input_file/app.py +++ /dev/null @@ -1,58 +0,0 @@ -from __future__ import annotations - -import pandas as pd - -from shiny import App, Inputs, Outputs, Session, reactive, render, ui -from shiny.types import FileInfo - -app_ui = ui.page_fluid( - ui.input_file("file1", "Choose CSV File", accept=[".csv"], multiple=False), - ui.input_checkbox_group( - "stats", - "Summary Stats", - choices=["Row Count", "Column Count", "Column Names"], - selected=["Row Count", "Column Count", "Column Names"], - ), - ui.output_table("summary"), -) - - -def server(input: Inputs, output: Outputs, session: Session): - @reactive.Calc - def parsed_file(): - file: list[FileInfo] | None = input.file1() - if file is None: - return pd.DataFrame() - return pd.read_csv( # pyright: ignore[reportUnknownMemberType] - file[0]["datapath"] - ) - - @output - @render.table - def summary(): - df = parsed_file() - - if df.empty: - return pd.DataFrame() - - # Get the row count, column count, and column names of the DataFrame - row_count = df.shape[0] - column_count = df.shape[1] - names = df.columns.tolist() - column_names = ", ".join(str(name) for name in names) - - # Create a new DataFrame to display the information - info_df = pd.DataFrame( - { - "Row Count": [row_count], - "Column Count": [column_count], - "Column Names": [column_names], - } - ) - - # input.stats() is a list of strings; subset the columns based on the selected - # checkboxes - return info_df.loc[:, input.stats()] - - -app = App(app_ui, server)