streamlit-nightly 1.43.3.dev20250317__py3-none-any.whl → 1.43.3.dev20250319__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 +141 -45
- streamlit/config_option.py +4 -1
- streamlit/config_util.py +1 -1
- 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/material_icon_names.py +1 -1
- streamlit/proto/NewSession_pb2.py +16 -16
- streamlit/proto/NewSession_pb2.pyi +22 -11
- streamlit/runtime/app_session.py +10 -7
- 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 +2 -2
- 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 +2 -2
- streamlit/static/static/css/{index.DQZt7VFg.css → index.BOl9eq08.css} +1 -1
- streamlit/static/static/css/index.C5t3M85E.css +1 -0
- streamlit/static/static/js/{FileDownload.esm.DPWNg8L0.js → FileDownload.esm.Dz4lqu2t.js} +1 -1
- streamlit/static/static/js/{FileHelper.Be9l1B23.js → FileHelper.B_o0E5mY.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.Ck_v4Tgg.js → FormClearHelper.B5ARMjis.js} +1 -1
- streamlit/static/static/js/{Hooks.B0Mdn8OE.js → Hooks.gYcZ3nte.js} +1 -1
- streamlit/static/static/js/{InputInstructions.DEfhAJgc.js → InputInstructions.K_vAW_MG.js} +1 -1
- streamlit/static/static/js/{ProgressBar.D34ZfmP5.js → ProgressBar.DOjGuUdH.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.D7rG7dkm.js → RenderInPortalIfExists.C4HdMGrO.js} +1 -1
- streamlit/static/static/js/{Toolbar.BKx7cxA3.js → Toolbar.BZqFuVCo.js} +1 -1
- streamlit/static/static/js/{base-input.D400PpZv.js → base-input.DtNLPEYc.js} +1 -1
- streamlit/static/static/js/{checkbox.T2_9UyBa.js → checkbox.De5lDKlG.js} +1 -1
- streamlit/static/static/js/{createSuper.B6r1ToQR.js → createSuper.DUfdjejQ.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.ByFOuSZw.js +1 -0
- streamlit/static/static/js/{downloader.CfgCJjqI.js → downloader.Bndt7ayy.js} +1 -1
- streamlit/static/static/js/{es6.BIR4_s9Q.js → es6.B9axslaM.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.BvHB3v_q.js → iframeResizer.contentWindow.C19fTVqS.js} +1 -1
- streamlit/static/static/js/{index.P1KdGEyu.js → index.3vPW8lC3.js} +1 -1
- streamlit/static/static/js/{index.-19Q4tZa.js → index.8fEQ0naY.js} +1 -1
- streamlit/static/static/js/{index.ChU_mie6.js → index.B9N7bKyh.js} +1 -1
- streamlit/static/static/js/{index.4XxlReRC.js → index.BBkaxxeO.js} +1 -1
- streamlit/static/static/js/index.BDWxQ6IH.js +3 -0
- streamlit/static/static/js/{index.CY8FtTk0.js → index.BELm1MW6.js} +1 -1
- streamlit/static/static/js/{index.B6BwNYBs.js → index.BKE695Zg.js} +1 -1
- streamlit/static/static/js/{index.BlTWh14x.js → index.BKhwcUMH.js} +83 -83
- streamlit/static/static/js/index.BOsCHoek.js +1 -0
- streamlit/static/static/js/{index.CPHXX3ut.js → index.BQkmoKYZ.js} +1 -1
- streamlit/static/static/js/{index.1Y_wlVII.js → index.BRjv0YAi.js} +1 -1
- streamlit/static/static/js/index.BTbDncVq.js +1 -0
- streamlit/static/static/js/{index.wuPpurow.js → index.BVKRKiWg.js} +1 -1
- streamlit/static/static/js/{index.B8cYOVy0.js → index.Bbd47eDn.js} +1 -1
- streamlit/static/static/js/index.Bk2R3MJ7.js +1 -0
- streamlit/static/static/js/{index.BsoT67Bp.js → index.BoIgF6Mf.js} +2 -2
- streamlit/static/static/js/{index.CxgOTC1d.js → index.BpkIFU8i.js} +1 -1
- streamlit/static/static/js/{index.BvRYYdLA.js → index.BrZWnIcP.js} +1 -1
- streamlit/static/static/js/index.Bu7fiR4T.js +1 -0
- streamlit/static/static/js/{index.mDzBI6l2.js → index.C4zUVQy-.js} +1 -1
- streamlit/static/static/js/index.CBtAFng_.js +1 -0
- streamlit/static/static/js/{index.D3XyyrNG.js → index.CGzFdF4L.js} +2 -2
- streamlit/static/static/js/{index.B1y58sqw.js → index.CKmyhCjm.js} +1 -1
- streamlit/static/static/js/index.CVbLNEv4.js +1 -0
- streamlit/static/static/js/{index.CW3wpu7l.js → index.CYG25qUi.js} +1 -1
- streamlit/static/static/js/{index.M8jMYQHQ.js → index.DCgNoHge.js} +3 -3
- streamlit/static/static/js/{index.Bw2C-uyr.js → index.DJzV_Hd9.js} +1 -1
- streamlit/static/static/js/{index.DdaG6BEp.js → index.DQ8O6p2Z.js} +1 -1
- streamlit/static/static/js/{index.D7KT3HOJ.js → index.DWQ-qPH7.js} +1 -1
- streamlit/static/static/js/{index.BZJaY1ZU.js → index.DxsZ6SOh.js} +1 -1
- streamlit/static/static/js/index.K2n8XAB3.js +2 -0
- streamlit/static/static/js/{index.D7j_uG-4.js → index.KmpTf7BC.js} +16 -16
- streamlit/static/static/js/{index.2z1MQMgc.js → index.TIHw6394.js} +1 -1
- streamlit/static/static/js/{index.BebPGQSk.js → index.TXEfAqTZ.js} +1 -1
- streamlit/static/static/js/index.bco4avsR.js +1 -0
- streamlit/static/static/js/{index.C01swFeE.js → index.cHVEPjHw.js} +2 -2
- streamlit/static/static/js/index.xvt4PCc-.js +1 -0
- streamlit/static/static/js/{input.BjUJQgVM.js → input.5dHsg5IP.js} +1 -1
- streamlit/static/static/js/{memory.7TMii04U.js → memory.7AvKwFql.js} +1 -1
- streamlit/static/static/js/{mergeWith.BXLP9sI5.js → mergeWith.Bz2fCjZ-.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.C2Z8Sd28.js → number-overlay-editor.BzFQCoPo.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.3LXCoGeT.js → possibleConstructorReturn.BWYpSIhJ.js} +1 -1
- streamlit/static/static/js/{sandbox.BRs-5jl_.js → sandbox.DDDzfccc.js} +1 -1
- streamlit/static/static/js/{textarea.DT8T2CKm.js → textarea.UlZOYsGE.js} +1 -1
- streamlit/static/static/js/{timepicker.BQDylQL_.js → timepicker.C8uTDs22.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.C9LiuPCd.js → toConsumableArray.CdG0Nv6r.js} +1 -1
- streamlit/static/static/js/{uniqueId.CVZfBH3U.js → uniqueId.hWzaDSRc.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.DgSV341D.js → useBasicWidgetState.CtYBARrn.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.D1W4Nc13.js → useOnInputChange.Cpz9bdhf.js} +1 -1
- streamlit/static/static/js/withFullScreenWrapper.BcDfXDtz.js +1 -0
- streamlit/static/static/media/MaterialSymbols-Rounded.BFCIvovZ.woff2 +0 -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.dev20250317.dist-info → streamlit_nightly-1.43.3.dev20250319.dist-info}/METADATA +2 -2
- {streamlit_nightly-1.43.3.dev20250317.dist-info → streamlit_nightly-1.43.3.dev20250319.dist-info}/RECORD +124 -124
- {streamlit_nightly-1.43.3.dev20250317.dist-info → streamlit_nightly-1.43.3.dev20250319.dist-info}/WHEEL +1 -1
- streamlit/static/static/css/index.Bmkmz40k.css +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.CGbd5q6g.js +0 -1
- streamlit/static/static/js/index.B5Gc6Qwv.js +0 -1
- streamlit/static/static/js/index.BD1Jat0A.js +0 -1
- streamlit/static/static/js/index.By9mG2hj.js +0 -1
- streamlit/static/static/js/index.C5wG0y4e.js +0 -3
- streamlit/static/static/js/index.CWQVC9i9.js +0 -1
- streamlit/static/static/js/index.CzCK3xQd.js +0 -1
- streamlit/static/static/js/index.DHk_4dX7.js +0 -2
- streamlit/static/static/js/index.DgjRgqmt.js +0 -1
- streamlit/static/static/js/index.Dl7G-PpD.js +0 -1
- streamlit/static/static/js/index.YQ7W-YC2.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.DIGqD0pT.js +0 -1
- streamlit/static/static/media/MaterialSymbols-Rounded.CRt5Q-14.woff2 +0 -0
- {streamlit_nightly-1.43.3.dev20250317.data → streamlit_nightly-1.43.3.dev20250319.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.43.3.dev20250317.dist-info → streamlit_nightly-1.43.3.dev20250319.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.43.3.dev20250317.dist-info → streamlit_nightly-1.43.3.dev20250319.dist-info}/top_level.txt +0 -0
@@ -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
|
@@ -227,13 +227,13 @@ class PlotlyChartSelectionSerde:
|
|
227
227
|
selection_state = (
|
228
228
|
empty_selection_state
|
229
229
|
if ui_value is None
|
230
|
-
else cast(PlotlyState, AttributeDictionary(json.loads(ui_value)))
|
230
|
+
else cast("PlotlyState", AttributeDictionary(json.loads(ui_value)))
|
231
231
|
)
|
232
232
|
|
233
233
|
if "selection" not in selection_state:
|
234
234
|
selection_state = empty_selection_state
|
235
235
|
|
236
|
-
return cast(PlotlyState, AttributeDictionary(selection_state))
|
236
|
+
return cast("PlotlyState", AttributeDictionary(selection_state))
|
237
237
|
|
238
238
|
def serialize(self, selection_state: PlotlyState) -> str:
|
239
239
|
return json.dumps(selection_state, default=str)
|
@@ -474,7 +474,7 @@ class PlotlyMixin:
|
|
474
474
|
check_widget_policies(
|
475
475
|
self.dg,
|
476
476
|
key,
|
477
|
-
on_change=cast(WidgetCallback, on_select) if is_callback else None,
|
477
|
+
on_change=cast("WidgetCallback", on_select) if is_callback else None,
|
478
478
|
default_value=None,
|
479
479
|
writes_allowed=False,
|
480
480
|
enable_check_callback_rules=is_callback,
|
@@ -536,7 +536,7 @@ class PlotlyMixin:
|
|
536
536
|
)
|
537
537
|
|
538
538
|
self.dg._enqueue("plotly_chart", plotly_chart_proto)
|
539
|
-
return cast(PlotlyState, widget_state.value)
|
539
|
+
return cast("PlotlyState", widget_state.value)
|
540
540
|
else:
|
541
541
|
return self.dg._enqueue("plotly_chart", plotly_chart_proto)
|
542
542
|
|
@@ -238,13 +238,13 @@ class VegaLiteStateSerde:
|
|
238
238
|
selection_state = (
|
239
239
|
empty_selection_state
|
240
240
|
if ui_value is None
|
241
|
-
else cast(VegaLiteState, AttributeDictionary(json.loads(ui_value)))
|
241
|
+
else cast("VegaLiteState", AttributeDictionary(json.loads(ui_value)))
|
242
242
|
)
|
243
243
|
|
244
244
|
if "selection" not in selection_state:
|
245
245
|
selection_state = empty_selection_state
|
246
246
|
|
247
|
-
return cast(VegaLiteState, AttributeDictionary(selection_state))
|
247
|
+
return cast("VegaLiteState", AttributeDictionary(selection_state))
|
248
248
|
|
249
249
|
def serialize(self, selection_state: VegaLiteState) -> str:
|
250
250
|
return json.dumps(selection_state, default=str)
|
@@ -255,7 +255,7 @@ def _prepare_vega_lite_spec(
|
|
255
255
|
use_container_width: bool,
|
256
256
|
**kwargs,
|
257
257
|
) -> VegaLiteSpec:
|
258
|
-
if
|
258
|
+
if kwargs:
|
259
259
|
# Support passing in kwargs. Example:
|
260
260
|
# marshall(proto, {foo: 'bar'}, baz='boz')
|
261
261
|
# Merge spec with unflattened kwargs, where kwargs take precedence.
|
@@ -1884,7 +1884,7 @@ class VegaChartsMixin:
|
|
1884
1884
|
check_widget_policies(
|
1885
1885
|
self.dg,
|
1886
1886
|
key,
|
1887
|
-
on_change=cast(WidgetCallback, on_select) if is_callback else None,
|
1887
|
+
on_change=cast("WidgetCallback", on_select) if is_callback else None,
|
1888
1888
|
default_value=None,
|
1889
1889
|
writes_allowed=False,
|
1890
1890
|
enable_check_callback_rules=is_callback,
|
@@ -1970,7 +1970,7 @@ class VegaChartsMixin:
|
|
1970
1970
|
vega_lite_proto,
|
1971
1971
|
add_rows_metadata=add_rows_metadata,
|
1972
1972
|
)
|
1973
|
-
return cast(VegaLiteState, widget_state.value)
|
1973
|
+
return cast("VegaLiteState", widget_state.value)
|
1974
1974
|
# If its not used with selections activated, just return
|
1975
1975
|
# the delta generator related to this element.
|
1976
1976
|
return self.dg._enqueue(
|
@@ -149,7 +149,7 @@ class SingleOrMultiSelectSerde(Generic[T]):
|
|
149
149
|
)
|
150
150
|
|
151
151
|
def serialize(self, value: T | list[T] | None) -> list[int]:
|
152
|
-
return self.serde.serialize(cast(Any, value))
|
152
|
+
return self.serde.serialize(cast("Any", value))
|
153
153
|
|
154
154
|
def deserialize(
|
155
155
|
self, ui_value: list[int] | None, widget_id: str = ""
|
@@ -14,7 +14,6 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from collections.abc import Sequence
|
18
17
|
from dataclasses import dataclass, field
|
19
18
|
from textwrap import dedent
|
20
19
|
from typing import TYPE_CHECKING, Any, Callable, Generic, cast
|
@@ -52,6 +51,8 @@ from streamlit.type_util import (
|
|
52
51
|
)
|
53
52
|
|
54
53
|
if TYPE_CHECKING:
|
54
|
+
from collections.abc import Sequence
|
55
|
+
|
55
56
|
from streamlit.dataframe_util import OptionSequence
|
56
57
|
from streamlit.delta_generator import DeltaGenerator
|
57
58
|
from streamlit.runtime.state import (
|
@@ -86,7 +87,7 @@ def _get_default_count(default: Sequence[Any] | Any | None) -> int:
|
|
86
87
|
return 0
|
87
88
|
if not is_iterable(default):
|
88
89
|
return 1
|
89
|
-
return len(cast(Sequence[Any], default))
|
90
|
+
return len(cast("Sequence[Any]", default))
|
90
91
|
|
91
92
|
|
92
93
|
def _check_max_selections(
|
@@ -56,15 +56,13 @@ from streamlit.runtime.state import (
|
|
56
56
|
WidgetKwargs,
|
57
57
|
register_widget,
|
58
58
|
)
|
59
|
-
from streamlit.runtime.state.common import (
|
60
|
-
RegisterWidgetResult,
|
61
|
-
)
|
62
59
|
from streamlit.type_util import T, check_python_comparable
|
63
60
|
|
64
61
|
if TYPE_CHECKING:
|
65
62
|
from collections.abc import Sequence
|
66
63
|
|
67
64
|
from streamlit.delta_generator import DeltaGenerator
|
65
|
+
from streamlit.runtime.state.common import RegisterWidgetResult
|
68
66
|
|
69
67
|
|
70
68
|
def _is_range_value(value: T | Sequence[T]) -> TypeGuard[Sequence[T]]:
|
@@ -91,7 +89,7 @@ class SelectSliderSerde(Generic[T]):
|
|
91
89
|
|
92
90
|
# The widget always returns floats, so convert to ints before indexing
|
93
91
|
return_value: tuple[T, T] = cast(
|
94
|
-
tuple[T, T],
|
92
|
+
"tuple[T, T]",
|
95
93
|
tuple(self.options[int(x)] for x in ui_value),
|
96
94
|
)
|
97
95
|
|
@@ -416,7 +414,7 @@ class SelectSliderMixin:
|
|
416
414
|
)
|
417
415
|
if isinstance(widget_state.value, tuple):
|
418
416
|
widget_state = maybe_coerce_enum_sequence(
|
419
|
-
cast(RegisterWidgetResult[tuple[T, T]], widget_state), options, opt
|
417
|
+
cast("RegisterWidgetResult[tuple[T, T]]", widget_state), options, opt
|
420
418
|
)
|
421
419
|
else:
|
422
420
|
widget_state = maybe_coerce_enum(widget_state, options, opt)
|
@@ -693,7 +693,7 @@ class SliderMixin:
|
|
693
693
|
) and max_value - min_value < timedelta(days=1):
|
694
694
|
step = timedelta(minutes=15)
|
695
695
|
if format is None:
|
696
|
-
format = cast(str, DEFAULTS[data_type]["format"])
|
696
|
+
format = cast("str", DEFAULTS[data_type]["format"])
|
697
697
|
|
698
698
|
if step == 0:
|
699
699
|
raise StreamlitAPIException(
|
@@ -811,7 +811,7 @@ class SliderMixin:
|
|
811
811
|
value = list(map(_datetime_to_micros, value))
|
812
812
|
min_value = _datetime_to_micros(min_value)
|
813
813
|
max_value = _datetime_to_micros(max_value)
|
814
|
-
step = _delta_to_micros(cast(timedelta, step))
|
814
|
+
step = _delta_to_micros(cast("timedelta", step))
|
815
815
|
|
816
816
|
# It would be great if we could guess the number of decimal places from
|
817
817
|
# the `step` argument, but this would only be meaningful if step were a
|
@@ -826,7 +826,7 @@ class SliderMixin:
|
|
826
826
|
slider_proto.default[:] = value
|
827
827
|
slider_proto.min = min_value
|
828
828
|
slider_proto.max = max_value
|
829
|
-
slider_proto.step = cast(float, step)
|
829
|
+
slider_proto.step = cast("float", step)
|
830
830
|
slider_proto.data_type = data_type
|
831
831
|
slider_proto.options[:] = []
|
832
832
|
slider_proto.form_id = current_form_id(self.dg)
|
@@ -872,7 +872,7 @@ class SliderMixin:
|
|
872
872
|
slider_proto.set_value = True
|
873
873
|
|
874
874
|
self.dg._enqueue("slider", slider_proto)
|
875
|
-
return cast(SliderReturn, widget_state.value)
|
875
|
+
return cast("SliderReturn", widget_state.value)
|
876
876
|
|
877
877
|
@property
|
878
878
|
def dg(self) -> DeltaGenerator:
|
@@ -151,7 +151,7 @@ def _parse_date_value(value: DateValue) -> tuple[list[date] | None, bool]:
|
|
151
151
|
value_tuple = value
|
152
152
|
else:
|
153
153
|
is_range = False
|
154
|
-
value_tuple = [cast(NullableScalarDateValue, value)]
|
154
|
+
value_tuple = [cast("NullableScalarDateValue", value)]
|
155
155
|
|
156
156
|
if len(value_tuple) not in {0, 1, 2}:
|
157
157
|
raise StreamlitAPIException(
|
@@ -227,7 +227,7 @@ class _DateInputValues:
|
|
227
227
|
)
|
228
228
|
|
229
229
|
if value == "today":
|
230
|
-
v = cast(list[date], parsed_value)[0]
|
230
|
+
v = cast("list[date]", parsed_value)[0]
|
231
231
|
if v < parsed_min:
|
232
232
|
parsed_value = [parsed_min]
|
233
233
|
if v > parsed_max:
|
@@ -300,7 +300,7 @@ class DateInputSerde:
|
|
300
300
|
|
301
301
|
if not self.value.is_range:
|
302
302
|
return return_value[0]
|
303
|
-
return cast(DateWidgetReturn, tuple(return_value))
|
303
|
+
return cast("DateWidgetReturn", tuple(return_value))
|
304
304
|
|
305
305
|
def serialize(self, v: DateWidgetReturn) -> list[str]:
|
306
306
|
if v is None:
|
@@ -869,7 +869,7 @@ class TimeWidgetsMixin:
|
|
869
869
|
parsed = None
|
870
870
|
elif isinstance(value, Sequence):
|
871
871
|
parsed = [
|
872
|
-
parse_date_deterministic_for_id(cast(NullableScalarDateValue, v))
|
872
|
+
parse_date_deterministic_for_id(cast("NullableScalarDateValue", v))
|
873
873
|
for v in value
|
874
874
|
]
|
875
875
|
else:
|
streamlit/elements/write.py
CHANGED
@@ -528,7 +528,7 @@ class WriteMixin:
|
|
528
528
|
flush_buffer()
|
529
529
|
# We cast arg to type here to appease mypy, due to bug in mypy:
|
530
530
|
# https://github.com/python/mypy/issues/12933
|
531
|
-
self.dg.help(cast(type, arg))
|
531
|
+
self.dg.help(cast("type", arg))
|
532
532
|
elif unsafe_allow_html and type_util.has_callable_attr(arg, "_repr_html_"):
|
533
533
|
self.dg.html(arg._repr_html_())
|
534
534
|
elif type_util.has_callable_attr(
|