streamlit-nightly 1.36.1.dev20240630__py2.py3-none-any.whl → 1.36.1.dev20240703__py2.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/commands/navigation.py +2 -2
- streamlit/components/v1/component_arrow.py +16 -11
- streamlit/components/v1/custom_component.py +2 -1
- streamlit/config.py +1 -136
- streamlit/dataframe_util.py +835 -0
- streamlit/delta_generator.py +5 -3
- streamlit/elements/arrow.py +17 -13
- streamlit/elements/dialog_decorator.py +1 -1
- streamlit/elements/exception.py +2 -8
- streamlit/elements/image.py +2 -1
- streamlit/elements/lib/built_in_chart_utils.py +78 -12
- streamlit/elements/lib/column_config_utils.py +1 -1
- streamlit/elements/lib/pandas_styler_utils.py +2 -2
- streamlit/elements/lib/policies.py +20 -2
- streamlit/elements/lib/utils.py +100 -10
- streamlit/elements/map.py +2 -2
- streamlit/elements/media.py +1 -1
- streamlit/elements/metric.py +5 -2
- streamlit/elements/plotly_chart.py +1 -1
- streamlit/elements/pyplot.py +26 -39
- streamlit/elements/vega_charts.py +6 -5
- streamlit/elements/widgets/button.py +1 -1
- streamlit/elements/widgets/camera_input.py +7 -2
- streamlit/elements/widgets/chat.py +1 -1
- streamlit/elements/widgets/checkbox.py +7 -2
- streamlit/elements/widgets/color_picker.py +7 -2
- streamlit/elements/widgets/data_editor.py +10 -9
- streamlit/elements/widgets/file_uploader.py +7 -2
- streamlit/elements/widgets/multiselect.py +6 -7
- streamlit/elements/widgets/number_input.py +7 -2
- streamlit/elements/widgets/radio.py +6 -7
- streamlit/elements/widgets/select_slider.py +6 -7
- streamlit/elements/widgets/selectbox.py +6 -7
- streamlit/elements/widgets/slider.py +7 -2
- streamlit/elements/widgets/text_widgets.py +8 -5
- streamlit/elements/widgets/time_widgets.py +7 -2
- streamlit/elements/write.py +5 -5
- streamlit/errors.py +0 -29
- streamlit/navigation/page.py +8 -3
- streamlit/proto/NewSession_pb2.pyi +1 -1
- streamlit/runtime/app_session.py +0 -4
- streamlit/runtime/caching/cache_utils.py +1 -1
- streamlit/runtime/scriptrunner/script_runner.py +7 -22
- streamlit/runtime/state/common.py +51 -2
- streamlit/runtime/state/session_state.py +2 -1
- streamlit/runtime/state/session_state_proxy.py +1 -1
- streamlit/runtime/state/widgets.py +1 -1
- streamlit/static/asset-manifest.json +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/main.28e3c6e9.js +2 -0
- streamlit/testing/v1/element_tree.py +3 -3
- streamlit/type_util.py +0 -1069
- streamlit/watcher/path_watcher.py +1 -2
- {streamlit_nightly-1.36.1.dev20240630.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.36.1.dev20240630.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/RECORD +60 -59
- {streamlit_nightly-1.36.1.dev20240630.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/main.0326e951.js +0 -2
- /streamlit/static/static/js/{main.0326e951.js.LICENSE.txt → main.28e3c6e9.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.36.1.dev20240630.data → streamlit_nightly-1.36.1.dev20240703.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.36.1.dev20240630.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.36.1.dev20240630.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/top_level.txt +0 -0
streamlit/elements/pyplot.py
CHANGED
@@ -20,8 +20,7 @@ import io
|
|
20
20
|
from typing import TYPE_CHECKING, Any, cast
|
21
21
|
|
22
22
|
import streamlit.elements.image as image_utils
|
23
|
-
from streamlit import
|
24
|
-
from streamlit.errors import StreamlitDeprecationWarning
|
23
|
+
from streamlit.deprecation_util import show_deprecation_warning
|
25
24
|
from streamlit.proto.Image_pb2 import ImageList as ImageListProto
|
26
25
|
from streamlit.runtime.metrics_util import gather_metrics
|
27
26
|
|
@@ -45,9 +44,13 @@ class PyplotMixin:
|
|
45
44
|
Parameters
|
46
45
|
----------
|
47
46
|
fig : Matplotlib Figure
|
48
|
-
The
|
49
|
-
|
50
|
-
|
47
|
+
The Matplotlib ``Figure`` object to render. See
|
48
|
+
https://matplotlib.org/stable/gallery/index.html for examples.
|
49
|
+
|
50
|
+
.. note::
|
51
|
+
When this argument isn't specified, this function will render the global
|
52
|
+
Matplotlib figure object. However, this feature is deprecated and
|
53
|
+
will be removed in a later version.
|
51
54
|
|
52
55
|
clear_figure : bool
|
53
56
|
If True, the figure will be cleared after being rendered.
|
@@ -87,15 +90,6 @@ class PyplotMixin:
|
|
87
90
|
https://doc-pyplot.streamlit.app/
|
88
91
|
height: 630px
|
89
92
|
|
90
|
-
Notes
|
91
|
-
-----
|
92
|
-
.. note::
|
93
|
-
Deprecation warning. After December 1st, 2020, we will remove the ability
|
94
|
-
to specify no arguments in `st.pyplot()`, as that requires the use of
|
95
|
-
Matplotlib's global figure object, which is not thread-safe. So
|
96
|
-
please always pass a figure object as shown in the example section
|
97
|
-
above.
|
98
|
-
|
99
93
|
Matplotlib supports several types of "backends". If you're getting an
|
100
94
|
error using Matplotlib with Streamlit, try setting your backend to "TkAgg"::
|
101
95
|
|
@@ -105,8 +99,24 @@ class PyplotMixin:
|
|
105
99
|
|
106
100
|
"""
|
107
101
|
|
108
|
-
if not fig
|
109
|
-
|
102
|
+
if not fig:
|
103
|
+
show_deprecation_warning("""
|
104
|
+
Calling `st.pyplot()` without providing a figure argument has been deprecated
|
105
|
+
and will be removed in a later version as it requires the use of Matplotlib's
|
106
|
+
global figure object, which is not thread-safe.
|
107
|
+
|
108
|
+
To future-proof this code, you should pass in a figure as shown below:
|
109
|
+
|
110
|
+
```python
|
111
|
+
fig, ax = plt.subplots()
|
112
|
+
ax.scatter([1, 2, 3], [1, 2, 3])
|
113
|
+
# other plotting actions...
|
114
|
+
st.pyplot(fig)
|
115
|
+
```
|
116
|
+
|
117
|
+
If you have a specific use case that requires this functionality, please let us
|
118
|
+
know via [issue on Github](https://github.com/streamlit/streamlit/issues).
|
119
|
+
""")
|
110
120
|
|
111
121
|
image_list_proto = ImageListProto()
|
112
122
|
marshall(
|
@@ -181,26 +191,3 @@ def marshall(
|
|
181
191
|
# plt calls will be starting fresh.
|
182
192
|
if clear_figure:
|
183
193
|
fig.clf()
|
184
|
-
|
185
|
-
|
186
|
-
class PyplotGlobalUseWarning(StreamlitDeprecationWarning):
|
187
|
-
def __init__(self) -> None:
|
188
|
-
super().__init__(
|
189
|
-
msg=self._get_message(), config_option="deprecation.showPyplotGlobalUse"
|
190
|
-
)
|
191
|
-
|
192
|
-
def _get_message(self) -> str:
|
193
|
-
return """
|
194
|
-
You are calling `st.pyplot()` without any arguments. After December 1st, 2020,
|
195
|
-
we will remove the ability to do this as it requires the use of Matplotlib's global
|
196
|
-
figure object, which is not thread-safe.
|
197
|
-
|
198
|
-
To future-proof this code, you should pass in a figure as shown below:
|
199
|
-
|
200
|
-
```python
|
201
|
-
>>> fig, ax = plt.subplots()
|
202
|
-
>>> ax.scatter([1, 2, 3], [1, 2, 3])
|
203
|
-
>>> ... other plotting actions ...
|
204
|
-
>>> st.pyplot(fig)
|
205
|
-
```
|
206
|
-
"""
|
@@ -36,9 +36,10 @@ from typing import (
|
|
36
36
|
from typing_extensions import TypeAlias
|
37
37
|
|
38
38
|
import streamlit.elements.lib.dicttools as dicttools
|
39
|
-
from streamlit import type_util
|
39
|
+
from streamlit import dataframe_util, type_util
|
40
40
|
from streamlit.elements.lib.built_in_chart_utils import (
|
41
41
|
AddRowsMetadata,
|
42
|
+
ChartStackType,
|
42
43
|
ChartType,
|
43
44
|
generate_chart,
|
44
45
|
)
|
@@ -49,6 +50,7 @@ from streamlit.elements.lib.policies import (
|
|
49
50
|
check_fragment_path_policy,
|
50
51
|
check_session_state_rules,
|
51
52
|
)
|
53
|
+
from streamlit.elements.lib.utils import Key, to_key
|
52
54
|
from streamlit.errors import StreamlitAPIException
|
53
55
|
from streamlit.proto.ArrowVegaLiteChart_pb2 import (
|
54
56
|
ArrowVegaLiteChart as ArrowVegaLiteChartProto,
|
@@ -57,7 +59,6 @@ from streamlit.runtime.metrics_util import gather_metrics
|
|
57
59
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
58
60
|
from streamlit.runtime.state import register_widget
|
59
61
|
from streamlit.runtime.state.common import compute_widget_id
|
60
|
-
from streamlit.type_util import ChartStackType, Key, to_key
|
61
62
|
from streamlit.util import HASHLIB_KWARGS
|
62
63
|
|
63
64
|
if TYPE_CHECKING:
|
@@ -279,10 +280,10 @@ def _serialize_data(data: Any) -> bytes:
|
|
279
280
|
import pyarrow as pa
|
280
281
|
|
281
282
|
if isinstance(data, pa.Table):
|
282
|
-
return
|
283
|
+
return dataframe_util.pyarrow_table_to_bytes(data)
|
283
284
|
|
284
|
-
df =
|
285
|
-
return
|
285
|
+
df = dataframe_util.convert_anything_to_pandas_df(data)
|
286
|
+
return dataframe_util.data_frame_to_bytes(df)
|
286
287
|
|
287
288
|
|
288
289
|
def _marshall_chart_data(
|
@@ -30,6 +30,7 @@ from streamlit.elements.lib.policies import (
|
|
30
30
|
check_fragment_path_policy,
|
31
31
|
check_session_state_rules,
|
32
32
|
)
|
33
|
+
from streamlit.elements.lib.utils import Key, to_key
|
33
34
|
from streamlit.errors import StreamlitAPIException
|
34
35
|
from streamlit.file_util import get_main_script_directory, normalize_path_join
|
35
36
|
from streamlit.navigation.page import StreamlitPage
|
@@ -47,7 +48,6 @@ from streamlit.runtime.state import (
|
|
47
48
|
)
|
48
49
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
49
50
|
from streamlit.string_util import validate_icon_or_emoji
|
50
|
-
from streamlit.type_util import Key, to_key
|
51
51
|
from streamlit.url_util import is_url
|
52
52
|
|
53
53
|
if TYPE_CHECKING:
|
@@ -26,8 +26,14 @@ from streamlit.elements.lib.policies import (
|
|
26
26
|
check_callback_rules,
|
27
27
|
check_fragment_path_policy,
|
28
28
|
check_session_state_rules,
|
29
|
+
maybe_raise_label_warnings,
|
30
|
+
)
|
31
|
+
from streamlit.elements.lib.utils import (
|
32
|
+
Key,
|
33
|
+
LabelVisibility,
|
34
|
+
get_label_visibility_proto_value,
|
35
|
+
to_key,
|
29
36
|
)
|
30
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
31
37
|
from streamlit.elements.widgets.file_uploader import _get_upload_files
|
32
38
|
from streamlit.proto.CameraInput_pb2 import CameraInput as CameraInputProto
|
33
39
|
from streamlit.proto.Common_pb2 import FileUploaderState as FileUploaderStateProto
|
@@ -42,7 +48,6 @@ from streamlit.runtime.state import (
|
|
42
48
|
)
|
43
49
|
from streamlit.runtime.state.common import compute_widget_id
|
44
50
|
from streamlit.runtime.uploaded_file_manager import DeletedFile, UploadedFile
|
45
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
46
51
|
|
47
52
|
if TYPE_CHECKING:
|
48
53
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -27,6 +27,7 @@ from streamlit.elements.lib.policies import (
|
|
27
27
|
check_fragment_path_policy,
|
28
28
|
check_session_state_rules,
|
29
29
|
)
|
30
|
+
from streamlit.elements.lib.utils import Key, to_key
|
30
31
|
from streamlit.errors import StreamlitAPIException
|
31
32
|
from streamlit.proto.Block_pb2 import Block as BlockProto
|
32
33
|
from streamlit.proto.ChatInput_pb2 import ChatInput as ChatInputProto
|
@@ -42,7 +43,6 @@ from streamlit.runtime.state import (
|
|
42
43
|
)
|
43
44
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
44
45
|
from streamlit.string_util import is_emoji, validate_material_icon
|
45
|
-
from streamlit.type_util import Key, to_key
|
46
46
|
|
47
47
|
if TYPE_CHECKING:
|
48
48
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -24,8 +24,14 @@ from streamlit.elements.lib.policies import (
|
|
24
24
|
check_callback_rules,
|
25
25
|
check_fragment_path_policy,
|
26
26
|
check_session_state_rules,
|
27
|
+
maybe_raise_label_warnings,
|
28
|
+
)
|
29
|
+
from streamlit.elements.lib.utils import (
|
30
|
+
Key,
|
31
|
+
LabelVisibility,
|
32
|
+
get_label_visibility_proto_value,
|
33
|
+
to_key,
|
27
34
|
)
|
28
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
29
35
|
from streamlit.proto.Checkbox_pb2 import Checkbox as CheckboxProto
|
30
36
|
from streamlit.runtime.metrics_util import gather_metrics
|
31
37
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
@@ -36,7 +42,6 @@ from streamlit.runtime.state import (
|
|
36
42
|
register_widget,
|
37
43
|
)
|
38
44
|
from streamlit.runtime.state.common import compute_widget_id
|
39
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
40
45
|
|
41
46
|
if TYPE_CHECKING:
|
42
47
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -25,8 +25,14 @@ from streamlit.elements.lib.policies import (
|
|
25
25
|
check_callback_rules,
|
26
26
|
check_fragment_path_policy,
|
27
27
|
check_session_state_rules,
|
28
|
+
maybe_raise_label_warnings,
|
29
|
+
)
|
30
|
+
from streamlit.elements.lib.utils import (
|
31
|
+
Key,
|
32
|
+
LabelVisibility,
|
33
|
+
get_label_visibility_proto_value,
|
34
|
+
to_key,
|
28
35
|
)
|
29
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
30
36
|
from streamlit.errors import StreamlitAPIException
|
31
37
|
from streamlit.proto.ColorPicker_pb2 import ColorPicker as ColorPickerProto
|
32
38
|
from streamlit.runtime.metrics_util import gather_metrics
|
@@ -38,7 +44,6 @@ from streamlit.runtime.state import (
|
|
38
44
|
register_widget,
|
39
45
|
)
|
40
46
|
from streamlit.runtime.state.common import compute_widget_id
|
41
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
42
47
|
|
43
48
|
if TYPE_CHECKING:
|
44
49
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -37,8 +37,8 @@ from typing import (
|
|
37
37
|
|
38
38
|
from typing_extensions import TypeAlias
|
39
39
|
|
40
|
+
from streamlit import dataframe_util
|
40
41
|
from streamlit import logger as _logger
|
41
|
-
from streamlit import type_util
|
42
42
|
from streamlit.elements.form import current_form_id
|
43
43
|
from streamlit.elements.lib.column_config_utils import (
|
44
44
|
INDEX_IDENTIFIER,
|
@@ -60,6 +60,7 @@ from streamlit.elements.lib.policies import (
|
|
60
60
|
check_fragment_path_policy,
|
61
61
|
check_session_state_rules,
|
62
62
|
)
|
63
|
+
from streamlit.elements.lib.utils import Key, to_key
|
63
64
|
from streamlit.errors import StreamlitAPIException
|
64
65
|
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
|
65
66
|
from streamlit.runtime.metrics_util import gather_metrics
|
@@ -71,7 +72,7 @@ from streamlit.runtime.state import (
|
|
71
72
|
register_widget,
|
72
73
|
)
|
73
74
|
from streamlit.runtime.state.common import compute_widget_id
|
74
|
-
from streamlit.type_util import
|
75
|
+
from streamlit.type_util import is_type
|
75
76
|
from streamlit.util import calc_md5
|
76
77
|
|
77
78
|
if TYPE_CHECKING:
|
@@ -89,7 +90,7 @@ _LOGGER: Final = _logger.get_logger(__name__)
|
|
89
90
|
EditableData = TypeVar(
|
90
91
|
"EditableData",
|
91
92
|
bound=Union[
|
92
|
-
DataFrameGenericAlias[Any], # covers DataFrame and Series
|
93
|
+
dataframe_util.DataFrameGenericAlias[Any], # covers DataFrame and Series
|
93
94
|
Tuple[Any],
|
94
95
|
List[Any],
|
95
96
|
Set[Any],
|
@@ -795,8 +796,8 @@ class DataEditorMixin:
|
|
795
796
|
|
796
797
|
column_config_mapping: ColumnConfigMapping = {}
|
797
798
|
|
798
|
-
data_format =
|
799
|
-
if data_format == DataFormat.UNKNOWN:
|
799
|
+
data_format = dataframe_util.determine_data_format(data)
|
800
|
+
if data_format == dataframe_util.DataFormat.UNKNOWN:
|
800
801
|
raise StreamlitAPIException(
|
801
802
|
f"The data type ({type(data).__name__}) or format is not supported by the data editor. "
|
802
803
|
"Please convert your data into a Pandas Dataframe or another supported data format."
|
@@ -804,7 +805,7 @@ class DataEditorMixin:
|
|
804
805
|
|
805
806
|
# The dataframe should always be a copy of the original data
|
806
807
|
# since we will apply edits directly to it.
|
807
|
-
data_df =
|
808
|
+
data_df = dataframe_util.convert_anything_to_pandas_df(data, ensure_copy=True)
|
808
809
|
|
809
810
|
# Check if the index is supported.
|
810
811
|
if not _is_supported_index(data_df.index):
|
@@ -855,7 +856,7 @@ class DataEditorMixin:
|
|
855
856
|
# Throws an exception if any of the configured types are incompatible.
|
856
857
|
_check_type_compatibilities(data_df, column_config_mapping, dataframe_schema)
|
857
858
|
|
858
|
-
arrow_bytes =
|
859
|
+
arrow_bytes = dataframe_util.pyarrow_table_to_bytes(arrow_table)
|
859
860
|
|
860
861
|
# We want to do this as early as possible to avoid introducing nondeterminism,
|
861
862
|
# but it isn't clear how much processing is needed to have the data in a
|
@@ -902,7 +903,7 @@ class DataEditorMixin:
|
|
902
903
|
|
903
904
|
proto.form_id = current_form_id(self.dg)
|
904
905
|
|
905
|
-
if
|
906
|
+
if dataframe_util.is_pandas_styler(data):
|
906
907
|
# Pandas styler will only work for non-editable/disabled columns.
|
907
908
|
# Get first 10 chars of md5 hash of the key or delta path as styler uuid
|
908
909
|
# and set it as styler uuid.
|
@@ -936,7 +937,7 @@ class DataEditorMixin:
|
|
936
937
|
|
937
938
|
_apply_dataframe_edits(data_df, widget_state.value, dataframe_schema)
|
938
939
|
self.dg._enqueue("arrow_data_frame", proto)
|
939
|
-
return
|
940
|
+
return dataframe_util.convert_df_to_data_format(data_df, data_format)
|
940
941
|
|
941
942
|
@property
|
942
943
|
def dg(self) -> DeltaGenerator:
|
@@ -27,8 +27,14 @@ from streamlit.elements.lib.policies import (
|
|
27
27
|
check_callback_rules,
|
28
28
|
check_fragment_path_policy,
|
29
29
|
check_session_state_rules,
|
30
|
+
maybe_raise_label_warnings,
|
31
|
+
)
|
32
|
+
from streamlit.elements.lib.utils import (
|
33
|
+
Key,
|
34
|
+
LabelVisibility,
|
35
|
+
get_label_visibility_proto_value,
|
36
|
+
to_key,
|
30
37
|
)
|
31
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
32
38
|
from streamlit.proto.Common_pb2 import FileUploaderState as FileUploaderStateProto
|
33
39
|
from streamlit.proto.Common_pb2 import UploadedFileInfo as UploadedFileInfoProto
|
34
40
|
from streamlit.proto.FileUploader_pb2 import FileUploader as FileUploaderProto
|
@@ -42,7 +48,6 @@ from streamlit.runtime.state import (
|
|
42
48
|
)
|
43
49
|
from streamlit.runtime.state.common import compute_widget_id
|
44
50
|
from streamlit.runtime.uploaded_file_manager import DeletedFile, UploadedFile
|
45
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
46
51
|
|
47
52
|
if TYPE_CHECKING:
|
48
53
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -18,16 +18,21 @@ from dataclasses import dataclass
|
|
18
18
|
from textwrap import dedent
|
19
19
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast, overload
|
20
20
|
|
21
|
+
from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
|
21
22
|
from streamlit.elements.form import current_form_id
|
22
23
|
from streamlit.elements.lib.policies import (
|
23
24
|
check_cache_replay_rules,
|
24
25
|
check_callback_rules,
|
25
26
|
check_fragment_path_policy,
|
26
27
|
check_session_state_rules,
|
28
|
+
maybe_raise_label_warnings,
|
27
29
|
)
|
28
30
|
from streamlit.elements.lib.utils import (
|
31
|
+
Key,
|
32
|
+
LabelVisibility,
|
29
33
|
get_label_visibility_proto_value,
|
30
34
|
maybe_coerce_enum_sequence,
|
35
|
+
to_key,
|
31
36
|
)
|
32
37
|
from streamlit.errors import StreamlitAPIException
|
33
38
|
from streamlit.proto.MultiSelect_pb2 import MultiSelect as MultiSelectProto
|
@@ -41,16 +46,10 @@ from streamlit.runtime.state import (
|
|
41
46
|
)
|
42
47
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
43
48
|
from streamlit.type_util import (
|
44
|
-
Key,
|
45
|
-
LabelVisibility,
|
46
|
-
OptionSequence,
|
47
49
|
T,
|
48
50
|
check_python_comparable,
|
49
|
-
ensure_indexable,
|
50
51
|
is_iterable,
|
51
52
|
is_type,
|
52
|
-
maybe_raise_label_warnings,
|
53
|
-
to_key,
|
54
53
|
)
|
55
54
|
|
56
55
|
if TYPE_CHECKING:
|
@@ -298,7 +297,7 @@ class MultiSelectMixin:
|
|
298
297
|
check_session_state_rules(default_value=default, key=key)
|
299
298
|
maybe_raise_label_warnings(label, label_visibility)
|
300
299
|
|
301
|
-
opt =
|
300
|
+
opt = convert_anything_to_sequence(options)
|
302
301
|
check_python_comparable(opt)
|
303
302
|
|
304
303
|
indices = _check_and_convert_to_indices(opt, default)
|
@@ -27,8 +27,14 @@ from streamlit.elements.lib.policies import (
|
|
27
27
|
check_callback_rules,
|
28
28
|
check_fragment_path_policy,
|
29
29
|
check_session_state_rules,
|
30
|
+
maybe_raise_label_warnings,
|
31
|
+
)
|
32
|
+
from streamlit.elements.lib.utils import (
|
33
|
+
Key,
|
34
|
+
LabelVisibility,
|
35
|
+
get_label_visibility_proto_value,
|
36
|
+
to_key,
|
30
37
|
)
|
31
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
32
38
|
from streamlit.errors import StreamlitAPIException
|
33
39
|
from streamlit.js_number import JSNumber, JSNumberBoundsException
|
34
40
|
from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
|
@@ -42,7 +48,6 @@ from streamlit.runtime.state import (
|
|
42
48
|
register_widget,
|
43
49
|
)
|
44
50
|
from streamlit.runtime.state.common import compute_widget_id
|
45
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
46
51
|
|
47
52
|
if TYPE_CHECKING:
|
48
53
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -18,16 +18,21 @@ from dataclasses import dataclass
|
|
18
18
|
from textwrap import dedent
|
19
19
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
|
20
20
|
|
21
|
+
from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
|
21
22
|
from streamlit.elements.form import current_form_id
|
22
23
|
from streamlit.elements.lib.policies import (
|
23
24
|
check_cache_replay_rules,
|
24
25
|
check_callback_rules,
|
25
26
|
check_fragment_path_policy,
|
26
27
|
check_session_state_rules,
|
28
|
+
maybe_raise_label_warnings,
|
27
29
|
)
|
28
30
|
from streamlit.elements.lib.utils import (
|
31
|
+
Key,
|
32
|
+
LabelVisibility,
|
29
33
|
get_label_visibility_proto_value,
|
30
34
|
maybe_coerce_enum,
|
35
|
+
to_key,
|
31
36
|
)
|
32
37
|
from streamlit.errors import StreamlitAPIException
|
33
38
|
from streamlit.proto.Radio_pb2 import Radio as RadioProto
|
@@ -42,14 +47,8 @@ from streamlit.runtime.state import (
|
|
42
47
|
)
|
43
48
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
44
49
|
from streamlit.type_util import (
|
45
|
-
Key,
|
46
|
-
LabelVisibility,
|
47
|
-
OptionSequence,
|
48
50
|
T,
|
49
51
|
check_python_comparable,
|
50
|
-
ensure_indexable,
|
51
|
-
maybe_raise_label_warnings,
|
52
|
-
to_key,
|
53
52
|
)
|
54
53
|
from streamlit.util import index_
|
55
54
|
|
@@ -264,7 +263,7 @@ class RadioMixin:
|
|
264
263
|
check_session_state_rules(default_value=None if index == 0 else index, key=key)
|
265
264
|
maybe_raise_label_warnings(label, label_visibility)
|
266
265
|
|
267
|
-
opt =
|
266
|
+
opt = convert_anything_to_sequence(options)
|
268
267
|
check_python_comparable(opt)
|
269
268
|
|
270
269
|
id = compute_widget_id(
|
@@ -20,16 +20,21 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, Tuple, cast
|
|
20
20
|
|
21
21
|
from typing_extensions import TypeGuard
|
22
22
|
|
23
|
+
from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
|
23
24
|
from streamlit.elements.form import current_form_id
|
24
25
|
from streamlit.elements.lib.policies import (
|
25
26
|
check_cache_replay_rules,
|
26
27
|
check_callback_rules,
|
27
28
|
check_session_state_rules,
|
29
|
+
maybe_raise_label_warnings,
|
28
30
|
)
|
29
31
|
from streamlit.elements.lib.utils import (
|
32
|
+
Key,
|
33
|
+
LabelVisibility,
|
30
34
|
get_label_visibility_proto_value,
|
31
35
|
maybe_coerce_enum,
|
32
36
|
maybe_coerce_enum_sequence,
|
37
|
+
to_key,
|
33
38
|
)
|
34
39
|
from streamlit.errors import StreamlitAPIException
|
35
40
|
from streamlit.proto.Slider_pb2 import Slider as SliderProto
|
@@ -47,14 +52,8 @@ from streamlit.runtime.state.common import (
|
|
47
52
|
save_for_app_testing,
|
48
53
|
)
|
49
54
|
from streamlit.type_util import (
|
50
|
-
Key,
|
51
|
-
LabelVisibility,
|
52
|
-
OptionSequence,
|
53
55
|
T,
|
54
56
|
check_python_comparable,
|
55
|
-
ensure_indexable,
|
56
|
-
maybe_raise_label_warnings,
|
57
|
-
to_key,
|
58
57
|
)
|
59
58
|
from streamlit.util import index_
|
60
59
|
|
@@ -268,7 +267,7 @@ class SelectSliderMixin:
|
|
268
267
|
check_session_state_rules(default_value=value, key=key)
|
269
268
|
maybe_raise_label_warnings(label, label_visibility)
|
270
269
|
|
271
|
-
opt =
|
270
|
+
opt = convert_anything_to_sequence(options)
|
272
271
|
check_python_comparable(opt)
|
273
272
|
|
274
273
|
if len(opt) == 0:
|
@@ -17,16 +17,21 @@ from dataclasses import dataclass
|
|
17
17
|
from textwrap import dedent
|
18
18
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
|
19
19
|
|
20
|
+
from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
|
20
21
|
from streamlit.elements.form import current_form_id
|
21
22
|
from streamlit.elements.lib.policies import (
|
22
23
|
check_cache_replay_rules,
|
23
24
|
check_callback_rules,
|
24
25
|
check_fragment_path_policy,
|
25
26
|
check_session_state_rules,
|
27
|
+
maybe_raise_label_warnings,
|
26
28
|
)
|
27
29
|
from streamlit.elements.lib.utils import (
|
30
|
+
Key,
|
31
|
+
LabelVisibility,
|
28
32
|
get_label_visibility_proto_value,
|
29
33
|
maybe_coerce_enum,
|
34
|
+
to_key,
|
30
35
|
)
|
31
36
|
from streamlit.errors import StreamlitAPIException
|
32
37
|
from streamlit.proto.Selectbox_pb2 import Selectbox as SelectboxProto
|
@@ -41,14 +46,8 @@ from streamlit.runtime.state import (
|
|
41
46
|
)
|
42
47
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
43
48
|
from streamlit.type_util import (
|
44
|
-
Key,
|
45
|
-
LabelVisibility,
|
46
|
-
OptionSequence,
|
47
49
|
T,
|
48
50
|
check_python_comparable,
|
49
|
-
ensure_indexable,
|
50
|
-
maybe_raise_label_warnings,
|
51
|
-
to_key,
|
52
51
|
)
|
53
52
|
from streamlit.util import index_
|
54
53
|
|
@@ -244,7 +243,7 @@ class SelectboxMixin:
|
|
244
243
|
check_session_state_rules(default_value=None if index == 0 else index, key=key)
|
245
244
|
maybe_raise_label_warnings(label, label_visibility)
|
246
245
|
|
247
|
-
opt =
|
246
|
+
opt = convert_anything_to_sequence(options)
|
248
247
|
check_python_comparable(opt)
|
249
248
|
|
250
249
|
id = compute_widget_id(
|
@@ -28,8 +28,14 @@ from streamlit.elements.lib.policies import (
|
|
28
28
|
check_callback_rules,
|
29
29
|
check_fragment_path_policy,
|
30
30
|
check_session_state_rules,
|
31
|
+
maybe_raise_label_warnings,
|
32
|
+
)
|
33
|
+
from streamlit.elements.lib.utils import (
|
34
|
+
Key,
|
35
|
+
LabelVisibility,
|
36
|
+
get_label_visibility_proto_value,
|
37
|
+
to_key,
|
31
38
|
)
|
32
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
33
39
|
from streamlit.errors import StreamlitAPIException
|
34
40
|
from streamlit.js_number import JSNumber, JSNumberBoundsException
|
35
41
|
from streamlit.proto.Slider_pb2 import Slider as SliderProto
|
@@ -43,7 +49,6 @@ from streamlit.runtime.state import (
|
|
43
49
|
register_widget,
|
44
50
|
)
|
45
51
|
from streamlit.runtime.state.common import compute_widget_id
|
46
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
47
52
|
|
48
53
|
if TYPE_CHECKING:
|
49
54
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -24,8 +24,14 @@ from streamlit.elements.lib.policies import (
|
|
24
24
|
check_callback_rules,
|
25
25
|
check_fragment_path_policy,
|
26
26
|
check_session_state_rules,
|
27
|
+
maybe_raise_label_warnings,
|
28
|
+
)
|
29
|
+
from streamlit.elements.lib.utils import (
|
30
|
+
Key,
|
31
|
+
LabelVisibility,
|
32
|
+
get_label_visibility_proto_value,
|
33
|
+
to_key,
|
27
34
|
)
|
28
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
29
35
|
from streamlit.errors import StreamlitAPIException
|
30
36
|
from streamlit.proto.TextArea_pb2 import TextArea as TextAreaProto
|
31
37
|
from streamlit.proto.TextInput_pb2 import TextInput as TextInputProto
|
@@ -40,15 +46,12 @@ from streamlit.runtime.state import (
|
|
40
46
|
)
|
41
47
|
from streamlit.runtime.state.common import compute_widget_id
|
42
48
|
from streamlit.type_util import (
|
43
|
-
Key,
|
44
|
-
LabelVisibility,
|
45
49
|
SupportsStr,
|
46
|
-
maybe_raise_label_warnings,
|
47
|
-
to_key,
|
48
50
|
)
|
49
51
|
|
50
52
|
if TYPE_CHECKING:
|
51
53
|
from streamlit.delta_generator import DeltaGenerator
|
54
|
+
from streamlit.type_util import SupportsStr
|
52
55
|
|
53
56
|
|
54
57
|
@dataclass
|
@@ -38,8 +38,14 @@ from streamlit.elements.lib.policies import (
|
|
38
38
|
check_callback_rules,
|
39
39
|
check_fragment_path_policy,
|
40
40
|
check_session_state_rules,
|
41
|
+
maybe_raise_label_warnings,
|
42
|
+
)
|
43
|
+
from streamlit.elements.lib.utils import (
|
44
|
+
Key,
|
45
|
+
LabelVisibility,
|
46
|
+
get_label_visibility_proto_value,
|
47
|
+
to_key,
|
41
48
|
)
|
42
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
43
49
|
from streamlit.errors import StreamlitAPIException
|
44
50
|
from streamlit.proto.DateInput_pb2 import DateInput as DateInputProto
|
45
51
|
from streamlit.proto.TimeInput_pb2 import TimeInput as TimeInputProto
|
@@ -54,7 +60,6 @@ from streamlit.runtime.state import (
|
|
54
60
|
)
|
55
61
|
from streamlit.runtime.state.common import compute_widget_id
|
56
62
|
from streamlit.time_util import adjust_years
|
57
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
58
63
|
|
59
64
|
if TYPE_CHECKING:
|
60
65
|
from streamlit.delta_generator import DeltaGenerator
|
streamlit/elements/write.py
CHANGED
@@ -21,7 +21,7 @@ import types
|
|
21
21
|
from io import StringIO
|
22
22
|
from typing import TYPE_CHECKING, Any, Callable, Final, Generator, Iterable, List, cast
|
23
23
|
|
24
|
-
from streamlit import type_util
|
24
|
+
from streamlit import dataframe_util, type_util
|
25
25
|
from streamlit.errors import StreamlitAPIException
|
26
26
|
from streamlit.logger import get_logger
|
27
27
|
from streamlit.runtime.metrics_util import gather_metrics
|
@@ -128,7 +128,7 @@ class WriteMixin:
|
|
128
128
|
|
129
129
|
# Just apply some basic checks for common iterable types that should
|
130
130
|
# not be passed in here.
|
131
|
-
if isinstance(stream, str) or
|
131
|
+
if isinstance(stream, str) or dataframe_util.is_dataframe_like(stream):
|
132
132
|
raise StreamlitAPIException(
|
133
133
|
"`st.write_stream` expects a generator or stream-like object as input "
|
134
134
|
f"not {type(stream)}. Please use `st.write` instead for "
|
@@ -401,12 +401,12 @@ class WriteMixin:
|
|
401
401
|
item()
|
402
402
|
else:
|
403
403
|
self.write(item, unsafe_allow_html=unsafe_allow_html)
|
404
|
-
elif
|
404
|
+
elif dataframe_util.is_unevaluated_data_object(
|
405
405
|
arg
|
406
|
-
) or
|
406
|
+
) or dataframe_util.is_snowpark_row_list(arg):
|
407
407
|
flush_buffer()
|
408
408
|
self.dg.dataframe(arg)
|
409
|
-
elif
|
409
|
+
elif dataframe_util.is_dataframe_like(arg):
|
410
410
|
import numpy as np
|
411
411
|
|
412
412
|
flush_buffer()
|