streamlit-nightly 1.43.3.dev20250318__py3-none-any.whl → 1.43.3.dev20250320__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/auth_util.py +1 -1
- streamlit/commands/page_config.py +1 -1
- streamlit/config.py +11 -14
- streamlit/connections/snowflake_connection.py +2 -2
- streamlit/connections/snowpark_connection.py +1 -1
- streamlit/connections/sql_connection.py +1 -1
- streamlit/connections/util.py +1 -1
- streamlit/dataframe_util.py +12 -12
- streamlit/delta_generator.py +2 -2
- streamlit/deprecation_util.py +2 -2
- streamlit/elements/arrow.py +3 -3
- streamlit/elements/deck_gl_json_chart.py +4 -4
- streamlit/elements/dialog_decorator.py +2 -2
- streamlit/elements/heading.py +1 -1
- streamlit/elements/html.py +3 -3
- streamlit/elements/lib/built_in_chart_utils.py +9 -8
- streamlit/elements/lib/color_util.py +7 -7
- streamlit/elements/lib/dialog.py +1 -1
- streamlit/elements/lib/image_utils.py +9 -7
- streamlit/elements/lib/mutable_status_container.py +1 -1
- streamlit/elements/media.py +2 -2
- streamlit/elements/metric.py +1 -1
- streamlit/elements/plotly_chart.py +4 -4
- streamlit/elements/vega_charts.py +5 -5
- streamlit/elements/widgets/button_group.py +1 -1
- streamlit/elements/widgets/multiselect.py +3 -2
- streamlit/elements/widgets/select_slider.py +3 -5
- streamlit/elements/widgets/slider.py +4 -4
- streamlit/elements/widgets/time_widgets.py +4 -4
- streamlit/elements/write.py +1 -1
- streamlit/proto/NewSession_pb2.py +16 -16
- streamlit/proto/NewSession_pb2.pyi +16 -11
- streamlit/runtime/app_session.py +1 -1
- streamlit/runtime/caching/cache_data_api.py +2 -2
- streamlit/runtime/caching/cache_resource_api.py +2 -2
- streamlit/runtime/caching/hashing.py +7 -7
- streamlit/runtime/metrics_util.py +1 -1
- streamlit/runtime/scriptrunner/script_runner.py +1 -1
- streamlit/runtime/scriptrunner_utils/script_requests.py +1 -1
- streamlit/runtime/session_manager.py +1 -1
- streamlit/runtime/state/session_state.py +3 -3
- streamlit/runtime/websocket_session_manager.py +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/css/index.C5t3M85E.css +1 -0
- streamlit/static/static/js/{FileDownload.esm.qg6FU0gn.js → FileDownload.esm.DQm20hQF.js} +1 -1
- streamlit/static/static/js/{FileHelper.BjsqRSXf.js → FileHelper.O0Tw1vHm.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.lrCbq3h9.js → FormClearHelper.B96mvJBl.js} +1 -1
- streamlit/static/static/js/{Hooks.DLM8-GOj.js → Hooks.DhfCkO7P.js} +1 -1
- streamlit/static/static/js/{InputInstructions.C6xqeBjt.js → InputInstructions.BUcruzQw.js} +1 -1
- streamlit/static/static/js/{ProgressBar.CwnbGH4T.js → ProgressBar.C5PvfYoT.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.DBosjlw4.js → RenderInPortalIfExists.CsAqYz6S.js} +1 -1
- streamlit/static/static/js/{Toolbar.DPjbmT0r.js → Toolbar.DPKilS9Z.js} +1 -1
- streamlit/static/static/js/{base-input.DYN8lKyb.js → base-input.CyYBBCqT.js} +1 -1
- streamlit/static/static/js/{checkbox.DHvRlo93.js → checkbox.EwRwlfrN.js} +1 -1
- streamlit/static/static/js/{createSuper.ClJZbMNR.js → createSuper.CZLLU1gy.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.B9qrlUd6.js +1 -0
- streamlit/static/static/js/{downloader.D-SIwsMu.js → downloader.O1knmGpz.js} +1 -1
- streamlit/static/static/js/{es6.RZQgn996.js → es6.qhuPBmb4.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.CXViiYfd.js → iframeResizer.contentWindow.nwPvRFph.js} +1 -1
- streamlit/static/static/js/{index.BLNPtZ0I.js → index.7rsEhQWb.js} +1 -1
- streamlit/static/static/js/index.B0cliXfV.js +1 -0
- streamlit/static/static/js/{index.Dk0AzWKK.js → index.B3Q5Y9yF.js} +1 -1
- streamlit/static/static/js/index.BBpWQQgl.js +1 -0
- streamlit/static/static/js/{index.Clo5LWpc.js → index.BfZU6Baz.js} +1 -1
- streamlit/static/static/js/{index.DC-G9iGy.js → index.BoGQMxwQ.js} +84 -84
- streamlit/static/static/js/{index.COChIdSa.js → index.BoiwdkHj.js} +1 -1
- streamlit/static/static/js/index.BzrIY8ls.js +1 -0
- streamlit/static/static/js/{index.CVwvNsMT.js → index.C5JMUfSW.js} +1 -1
- streamlit/static/static/js/{index.BnRmaj0q.js → index.CVjcxZTQ.js} +1 -1
- streamlit/static/static/js/index.Ca52mv8y.js +1 -0
- streamlit/static/static/js/index.Cez--pxr.js +1 -0
- streamlit/static/static/js/{index.C-HVVl5G.js → index.CxprXN11.js} +2 -2
- streamlit/static/static/js/{index.ChEumMTh.js → index.DCNJotj9.js} +1 -1
- streamlit/static/static/js/{index.CJNnM66H.js → index.DEAvt50T.js} +1 -1
- streamlit/static/static/js/{index.Bz8bUQom.js → index.DEkQ7-4x.js} +1 -1
- streamlit/static/static/js/{index.HyA1RCUq.js → index.DKCVmING.js} +1 -1
- streamlit/static/static/js/{index.Df97B7YB.js → index.DLUxbvxL.js} +1 -1
- streamlit/static/static/js/index.DLZWj5Wx.js +1 -0
- streamlit/static/static/js/{index.Cvp6swyX.js → index.DVtEu8XG.js} +1 -1
- streamlit/static/static/js/index.DmMT9-rF.js +1 -0
- streamlit/static/static/js/{index.DPBPYkVj.js → index.Dp1D2WwI.js} +1 -1
- streamlit/static/static/js/{index.DJnKVyky.js → index.DpDZXc5A.js} +1 -1
- streamlit/static/static/js/{index.Nr-h-MEp.js → index.DrZbpcih.js} +2 -2
- streamlit/static/static/js/{index.Dw0WhCiS.js → index.DrcgL_1W.js} +1 -1
- streamlit/static/static/js/{index.Cjhlljyd.js → index.DsAgncrv.js} +1 -1
- streamlit/static/static/js/{index.PrTbO9_K.js → index.DsqZ46tn.js} +16 -16
- streamlit/static/static/js/{index.9SqbTcLN.js → index.DwhrLk1V.js} +1 -1
- streamlit/static/static/js/index.Q9qfT6Yw.js +1 -0
- streamlit/static/static/js/{index.Do_EEKkv.js → index.RIvbbwSs.js} +1 -1
- streamlit/static/static/js/{index.jtYhcA9Y.js → index.Wmp1JsUa.js} +1 -1
- streamlit/static/static/js/{index.CqzRlT_N.js → index.YXZoRre5.js} +3 -3
- streamlit/static/static/js/index.jrTYlvfq.js +3 -0
- streamlit/static/static/js/{index.BrmZ2YXw.js → index.kxnglcal.js} +1 -1
- streamlit/static/static/js/index.qDmk2AC0.js +1 -0
- streamlit/static/static/js/{index.D8rVyQy1.js → index.t--hEgTQ.js} +2 -2
- streamlit/static/static/js/{index.krYobKf-.js → index.t5u3HMw8.js} +2 -2
- streamlit/static/static/js/{index.DXtp2vWQ.js → index.yt3O_h8P.js} +1 -1
- streamlit/static/static/js/{input.dDObaqA1.js → input.DYN2hm8h.js} +1 -1
- streamlit/static/static/js/{memory.ByHTAQoD.js → memory.DcwTlUfH.js} +1 -1
- streamlit/static/static/js/{mergeWith.BZKwBIi3.js → mergeWith.C6Lut-Ce.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.xIt9oCDu.js → number-overlay-editor.hbp0nFAA.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.CWDGHg1z.js → possibleConstructorReturn.GmuwO8nJ.js} +1 -1
- streamlit/static/static/js/{sandbox.Bp7KFO4N.js → sandbox.Czx1NrMq.js} +1 -1
- streamlit/static/static/js/{textarea.BryYk9e_.js → textarea.-FtGYA3f.js} +1 -1
- streamlit/static/static/js/{timepicker.BXqQU8Wg.js → timepicker.5NDJbOBG.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.jCEZas3E.js → toConsumableArray.CdqshcAD.js} +1 -1
- streamlit/static/static/js/{uniqueId.Bo8oca1r.js → uniqueId.BwgQc4e5.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.B5KzIWBc.js → useBasicWidgetState.C-ydtpV8.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.DbufYBDh.js → useOnInputChange.o1RUPHsO.js} +1 -1
- streamlit/static/static/js/withFullScreenWrapper.CPl_bcPk.js +1 -0
- streamlit/string_util.py +1 -1
- streamlit/testing/v1/element_tree.py +14 -14
- streamlit/watcher/event_based_path_watcher.py +1 -1
- streamlit/web/server/routes.py +1 -0
- {streamlit_nightly-1.43.3.dev20250318.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/METADATA +2 -2
- {streamlit_nightly-1.43.3.dev20250318.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/RECORD +120 -120
- {streamlit_nightly-1.43.3.dev20250318.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/WHEEL +1 -1
- streamlit/static/static/css/index.Bmkmz40k.css +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.CBlXaHUd.js +0 -1
- streamlit/static/static/js/index.9un9ip3K.js +0 -3
- streamlit/static/static/js/index.B683Y0MV.js +0 -1
- streamlit/static/static/js/index.BOAw4pUA.js +0 -1
- streamlit/static/static/js/index.BYzci3kh.js +0 -1
- streamlit/static/static/js/index.BjS7LGRO.js +0 -1
- streamlit/static/static/js/index.CI-nHxA-.js +0 -1
- streamlit/static/static/js/index.CaO-RWxy.js +0 -1
- streamlit/static/static/js/index.CqnxBfXn.js +0 -1
- streamlit/static/static/js/index.DveSnEeT.js +0 -1
- streamlit/static/static/js/index.RAvbwGxj.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.BKsmWq7e.js +0 -1
- {streamlit_nightly-1.43.3.dev20250318.data → streamlit_nightly-1.43.3.dev20250320.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.43.3.dev20250318.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.43.3.dev20250318.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/top_level.txt +0 -0
streamlit/auth_util.py
CHANGED
@@ -79,7 +79,7 @@ def get_secrets_auth_section() -> AttrDict:
|
|
79
79
|
auth_section = AttrDict({})
|
80
80
|
"""Get the 'auth' section of the secrets.toml."""
|
81
81
|
if secrets_singleton.load_if_toml_exists():
|
82
|
-
auth_section = cast(AttrDict, secrets_singleton.get("auth"))
|
82
|
+
auth_section = cast("AttrDict", secrets_singleton.get("auth"))
|
83
83
|
|
84
84
|
return auth_section
|
85
85
|
|
@@ -262,7 +262,7 @@ def set_page_config(
|
|
262
262
|
msg.page_config_changed.initial_sidebar_state = pb_sidebar_state
|
263
263
|
|
264
264
|
if menu_items is not None:
|
265
|
-
lowercase_menu_items = cast(MenuItems, _lower_clean_dict_keys(menu_items))
|
265
|
+
lowercase_menu_items = cast("MenuItems", _lower_clean_dict_keys(menu_items))
|
266
266
|
validate_menu_items(lowercase_menu_items)
|
267
267
|
menu_items_proto = msg.page_config_changed.menu_items
|
268
268
|
set_menu_items_proto(lowercase_menu_items, menu_items_proto)
|
streamlit/config.py
CHANGED
@@ -318,13 +318,13 @@ def _create_theme_options(
|
|
318
318
|
f"{section}.{name}",
|
319
319
|
description=description,
|
320
320
|
default_val=default_val,
|
321
|
-
scriptable=False,
|
322
321
|
visibility=visibility,
|
322
|
+
type_=type_,
|
323
|
+
scriptable=False,
|
323
324
|
deprecated=False,
|
324
325
|
deprecation_text=None,
|
325
326
|
expiration_date=None,
|
326
327
|
replaced_by=None,
|
327
|
-
type_=type_,
|
328
328
|
sensitive=False,
|
329
329
|
)
|
330
330
|
|
@@ -1084,7 +1084,12 @@ _create_theme_options(
|
|
1084
1084
|
"linkColor",
|
1085
1085
|
categories=["theme", CustomThemeCategories.SIDEBAR],
|
1086
1086
|
description="Color used for all links.",
|
1087
|
-
|
1087
|
+
)
|
1088
|
+
|
1089
|
+
_create_theme_options(
|
1090
|
+
"codeBackgroundColor",
|
1091
|
+
categories=["theme", CustomThemeCategories.SIDEBAR],
|
1092
|
+
description="Background color used for code blocks.",
|
1088
1093
|
)
|
1089
1094
|
|
1090
1095
|
_create_theme_options(
|
@@ -1104,7 +1109,6 @@ _create_theme_options(
|
|
1104
1109
|
The font family to use for code (monospace) in the app.
|
1105
1110
|
To use a custom font, it needs to be added via [theme.fontFaces].
|
1106
1111
|
""",
|
1107
|
-
visibility="hidden",
|
1108
1112
|
)
|
1109
1113
|
|
1110
1114
|
_create_theme_options(
|
@@ -1114,7 +1118,6 @@ _create_theme_options(
|
|
1114
1118
|
The font family to use for headings in the app.
|
1115
1119
|
To use a custom font, it needs to be added via [theme.fontFaces].
|
1116
1120
|
""",
|
1117
|
-
visibility="hidden",
|
1118
1121
|
)
|
1119
1122
|
|
1120
1123
|
_create_theme_options(
|
@@ -1123,7 +1126,6 @@ _create_theme_options(
|
|
1123
1126
|
description="""
|
1124
1127
|
Configure a list of font faces that you can use for the app & code fonts.
|
1125
1128
|
""",
|
1126
|
-
visibility="hidden",
|
1127
1129
|
)
|
1128
1130
|
|
1129
1131
|
_create_theme_options(
|
@@ -1134,7 +1136,6 @@ _create_theme_options(
|
|
1134
1136
|
"none", "small", "medium", "large", "full", or the number in pixel or rem.
|
1135
1137
|
For example: "10px", "0.5rem", "1.2rem", "2rem".
|
1136
1138
|
""",
|
1137
|
-
visibility="hidden",
|
1138
1139
|
)
|
1139
1140
|
|
1140
1141
|
_create_theme_options(
|
@@ -1143,18 +1144,16 @@ _create_theme_options(
|
|
1143
1144
|
description="""
|
1144
1145
|
The color of the border around elements.
|
1145
1146
|
""",
|
1146
|
-
visibility="hidden",
|
1147
1147
|
)
|
1148
1148
|
|
1149
1149
|
_create_theme_options(
|
1150
|
-
"
|
1150
|
+
"showWidgetBorder",
|
1151
1151
|
categories=["theme", CustomThemeCategories.SIDEBAR],
|
1152
1152
|
description="""
|
1153
|
-
Whether to show a border around input
|
1153
|
+
Whether to show a border around input widgets (e.g. text_input, number_input,
|
1154
1154
|
file_uploader, etc).
|
1155
1155
|
""",
|
1156
1156
|
type_=bool,
|
1157
|
-
visibility="hidden",
|
1158
1157
|
)
|
1159
1158
|
|
1160
1159
|
_create_theme_options(
|
@@ -1165,17 +1164,15 @@ _create_theme_options(
|
|
1165
1164
|
scale of text and UI elements. The default base font size is 16.
|
1166
1165
|
""",
|
1167
1166
|
type_=int,
|
1168
|
-
visibility="hidden",
|
1169
1167
|
)
|
1170
1168
|
|
1171
1169
|
_create_theme_options(
|
1172
|
-
"
|
1170
|
+
"showSidebarBorder",
|
1173
1171
|
categories=["theme"],
|
1174
1172
|
description="""
|
1175
1173
|
Whether to show a vertical separator between the sidebar and the main content.
|
1176
1174
|
""",
|
1177
1175
|
type_=bool,
|
1178
|
-
visibility="hidden",
|
1179
1176
|
)
|
1180
1177
|
|
1181
1178
|
# Config Section: Secrets #
|
@@ -264,7 +264,7 @@ class SnowflakeConnection(BaseConnection["InternalSnowflakeConnection"]):
|
|
264
264
|
|
265
265
|
return snowflake.connector.connect(**kwargs)
|
266
266
|
except SnowflakeError as e:
|
267
|
-
if not len(st_secrets) and not
|
267
|
+
if not len(st_secrets) and not kwargs:
|
268
268
|
raise StreamlitAPIException(
|
269
269
|
"Missing Snowflake connection configuration. "
|
270
270
|
"Did you forget to set this in `secrets.toml`, a Snowflake configuration file, "
|
@@ -557,5 +557,5 @@ class SnowflakeConnection(BaseConnection["InternalSnowflakeConnection"]):
|
|
557
557
|
return get_active_session()
|
558
558
|
|
559
559
|
return cast(
|
560
|
-
Session, Session.builder.configs({"connection": self._instance}).create()
|
560
|
+
"Session", Session.builder.configs({"connection": self._instance}).create()
|
561
561
|
)
|
@@ -91,7 +91,7 @@ class SnowparkConnection(BaseConnection["Session"]):
|
|
91
91
|
if p not in conn_params:
|
92
92
|
raise StreamlitAPIException(f"Missing Snowpark connection param: {p}")
|
93
93
|
|
94
|
-
return cast(Session, Session.builder.configs(conn_params).create())
|
94
|
+
return cast("Session", Session.builder.configs(conn_params).create())
|
95
95
|
|
96
96
|
def query(
|
97
97
|
self,
|
@@ -390,7 +390,7 @@ class SQLConnection(BaseConnection["Engine"]):
|
|
390
390
|
str
|
391
391
|
The name of the driver. For example, ``"pyodbc"`` or ``"psycopg2"``.
|
392
392
|
"""
|
393
|
-
return cast(str, self._instance.driver)
|
393
|
+
return cast("str", self._instance.driver)
|
394
394
|
|
395
395
|
@property
|
396
396
|
def session(self) -> Session:
|
streamlit/connections/util.py
CHANGED
streamlit/dataframe_util.py
CHANGED
@@ -559,13 +559,13 @@ def convert_anything_to_pandas_df(
|
|
559
559
|
import pandas as pd
|
560
560
|
|
561
561
|
if isinstance(data, pd.DataFrame):
|
562
|
-
return data.copy() if ensure_copy else cast(pd.DataFrame, data)
|
562
|
+
return data.copy() if ensure_copy else cast("pd.DataFrame", data)
|
563
563
|
|
564
564
|
if isinstance(data, (pd.Series, pd.Index, pd.api.extensions.ExtensionArray)):
|
565
565
|
return pd.DataFrame(data)
|
566
566
|
|
567
567
|
if is_pandas_styler(data):
|
568
|
-
return cast(pd.DataFrame, data.data.copy() if ensure_copy else data.data)
|
568
|
+
return cast("pd.DataFrame", data.data.copy() if ensure_copy else data.data)
|
569
569
|
|
570
570
|
if isinstance(data, np.ndarray):
|
571
571
|
return (
|
@@ -589,7 +589,7 @@ def convert_anything_to_pandas_df(
|
|
589
589
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
590
590
|
"rows. Call `collect()` on the dataframe to show more."
|
591
591
|
)
|
592
|
-
return cast(pd.DataFrame, data)
|
592
|
+
return cast("pd.DataFrame", data)
|
593
593
|
|
594
594
|
if is_xarray_dataset(data):
|
595
595
|
if ensure_copy:
|
@@ -614,7 +614,7 @@ def convert_anything_to_pandas_df(
|
|
614
614
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
615
615
|
"rows. Call `compute()` on the data object to show more."
|
616
616
|
)
|
617
|
-
return cast(pd.DataFrame, data)
|
617
|
+
return cast("pd.DataFrame", data)
|
618
618
|
|
619
619
|
if is_ray_dataset(data):
|
620
620
|
data = data.limit(max_unevaluated_rows).to_pandas()
|
@@ -624,7 +624,7 @@ def convert_anything_to_pandas_df(
|
|
624
624
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
625
625
|
"rows. Call `to_pandas()` on the dataset to show more."
|
626
626
|
)
|
627
|
-
return cast(pd.DataFrame, data)
|
627
|
+
return cast("pd.DataFrame", data)
|
628
628
|
|
629
629
|
if is_modin_data_object(data):
|
630
630
|
data = data.head(max_unevaluated_rows)._to_pandas()
|
@@ -637,7 +637,7 @@ def convert_anything_to_pandas_df(
|
|
637
637
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
638
638
|
"rows. Call `_to_pandas()` on the data object to show more."
|
639
639
|
)
|
640
|
-
return cast(pd.DataFrame, data)
|
640
|
+
return cast("pd.DataFrame", data)
|
641
641
|
|
642
642
|
if is_pyspark_data_object(data):
|
643
643
|
data = data.limit(max_unevaluated_rows).toPandas()
|
@@ -646,7 +646,7 @@ def convert_anything_to_pandas_df(
|
|
646
646
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
647
647
|
"rows. Call `toPandas()` on the data object to show more."
|
648
648
|
)
|
649
|
-
return cast(pd.DataFrame, data)
|
649
|
+
return cast("pd.DataFrame", data)
|
650
650
|
|
651
651
|
if is_snowpandas_data_object(data):
|
652
652
|
data = data[:max_unevaluated_rows].to_pandas()
|
@@ -659,7 +659,7 @@ def convert_anything_to_pandas_df(
|
|
659
659
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
660
660
|
"rows. Call `to_pandas()` on the data object to show more."
|
661
661
|
)
|
662
|
-
return cast(pd.DataFrame, data)
|
662
|
+
return cast("pd.DataFrame", data)
|
663
663
|
|
664
664
|
if is_snowpark_data_object(data):
|
665
665
|
data = data.limit(max_unevaluated_rows).to_pandas()
|
@@ -668,7 +668,7 @@ def convert_anything_to_pandas_df(
|
|
668
668
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
669
669
|
"rows. Call `to_pandas()` on the data object to show more."
|
670
670
|
)
|
671
|
-
return cast(pd.DataFrame, data)
|
671
|
+
return cast("pd.DataFrame", data)
|
672
672
|
|
673
673
|
if is_duckdb_relation(data):
|
674
674
|
data = data.limit(max_unevaluated_rows).df()
|
@@ -800,7 +800,7 @@ def convert_arrow_table_to_arrow_bytes(table: pa.Table) -> bytes:
|
|
800
800
|
writer = pa.RecordBatchStreamWriter(sink, table.schema)
|
801
801
|
writer.write_table(table)
|
802
802
|
writer.close()
|
803
|
-
return cast(bytes, sink.getvalue().to_pybytes())
|
803
|
+
return cast("bytes", sink.getvalue().to_pybytes())
|
804
804
|
|
805
805
|
|
806
806
|
def convert_pandas_df_to_arrow_bytes(df: DataFrame) -> bytes:
|
@@ -951,7 +951,7 @@ def convert_anything_to_list(obj: OptionSequence[V_co]) -> list[V_co]:
|
|
951
951
|
return (
|
952
952
|
[]
|
953
953
|
if data_df.empty
|
954
|
-
else cast(list[V_co], list(data_df.iloc[:, 0].to_list()))
|
954
|
+
else cast("list[V_co]", list(data_df.iloc[:, 0].to_list()))
|
955
955
|
)
|
956
956
|
except errors.StreamlitAPIException:
|
957
957
|
# Wrap the object into a list
|
@@ -1167,7 +1167,7 @@ def determine_data_format(input_data: Any) -> DataFormat:
|
|
1167
1167
|
elif isinstance(input_data, pd.DataFrame):
|
1168
1168
|
return DataFormat.PANDAS_DATAFRAME
|
1169
1169
|
elif isinstance(input_data, np.ndarray):
|
1170
|
-
if len(cast(NumpyShape, input_data.shape)) == 1:
|
1170
|
+
if len(cast("NumpyShape", input_data.shape)) == 1:
|
1171
1171
|
# For technical reasons, we need to distinguish one
|
1172
1172
|
# one-dimensional numpy array from multidimensional ones.
|
1173
1173
|
return DataFormat.NUMPY_LIST
|
streamlit/delta_generator.py
CHANGED
@@ -538,7 +538,7 @@ class DeltaGenerator(
|
|
538
538
|
dg_type = DeltaGenerator
|
539
539
|
|
540
540
|
block_dg = cast(
|
541
|
-
DeltaGenerator,
|
541
|
+
"DeltaGenerator",
|
542
542
|
dg_type(
|
543
543
|
root_container=dg._root_container,
|
544
544
|
cursor=block_cursor,
|
@@ -566,7 +566,7 @@ class DeltaGenerator(
|
|
566
566
|
|
567
567
|
def _writes_directly_to_sidebar(dg: DeltaGenerator) -> bool:
|
568
568
|
in_sidebar = any(a._root_container == RootContainer.SIDEBAR for a in dg._ancestors)
|
569
|
-
has_container = bool(
|
569
|
+
has_container = bool(list(dg._ancestor_block_types))
|
570
570
|
return in_sidebar and not has_container
|
571
571
|
|
572
572
|
|
streamlit/deprecation_util.py
CHANGED
@@ -105,7 +105,7 @@ def deprecate_func_name(
|
|
105
105
|
# Update the wrapped func's name & docstring so st.help does the right thing
|
106
106
|
wrapped_func.__name__ = old_name
|
107
107
|
wrapped_func.__doc__ = func.__doc__
|
108
|
-
return cast(TFunc, wrapped_func)
|
108
|
+
return cast("TFunc", wrapped_func)
|
109
109
|
|
110
110
|
|
111
111
|
def deprecate_obj_name(
|
@@ -206,4 +206,4 @@ def _create_deprecated_obj_wrapper(obj: TObj, show_warning: Callable[[], Any]) -
|
|
206
206
|
|
207
207
|
return proxy
|
208
208
|
|
209
|
-
return cast(TObj, Wrapper())
|
209
|
+
return cast("TObj", Wrapper())
|
streamlit/elements/arrow.py
CHANGED
@@ -174,7 +174,7 @@ class DataframeSelectionSerde:
|
|
174
174
|
if "selection" not in selection_state:
|
175
175
|
selection_state = empty_selection_state
|
176
176
|
|
177
|
-
return cast(DataframeState, AttributeDictionary(selection_state))
|
177
|
+
return cast("DataframeState", AttributeDictionary(selection_state))
|
178
178
|
|
179
179
|
def serialize(self, editing_state: DataframeState) -> str:
|
180
180
|
return json.dumps(editing_state, default=str)
|
@@ -549,7 +549,7 @@ class ArrowMixin:
|
|
549
549
|
check_widget_policies(
|
550
550
|
self.dg,
|
551
551
|
key,
|
552
|
-
on_change=cast(WidgetCallback, on_select) if is_callback else None,
|
552
|
+
on_change=cast("WidgetCallback", on_select) if is_callback else None,
|
553
553
|
default_value=None,
|
554
554
|
writes_allowed=False,
|
555
555
|
enable_check_callback_rules=is_callback,
|
@@ -644,7 +644,7 @@ class ArrowMixin:
|
|
644
644
|
value_type="string_value",
|
645
645
|
)
|
646
646
|
self.dg._enqueue("arrow_data_frame", proto)
|
647
|
-
return cast(DataframeState, widget_state.value)
|
647
|
+
return cast("DataframeState", widget_state.value)
|
648
648
|
else:
|
649
649
|
return self.dg._enqueue("arrow_data_frame", proto)
|
650
650
|
|
@@ -251,7 +251,7 @@ class PydeckSelectionSerde:
|
|
251
251
|
if "selection" not in selection_state:
|
252
252
|
selection_state = empty_selection_state
|
253
253
|
|
254
|
-
return cast(PydeckState, AttributeDictionary(selection_state))
|
254
|
+
return cast("PydeckState", AttributeDictionary(selection_state))
|
255
255
|
|
256
256
|
def serialize(self, selection_state: PydeckState) -> str:
|
257
257
|
return json.dumps(selection_state, default=str)
|
@@ -488,7 +488,7 @@ class PydeckMixin:
|
|
488
488
|
check_widget_policies(
|
489
489
|
self.dg,
|
490
490
|
key,
|
491
|
-
on_change=cast(WidgetCallback, on_select) if is_callback else None,
|
491
|
+
on_change=cast("WidgetCallback", on_select) if is_callback else None,
|
492
492
|
default_value=None,
|
493
493
|
writes_allowed=False,
|
494
494
|
enable_check_callback_rules=is_callback,
|
@@ -518,7 +518,7 @@ class PydeckMixin:
|
|
518
518
|
|
519
519
|
self.dg._enqueue("deck_gl_json_chart", pydeck_proto)
|
520
520
|
|
521
|
-
return cast(PydeckState, widget_state.value)
|
521
|
+
return cast("PydeckState", widget_state.value)
|
522
522
|
|
523
523
|
return self.dg._enqueue("deck_gl_json_chart", pydeck_proto)
|
524
524
|
|
@@ -541,6 +541,6 @@ def _get_pydeck_tooltip(pydeck_obj: Deck | None) -> dict[str, str] | None:
|
|
541
541
|
# For details, see: https://github.com/visgl/deck.gl/pull/7125/files
|
542
542
|
tooltip = getattr(pydeck_obj, "_tooltip", None)
|
543
543
|
if tooltip is not None and isinstance(tooltip, dict):
|
544
|
-
return cast(dict[str, str], tooltip)
|
544
|
+
return cast("dict[str, str]", tooltip)
|
545
545
|
|
546
546
|
return None
|
@@ -102,7 +102,7 @@ def _dialog_decorator(
|
|
102
102
|
# the fragment decorator has multiple return types so that you can pass
|
103
103
|
# arguments to it. Here we know the return type, so we cast
|
104
104
|
fragmented_dialog_content = cast(
|
105
|
-
Callable[[], None],
|
105
|
+
"Callable[[], None]",
|
106
106
|
_fragment(
|
107
107
|
dialog_content, additional_hash_info=non_optional_func.__qualname__
|
108
108
|
),
|
@@ -112,7 +112,7 @@ def _dialog_decorator(
|
|
112
112
|
fragmented_dialog_content()
|
113
113
|
return None
|
114
114
|
|
115
|
-
return cast(F, wrap)
|
115
|
+
return cast("F", wrap)
|
116
116
|
|
117
117
|
|
118
118
|
@overload
|
streamlit/elements/heading.py
CHANGED
@@ -261,7 +261,7 @@ class HeadingMixin:
|
|
261
261
|
"rainbow",
|
262
262
|
]
|
263
263
|
if divider in valid_colors:
|
264
|
-
return cast(str, divider)
|
264
|
+
return cast("str", divider)
|
265
265
|
else:
|
266
266
|
raise StreamlitAPIException(
|
267
267
|
f"Divider parameter has invalid value: `{divider}`. Please choose from: {', '.join(valid_colors)}."
|
streamlit/elements/html.py
CHANGED
@@ -75,16 +75,16 @@ class HtmlMixin:
|
|
75
75
|
|
76
76
|
# If body supports _repr_html_, use that.
|
77
77
|
if has_callable_attr(body, "_repr_html_"):
|
78
|
-
html_proto.body = cast(SupportsReprHtml, body)._repr_html_()
|
78
|
+
html_proto.body = cast("SupportsReprHtml", body)._repr_html_()
|
79
79
|
|
80
80
|
# Check if the body is a file path. May include filesystem lookup.
|
81
81
|
elif isinstance(body, Path) or _is_file(body):
|
82
|
-
with open(cast(str, body), encoding="utf-8") as f:
|
82
|
+
with open(cast("str", body), encoding="utf-8") as f:
|
83
83
|
html_proto.body = f.read()
|
84
84
|
|
85
85
|
# OK, let's just try converting to string and hope for the best.
|
86
86
|
else:
|
87
|
-
html_proto.body = clean_text(cast(SupportsStr, body))
|
87
|
+
html_proto.body = clean_text(cast("SupportsStr", body))
|
88
88
|
|
89
89
|
return self.dg._enqueue("html", html_proto)
|
90
90
|
|
@@ -16,7 +16,6 @@
|
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
19
|
-
from collections.abc import Collection, Hashable, Sequence
|
20
19
|
from dataclasses import dataclass
|
21
20
|
from datetime import date
|
22
21
|
from enum import Enum
|
@@ -42,6 +41,8 @@ from streamlit.elements.lib.color_util import (
|
|
42
41
|
from streamlit.errors import Error, StreamlitAPIException
|
43
42
|
|
44
43
|
if TYPE_CHECKING:
|
44
|
+
from collections.abc import Collection, Hashable, Sequence
|
45
|
+
|
45
46
|
import altair as alt
|
46
47
|
import pandas as pd
|
47
48
|
|
@@ -287,7 +288,7 @@ def _add_improved_hover_tooltips(
|
|
287
288
|
)
|
288
289
|
)
|
289
290
|
|
290
|
-
return cast(alt.LayerChart, layer_chart)
|
291
|
+
return cast("alt.LayerChart", layer_chart)
|
291
292
|
|
292
293
|
|
293
294
|
def prep_chart_data_for_add_rows(
|
@@ -301,7 +302,7 @@ def prep_chart_data_for_add_rows(
|
|
301
302
|
"""
|
302
303
|
import pandas as pd
|
303
304
|
|
304
|
-
df = cast(pd.DataFrame, dataframe_util.convert_anything_to_pandas_df(data))
|
305
|
+
df = cast("pd.DataFrame", dataframe_util.convert_anything_to_pandas_df(data))
|
305
306
|
|
306
307
|
# Make range indices start at last_index.
|
307
308
|
if isinstance(df.index, pd.RangeIndex):
|
@@ -440,7 +441,7 @@ def _prep_data(
|
|
440
441
|
def _last_index_for_melted_dataframes(
|
441
442
|
data: pd.DataFrame,
|
442
443
|
) -> Hashable | None:
|
443
|
-
return cast(Hashable, data.index[-1]) if data.index.size > 0 else None
|
444
|
+
return cast("Hashable", data.index[-1]) if data.index.size > 0 else None
|
444
445
|
|
445
446
|
|
446
447
|
def _is_date_column(df: pd.DataFrame, name: str | None) -> bool:
|
@@ -939,21 +940,21 @@ def _get_color_encoding(
|
|
939
940
|
# color column (be they manual or auto-assigned due to melting)
|
940
941
|
if has_color_value:
|
941
942
|
# If the color value is color-like, return that.
|
942
|
-
if is_color_like(cast(Any, color_value)):
|
943
|
+
if is_color_like(cast("Any", color_value)):
|
943
944
|
if len(y_column_list) != 1:
|
944
945
|
raise StreamlitColorLengthError([color_value], y_column_list)
|
945
946
|
|
946
|
-
return alt.ColorValue(to_css_color(cast(Any, color_value)))
|
947
|
+
return alt.ColorValue(to_css_color(cast("Any", color_value)))
|
947
948
|
|
948
949
|
# If the color value is a list of colors of approriate length, return that.
|
949
950
|
elif isinstance(color_value, (list, tuple)):
|
950
|
-
color_values = cast(Collection[Color], color_value)
|
951
|
+
color_values = cast("Collection[Color]", color_value)
|
951
952
|
|
952
953
|
if len(color_values) != len(y_column_list):
|
953
954
|
raise StreamlitColorLengthError(color_values, y_column_list)
|
954
955
|
|
955
956
|
if len(color_values) == 1:
|
956
|
-
return alt.ColorValue(to_css_color(cast(Any, color_value[0])))
|
957
|
+
return alt.ColorValue(to_css_color(cast("Any", color_value[0])))
|
957
958
|
else:
|
958
959
|
return alt.Color(
|
959
960
|
field=color_column
|
@@ -64,7 +64,7 @@ def to_int_color_tuple(color: MaybeColor) -> IntColorTuple:
|
|
64
64
|
rgb_formatter=_int_formatter,
|
65
65
|
alpha_formatter=_int_formatter,
|
66
66
|
)
|
67
|
-
return cast(IntColorTuple, color_tuple)
|
67
|
+
return cast("IntColorTuple", color_tuple)
|
68
68
|
|
69
69
|
|
70
70
|
def to_css_color(color: MaybeColor) -> Color:
|
@@ -76,15 +76,15 @@ def to_css_color(color: MaybeColor) -> Color:
|
|
76
76
|
See tests for more info.
|
77
77
|
"""
|
78
78
|
if is_css_color_like(color):
|
79
|
-
return cast(Color, color)
|
79
|
+
return cast("Color", color)
|
80
80
|
|
81
81
|
if is_color_tuple_like(color):
|
82
|
-
ctuple = cast(ColorTuple, color)
|
82
|
+
ctuple = cast("ColorTuple", color)
|
83
83
|
ctuple = _normalize_tuple(ctuple, _int_formatter, _float_formatter)
|
84
84
|
if len(ctuple) == 3:
|
85
85
|
return f"rgb({ctuple[0]}, {ctuple[1]}, {ctuple[2]})"
|
86
86
|
elif len(ctuple) == 4:
|
87
|
-
c4tuple = cast(MixedRGBAColorTuple, ctuple)
|
87
|
+
c4tuple = cast("MixedRGBAColorTuple", ctuple)
|
88
88
|
return f"rgba({c4tuple[0]}, {c4tuple[1]}, {c4tuple[2]}, {c4tuple[3]})"
|
89
89
|
|
90
90
|
raise StreamlitInvalidColorError(color)
|
@@ -168,7 +168,7 @@ def _to_color_tuple(
|
|
168
168
|
"""
|
169
169
|
if is_hex_color_like(color):
|
170
170
|
hex_len = len(color)
|
171
|
-
color_hex = cast(str, color)
|
171
|
+
color_hex = cast("str", color)
|
172
172
|
|
173
173
|
if hex_len == 4:
|
174
174
|
r = 2 * color_hex[1]
|
@@ -199,7 +199,7 @@ def _to_color_tuple(
|
|
199
199
|
raise StreamlitInvalidColorError(color) from ex
|
200
200
|
|
201
201
|
if is_color_tuple_like(color):
|
202
|
-
color_tuple = cast(ColorTuple, color)
|
202
|
+
color_tuple = cast("ColorTuple", color)
|
203
203
|
return _normalize_tuple(color_tuple, rgb_formatter, alpha_formatter)
|
204
204
|
|
205
205
|
raise StreamlitInvalidColorError(color)
|
@@ -225,7 +225,7 @@ def _normalize_tuple(
|
|
225
225
|
return r, g, b
|
226
226
|
|
227
227
|
elif len(color) == 4:
|
228
|
-
color_4tuple = cast(Color4Tuple, color)
|
228
|
+
color_4tuple = cast("Color4Tuple", color)
|
229
229
|
r = rgb_formatter(color_4tuple[0], color_4tuple)
|
230
230
|
g = rgb_formatter(color_4tuple[1], color_4tuple)
|
231
231
|
b = rgb_formatter(color_4tuple[2], color_4tuple)
|
streamlit/elements/lib/dialog.py
CHANGED
@@ -92,7 +92,7 @@ class Dialog(DeltaGenerator):
|
|
92
92
|
delta_path: list[int] = (
|
93
93
|
parent._active_dg._cursor.delta_path if parent._active_dg._cursor else []
|
94
94
|
)
|
95
|
-
dialog = cast(Dialog, parent._block(block_proto=block_proto, dg_type=Dialog))
|
95
|
+
dialog = cast("Dialog", parent._block(block_proto=block_proto, dg_type=Dialog))
|
96
96
|
|
97
97
|
dialog._delta_path = delta_path
|
98
98
|
dialog._current_proto = block_proto
|
@@ -27,7 +27,6 @@ from typing_extensions import TypeAlias
|
|
27
27
|
from streamlit import runtime, url_util
|
28
28
|
from streamlit.errors import StreamlitAPIException
|
29
29
|
from streamlit.runtime import caching
|
30
|
-
from streamlit.type_util import NumpyShape
|
31
30
|
|
32
31
|
if TYPE_CHECKING:
|
33
32
|
from typing import Any
|
@@ -36,6 +35,7 @@ if TYPE_CHECKING:
|
|
36
35
|
from PIL import GifImagePlugin, Image, ImageFile
|
37
36
|
|
38
37
|
from streamlit.proto.Image_pb2 import ImageList as ImageListProto
|
38
|
+
from streamlit.type_util import NumpyShape
|
39
39
|
|
40
40
|
PILImage: TypeAlias = Union[
|
41
41
|
"ImageFile.ImageFile", "Image.Image", "GifImagePlugin.GifImageFile"
|
@@ -99,7 +99,7 @@ def _validate_image_format_string(
|
|
99
99
|
"""
|
100
100
|
format = format.upper()
|
101
101
|
if format in {"JPEG", "PNG"}:
|
102
|
-
return cast(ImageFormat, format)
|
102
|
+
return cast("ImageFormat", format)
|
103
103
|
|
104
104
|
# We are forgiving on the spelling of JPEG
|
105
105
|
if format == "JPG":
|
@@ -315,7 +315,7 @@ def image_to_url(
|
|
315
315
|
image = _clip_image(_verify_np_shape(image), clamp)
|
316
316
|
|
317
317
|
if channels == "BGR":
|
318
|
-
if len(cast(NumpyShape, image.shape)) == 3:
|
318
|
+
if len(cast("NumpyShape", image.shape)) == 3:
|
319
319
|
image = image[:, :, [2, 1, 0]]
|
320
320
|
else:
|
321
321
|
raise StreamlitAPIException(
|
@@ -396,22 +396,24 @@ def marshall_images(
|
|
396
396
|
"""
|
397
397
|
import numpy as np
|
398
398
|
|
399
|
-
channels = cast(Channels, channels.upper())
|
399
|
+
channels = cast("Channels", channels.upper())
|
400
400
|
|
401
401
|
# Turn single image and caption into one element list.
|
402
402
|
images: Sequence[AtomicImage]
|
403
403
|
if isinstance(image, (list, set, tuple)):
|
404
404
|
images = list(image)
|
405
|
-
elif isinstance(image, np.ndarray) and len(cast(NumpyShape, image.shape)) == 4:
|
405
|
+
elif isinstance(image, np.ndarray) and len(cast("NumpyShape", image.shape)) == 4:
|
406
406
|
images = _4d_to_list_3d(image)
|
407
407
|
else:
|
408
|
-
images = cast(Sequence[AtomicImage], [image])
|
408
|
+
images = cast("Sequence[AtomicImage]", [image])
|
409
409
|
|
410
410
|
if isinstance(caption, list):
|
411
411
|
captions: Sequence[str | None] = caption
|
412
412
|
elif isinstance(caption, str):
|
413
413
|
captions = [caption]
|
414
|
-
elif
|
414
|
+
elif (
|
415
|
+
isinstance(caption, np.ndarray) and len(cast("NumpyShape", caption.shape)) == 1
|
416
|
+
):
|
415
417
|
captions = caption.tolist()
|
416
418
|
elif caption is None:
|
417
419
|
captions = [None] * len(images)
|
streamlit/elements/media.py
CHANGED
@@ -32,7 +32,6 @@ from streamlit.proto.Video_pb2 import Video as VideoProto
|
|
32
32
|
from streamlit.runtime import caching
|
33
33
|
from streamlit.runtime.metrics_util import gather_metrics
|
34
34
|
from streamlit.time_util import time_to_seconds
|
35
|
-
from streamlit.type_util import NumpyShape
|
36
35
|
|
37
36
|
if TYPE_CHECKING:
|
38
37
|
from typing import Any
|
@@ -40,6 +39,7 @@ if TYPE_CHECKING:
|
|
40
39
|
from numpy import typing as npt
|
41
40
|
|
42
41
|
from streamlit.delta_generator import DeltaGenerator
|
42
|
+
from streamlit.type_util import NumpyShape
|
43
43
|
|
44
44
|
|
45
45
|
MediaData: TypeAlias = Union[
|
@@ -666,7 +666,7 @@ def _validate_and_normalize(data: npt.NDArray[Any]) -> tuple[bytes, int]:
|
|
666
666
|
|
667
667
|
transformed_data: npt.NDArray[Any] = np.array(data, dtype=float)
|
668
668
|
|
669
|
-
if len(cast(NumpyShape, transformed_data.shape)) == 1:
|
669
|
+
if len(cast("NumpyShape", transformed_data.shape)) == 1:
|
670
670
|
nchan = 1
|
671
671
|
elif len(transformed_data.shape) == 2:
|
672
672
|
# In wave files,channels are interleaved. E.g.,
|
streamlit/elements/metric.py
CHANGED
@@ -196,7 +196,7 @@ class MetricMixin:
|
|
196
196
|
metric_proto.help = dedent(help)
|
197
197
|
|
198
198
|
color_and_direction = _determine_delta_color_and_direction(
|
199
|
-
cast(DeltaColor, clean_text(delta_color)), delta
|
199
|
+
cast("DeltaColor", clean_text(delta_color)), delta
|
200
200
|
)
|
201
201
|
metric_proto.color = color_and_direction.color
|
202
202
|
metric_proto.direction = color_and_direction.direction
|