streamlit-nightly 1.35.1.dev20240610__py2.py3-none-any.whl → 1.35.1.dev20240611__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/__init__.py +5 -1
- streamlit/case_converters.py +2 -2
- streamlit/cli_util.py +2 -2
- streamlit/color_util.py +2 -2
- streamlit/commands/experimental_query_params.py +6 -8
- streamlit/commands/logo.py +4 -9
- streamlit/commands/navigation.py +6 -4
- streamlit/components/lib/local_component_registry.py +4 -2
- streamlit/components/types/base_component_registry.py +3 -2
- streamlit/components/v1/component_arrow.py +2 -1
- streamlit/components/v1/component_registry.py +6 -2
- streamlit/components/v1/components.py +4 -2
- streamlit/components/v1/custom_component.py +6 -6
- streamlit/config.py +15 -12
- streamlit/connections/snowflake_connection.py +2 -1
- streamlit/connections/snowpark_connection.py +2 -4
- streamlit/connections/sql_connection.py +2 -1
- streamlit/delta_generator.py +3 -4
- streamlit/elements/arrow.py +3 -6
- streamlit/elements/code.py +1 -1
- streamlit/elements/dialog_decorator.py +10 -8
- streamlit/elements/doc_string.py +1 -1
- streamlit/elements/exception.py +1 -1
- streamlit/elements/form.py +1 -1
- streamlit/elements/heading.py +1 -1
- streamlit/elements/html.py +1 -1
- streamlit/elements/image.py +5 -3
- streamlit/elements/layouts.py +7 -7
- streamlit/elements/lib/built_in_chart_utils.py +24 -12
- streamlit/elements/lib/column_config_utils.py +2 -1
- streamlit/elements/lib/dialog.py +8 -5
- streamlit/elements/lib/dicttools.py +3 -3
- streamlit/elements/lib/mutable_status_container.py +8 -5
- streamlit/elements/lib/pandas_styler_utils.py +2 -1
- streamlit/elements/lib/subtitle_utils.py +0 -1
- streamlit/elements/lib/utils.py +8 -10
- streamlit/elements/plotly_chart.py +5 -10
- streamlit/elements/pyplot.py +0 -1
- streamlit/elements/toast.py +2 -2
- streamlit/elements/vega_charts.py +46 -10
- streamlit/elements/widgets/color_picker.py +6 -4
- streamlit/elements/widgets/file_uploader.py +4 -8
- streamlit/elements/widgets/multiselect.py +2 -4
- streamlit/elements/widgets/number_input.py +4 -8
- streamlit/elements/widgets/select_slider.py +1 -1
- streamlit/elements/widgets/slider.py +2 -5
- streamlit/elements/widgets/time_widgets.py +5 -5
- streamlit/errors.py +1 -6
- streamlit/git_util.py +2 -2
- streamlit/hello/Animation_Demo.py +0 -1
- streamlit/logger.py +1 -1
- streamlit/navigation/page.py +6 -1
- streamlit/net_util.py +2 -5
- streamlit/proto/AutoRerun_pb2.py +3 -2
- streamlit/runtime/app_session.py +7 -7
- streamlit/runtime/caching/__init__.py +9 -13
- streamlit/runtime/caching/cache_data_api.py +18 -7
- streamlit/runtime/caching/cache_errors.py +8 -6
- streamlit/runtime/caching/cache_resource_api.py +10 -9
- streamlit/runtime/caching/cache_utils.py +10 -7
- streamlit/runtime/caching/cached_message_replay.py +10 -9
- streamlit/runtime/caching/hashing.py +3 -3
- streamlit/runtime/caching/storage/cache_storage_protocol.py +1 -1
- streamlit/runtime/connection_factory.py +4 -2
- streamlit/runtime/credentials.py +11 -20
- streamlit/runtime/forward_msg_cache.py +10 -11
- streamlit/runtime/forward_msg_queue.py +6 -4
- streamlit/runtime/fragment.py +7 -9
- streamlit/runtime/media_file_manager.py +4 -4
- streamlit/runtime/memory_media_file_storage.py +7 -8
- streamlit/runtime/metrics_util.py +2 -4
- streamlit/runtime/pages_manager.py +41 -41
- streamlit/runtime/runtime.py +4 -4
- streamlit/runtime/runtime_util.py +7 -12
- streamlit/runtime/scriptrunner/magic.py +1 -1
- streamlit/runtime/scriptrunner/script_requests.py +4 -2
- streamlit/runtime/scriptrunner/script_run_context.py +15 -15
- streamlit/runtime/scriptrunner/script_runner.py +8 -8
- streamlit/runtime/secrets.py +3 -5
- streamlit/runtime/session_manager.py +8 -7
- streamlit/runtime/state/common.py +1 -1
- streamlit/runtime/state/query_params_proxy.py +5 -10
- streamlit/runtime/state/safe_session_state.py +8 -7
- streamlit/runtime/state/widgets.py +27 -27
- streamlit/runtime/stats.py +1 -1
- streamlit/runtime/uploaded_file_manager.py +4 -2
- streamlit/runtime/websocket_session_manager.py +6 -4
- streamlit/string_util.py +1 -1
- streamlit/testing/v1/app_test.py +4 -2
- streamlit/testing/v1/element_tree.py +33 -37
- streamlit/testing/v1/local_script_runner.py +7 -7
- streamlit/time_util.py +2 -4
- streamlit/type_util.py +16 -29
- streamlit/user_info.py +4 -2
- streamlit/util.py +1 -1
- streamlit/watcher/event_based_path_watcher.py +6 -3
- streamlit/watcher/local_sources_watcher.py +11 -7
- streamlit/web/bootstrap.py +1 -1
- streamlit/web/cache_storage_manager_config.py +5 -1
- streamlit/web/cli.py +9 -4
- streamlit/web/server/browser_websocket_handler.py +7 -8
- streamlit/web/server/component_request_handler.py +4 -2
- streamlit/web/server/routes.py +3 -3
- streamlit/web/server/server.py +12 -12
- streamlit/web/server/server_util.py +5 -6
- streamlit/web/server/stats_request_handler.py +1 -1
- streamlit/web/server/upload_file_request_handler.py +5 -3
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/RECORD +113 -113
- {streamlit_nightly-1.35.1.dev20240610.data → streamlit_nightly-1.35.1.dev20240611.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/top_level.txt +0 -0
streamlit/elements/image.py
CHANGED
@@ -150,7 +150,7 @@ class ImageMixin:
|
|
150
150
|
|
151
151
|
if use_column_width == "auto" or (use_column_width is None and width is None):
|
152
152
|
width = WidthBehaviour.AUTO
|
153
|
-
elif use_column_width == "always" or use_column_width
|
153
|
+
elif use_column_width == "always" or use_column_width is True:
|
154
154
|
width = WidthBehaviour.COLUMN
|
155
155
|
elif width is None:
|
156
156
|
width = WidthBehaviour.ORIGINAL
|
@@ -513,7 +513,7 @@ def marshall_images(
|
|
513
513
|
else:
|
514
514
|
images = [image]
|
515
515
|
|
516
|
-
if
|
516
|
+
if isinstance(caption, list):
|
517
517
|
captions: Sequence[str | None] = caption
|
518
518
|
else:
|
519
519
|
if isinstance(caption, str):
|
@@ -528,7 +528,9 @@ def marshall_images(
|
|
528
528
|
else:
|
529
529
|
captions = [str(caption)]
|
530
530
|
|
531
|
-
assert
|
531
|
+
assert isinstance(
|
532
|
+
captions, list
|
533
|
+
), "If image is a list then caption should be as well"
|
532
534
|
assert len(captions) == len(images), "Cannot pair %d captions with %d images." % (
|
533
535
|
len(captions),
|
534
536
|
len(images),
|
streamlit/elements/layouts.py
CHANGED
@@ -227,9 +227,9 @@ class LayoutsMixin:
|
|
227
227
|
weights = spec
|
228
228
|
weights_exception = StreamlitAPIException(
|
229
229
|
"The input argument to st.columns must be either a "
|
230
|
-
|
231
|
-
|
232
|
-
|
230
|
+
"positive integer or a list of positive numeric weights. "
|
231
|
+
"See [documentation](https://docs.streamlit.io/library/api-reference/layout/st.columns) "
|
232
|
+
"for more information."
|
233
233
|
)
|
234
234
|
|
235
235
|
if isinstance(weights, int):
|
@@ -242,7 +242,7 @@ class LayoutsMixin:
|
|
242
242
|
raise weights_exception
|
243
243
|
|
244
244
|
def column_gap(gap):
|
245
|
-
if
|
245
|
+
if isinstance(gap, str):
|
246
246
|
gap_size = gap.lower()
|
247
247
|
valid_sizes = ["small", "medium", "large"]
|
248
248
|
|
@@ -368,7 +368,7 @@ class LayoutsMixin:
|
|
368
368
|
"The input argument to st.tabs must contain at least one tab label."
|
369
369
|
)
|
370
370
|
|
371
|
-
if any(isinstance(tab, str)
|
371
|
+
if any(not isinstance(tab, str) for tab in tabs):
|
372
372
|
raise StreamlitAPIException(
|
373
373
|
"The tabs input list to st.tabs is only allowed to contain strings."
|
374
374
|
)
|
@@ -490,7 +490,7 @@ class LayoutsMixin:
|
|
490
490
|
help: str | None = None,
|
491
491
|
disabled: bool = False,
|
492
492
|
use_container_width: bool = False,
|
493
|
-
) ->
|
493
|
+
) -> DeltaGenerator:
|
494
494
|
r"""Insert a popover container.
|
495
495
|
|
496
496
|
Inserts a multi-element container as a popover. It consists of a button-like
|
@@ -737,7 +737,7 @@ class LayoutsMixin:
|
|
737
737
|
*,
|
738
738
|
dismissible: bool = True,
|
739
739
|
width: Literal["small", "large"] = "small",
|
740
|
-
) ->
|
740
|
+
) -> Dialog:
|
741
741
|
"""Inserts the dialog container.
|
742
742
|
|
743
743
|
Marked as internal because it is used by the dialog_decorator and is not supposed to be used directly.
|
@@ -88,8 +88,8 @@ class ChartType(Enum):
|
|
88
88
|
# NOTE #2: In theory, we could move COLOR_LEGEND_SETTINGS into
|
89
89
|
# ArrowVegaLiteChart/CustomTheme.tsx, but this would impact existing behavior.
|
90
90
|
# (See https://github.com/streamlit/streamlit/pull/7164#discussion_r1307707345)
|
91
|
-
_COLOR_LEGEND_SETTINGS: Final =
|
92
|
-
_SIZE_LEGEND_SETTINGS: Final =
|
91
|
+
_COLOR_LEGEND_SETTINGS: Final = {"titlePadding": 5, "offset": 5, "orient": "bottom"}
|
92
|
+
_SIZE_LEGEND_SETTINGS: Final = {"titlePadding": 0.5, "offset": 5, "orient": "bottom"}
|
93
93
|
|
94
94
|
# User-readable names to give the index and melted columns.
|
95
95
|
_SEPARATED_INDEX_COLUMN_TITLE: Final = "index"
|
@@ -116,6 +116,8 @@ def generate_chart(
|
|
116
116
|
data: Data | None,
|
117
117
|
x_from_user: str | None = None,
|
118
118
|
y_from_user: str | Sequence[str] | None = None,
|
119
|
+
x_axis_label: str | None = None,
|
120
|
+
y_axis_label: str | None = None,
|
119
121
|
color_from_user: str | Color | list[Color] | None = None,
|
120
122
|
size_from_user: str | float | None = None,
|
121
123
|
width: int | None = None,
|
@@ -146,12 +148,12 @@ def generate_chart(
|
|
146
148
|
# The last index of df so we can adjust the input df in add_rows:
|
147
149
|
last_index=_last_index_for_melted_dataframes(df),
|
148
150
|
# This is the input to prep_data (except for the df):
|
149
|
-
columns=
|
150
|
-
x_column
|
151
|
-
y_column_list
|
152
|
-
color_column
|
153
|
-
size_column
|
154
|
-
|
151
|
+
columns={
|
152
|
+
"x_column": x_column,
|
153
|
+
"y_column_list": y_column_list,
|
154
|
+
"color_column": color_column,
|
155
|
+
"size_column": size_column,
|
156
|
+
},
|
155
157
|
)
|
156
158
|
|
157
159
|
# At this point, all foo_column variables are either None/empty or contain actual
|
@@ -170,8 +172,8 @@ def generate_chart(
|
|
170
172
|
width=width or 0,
|
171
173
|
height=height or 0,
|
172
174
|
).encode(
|
173
|
-
x=_get_x_encoding(df, x_column, x_from_user, chart_type),
|
174
|
-
y=_get_y_encoding(df, y_column, y_from_user),
|
175
|
+
x=_get_x_encoding(df, x_column, x_from_user, x_axis_label, chart_type),
|
176
|
+
y=_get_y_encoding(df, y_column, y_from_user, y_axis_label),
|
175
177
|
)
|
176
178
|
|
177
179
|
# Set up opacity encoding.
|
@@ -539,7 +541,7 @@ def _parse_y_columns(
|
|
539
541
|
y_column_list = [y_from_user]
|
540
542
|
|
541
543
|
elif type_util.is_sequence(y_from_user):
|
542
|
-
y_column_list =
|
544
|
+
y_column_list = [str(col) for col in y_from_user]
|
543
545
|
|
544
546
|
else:
|
545
547
|
raise StreamlitAPIException(
|
@@ -619,6 +621,7 @@ def _get_x_encoding(
|
|
619
621
|
df: pd.DataFrame,
|
620
622
|
x_column: str | None,
|
621
623
|
x_from_user: str | None,
|
624
|
+
x_axis_label: str | None,
|
622
625
|
chart_type: ChartType,
|
623
626
|
) -> alt.X:
|
624
627
|
import altair as alt
|
@@ -646,6 +649,10 @@ def _get_x_encoding(
|
|
646
649
|
else:
|
647
650
|
x_title = x_column
|
648
651
|
|
652
|
+
# User specified x-axis label takes precedence
|
653
|
+
if x_axis_label is not None:
|
654
|
+
x_title = x_axis_label
|
655
|
+
|
649
656
|
return alt.X(
|
650
657
|
x_field,
|
651
658
|
title=x_title,
|
@@ -659,6 +666,7 @@ def _get_y_encoding(
|
|
659
666
|
df: pd.DataFrame,
|
660
667
|
y_column: str | None,
|
661
668
|
y_from_user: str | Sequence[str] | None,
|
669
|
+
y_axis_label: str | None,
|
662
670
|
) -> alt.Y:
|
663
671
|
import altair as alt
|
664
672
|
|
@@ -685,6 +693,10 @@ def _get_y_encoding(
|
|
685
693
|
else:
|
686
694
|
y_title = y_column
|
687
695
|
|
696
|
+
# User specified y-axis label takes precedence
|
697
|
+
if y_axis_label is not None:
|
698
|
+
y_title = y_axis_label
|
699
|
+
|
688
700
|
return alt.Y(
|
689
701
|
field=y_field,
|
690
702
|
title=y_title,
|
@@ -703,7 +715,7 @@ def _get_color_encoding(
|
|
703
715
|
) -> alt.Color | alt.ColorValue | None:
|
704
716
|
import altair as alt
|
705
717
|
|
706
|
-
has_color_value = color_value not in [None, [],
|
718
|
+
has_color_value = color_value not in [None, [], ()] # type: ignore[comparison-overlap]
|
707
719
|
|
708
720
|
# If user passed a color value, that should win over colors coming from the
|
709
721
|
# color column (be they manual or auto-assigned due to melting)
|
@@ -24,13 +24,14 @@ from typing_extensions import TypeAlias
|
|
24
24
|
from streamlit.elements.lib.column_types import ColumnConfig, ColumnType
|
25
25
|
from streamlit.elements.lib.dicttools import remove_none_values
|
26
26
|
from streamlit.errors import StreamlitAPIException
|
27
|
-
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
|
28
27
|
from streamlit.type_util import DataFormat, is_colum_type_arrow_incompatible
|
29
28
|
|
30
29
|
if TYPE_CHECKING:
|
31
30
|
import pyarrow as pa
|
32
31
|
from pandas import DataFrame, Index, Series
|
33
32
|
|
33
|
+
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
|
34
|
+
|
34
35
|
|
35
36
|
# The index identifier can be used to apply configuration options
|
36
37
|
IndexIdentifierType = Literal["_index"]
|
streamlit/elements/lib/dialog.py
CHANGED
@@ -15,18 +15,21 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import time
|
18
|
-
from
|
19
|
-
from typing import Literal, cast
|
18
|
+
from typing import TYPE_CHECKING, Literal, cast
|
20
19
|
|
21
|
-
from typing_extensions import TypeAlias
|
20
|
+
from typing_extensions import Self, TypeAlias
|
22
21
|
|
23
|
-
from streamlit.cursor import Cursor
|
24
22
|
from streamlit.delta_generator import DeltaGenerator, _enqueue_message
|
25
23
|
from streamlit.errors import StreamlitAPIException
|
26
24
|
from streamlit.proto.Block_pb2 import Block as BlockProto
|
27
25
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
28
26
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
29
27
|
|
28
|
+
if TYPE_CHECKING:
|
29
|
+
from types import TracebackType
|
30
|
+
|
31
|
+
from streamlit.cursor import Cursor
|
32
|
+
|
30
33
|
DialogWidth: TypeAlias = Literal["small", "large"]
|
31
34
|
|
32
35
|
|
@@ -132,7 +135,7 @@ class Dialog(DeltaGenerator):
|
|
132
135
|
def close(self) -> None:
|
133
136
|
self._update(False)
|
134
137
|
|
135
|
-
def __enter__(self) ->
|
138
|
+
def __enter__(self) -> Self: # type: ignore[override]
|
136
139
|
# This is a little dubious: we're returning a different type than
|
137
140
|
# our superclass' `__enter__` function. Maybe DeltaGenerator.__enter__
|
138
141
|
# should always return `self`?
|
@@ -56,7 +56,7 @@ def _unflatten_single_dict(flat_dict: dict[Any, Any]) -> dict[Any, Any]:
|
|
56
56
|
A tree made of dicts inside of dicts.
|
57
57
|
|
58
58
|
"""
|
59
|
-
out: dict[str, Any] =
|
59
|
+
out: dict[str, Any] = {}
|
60
60
|
for pathstr, v in flat_dict.items():
|
61
61
|
path = pathstr.split("_")
|
62
62
|
|
@@ -65,7 +65,7 @@ def _unflatten_single_dict(flat_dict: dict[Any, Any]) -> dict[Any, Any]:
|
|
65
65
|
|
66
66
|
for k in path:
|
67
67
|
if k not in curr_dict:
|
68
|
-
curr_dict[k] =
|
68
|
+
curr_dict[k] = {}
|
69
69
|
prev_dict = curr_dict
|
70
70
|
curr_dict = curr_dict[k]
|
71
71
|
|
@@ -133,7 +133,7 @@ def unflatten(
|
|
133
133
|
# Move items into 'encoding' if needed:
|
134
134
|
if k in encodings:
|
135
135
|
if "encoding" not in out_dict:
|
136
|
-
out_dict["encoding"] =
|
136
|
+
out_dict["encoding"] = {}
|
137
137
|
out_dict["encoding"][k] = v
|
138
138
|
out_dict.pop(k)
|
139
139
|
|
@@ -15,17 +15,20 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import time
|
18
|
-
from
|
19
|
-
from typing import Literal, cast
|
18
|
+
from typing import TYPE_CHECKING, Literal, cast
|
20
19
|
|
21
|
-
from typing_extensions import TypeAlias
|
20
|
+
from typing_extensions import Self, TypeAlias
|
22
21
|
|
23
|
-
from streamlit.cursor import Cursor
|
24
22
|
from streamlit.delta_generator import DeltaGenerator, _enqueue_message
|
25
23
|
from streamlit.errors import StreamlitAPIException
|
26
24
|
from streamlit.proto.Block_pb2 import Block as BlockProto
|
27
25
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
28
26
|
|
27
|
+
if TYPE_CHECKING:
|
28
|
+
from types import TracebackType
|
29
|
+
|
30
|
+
from streamlit.cursor import Cursor
|
31
|
+
|
29
32
|
States: TypeAlias = Literal["running", "complete", "error"]
|
30
33
|
|
31
34
|
|
@@ -149,7 +152,7 @@ class StatusContainer(DeltaGenerator):
|
|
149
152
|
self._current_proto = msg.delta.add_block
|
150
153
|
_enqueue_message(msg)
|
151
154
|
|
152
|
-
def __enter__(self) ->
|
155
|
+
def __enter__(self) -> Self: # type: ignore[override]
|
153
156
|
# This is a little dubious: we're returning a different type than
|
154
157
|
# our superclass' `__enter__` function. Maybe DeltaGenerator.__enter__
|
155
158
|
# should always return `self`?
|
@@ -18,12 +18,13 @@ from typing import TYPE_CHECKING, Any, Mapping, TypeVar
|
|
18
18
|
|
19
19
|
from streamlit import type_util
|
20
20
|
from streamlit.errors import StreamlitAPIException
|
21
|
-
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
|
22
21
|
|
23
22
|
if TYPE_CHECKING:
|
24
23
|
from pandas import DataFrame
|
25
24
|
from pandas.io.formats.style import Styler
|
26
25
|
|
26
|
+
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
|
27
|
+
|
27
28
|
|
28
29
|
def marshall_styler(proto: ArrowProto, styler: Styler, default_uuid: str) -> None:
|
29
30
|
"""Marshall pandas.Styler into an Arrow proto.
|
streamlit/elements/lib/utils.py
CHANGED
@@ -15,12 +15,14 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
from enum import Enum, EnumMeta
|
18
|
-
from typing import Any, Iterable, Sequence, overload
|
18
|
+
from typing import TYPE_CHECKING, Any, Iterable, Sequence, overload
|
19
19
|
|
20
20
|
from streamlit import type_util
|
21
21
|
from streamlit.proto.LabelVisibilityMessage_pb2 import LabelVisibilityMessage
|
22
22
|
from streamlit.runtime.state.common import RegisterWidgetResult
|
23
|
-
|
23
|
+
|
24
|
+
if TYPE_CHECKING:
|
25
|
+
from streamlit.type_util import T
|
24
26
|
|
25
27
|
|
26
28
|
def get_label_visibility_proto_value(
|
@@ -43,8 +45,7 @@ def maybe_coerce_enum(
|
|
43
45
|
register_widget_result: RegisterWidgetResult[Enum],
|
44
46
|
options: type[Enum],
|
45
47
|
opt_sequence: Sequence[Any],
|
46
|
-
) -> RegisterWidgetResult[Enum]:
|
47
|
-
...
|
48
|
+
) -> RegisterWidgetResult[Enum]: ...
|
48
49
|
|
49
50
|
|
50
51
|
@overload
|
@@ -52,8 +53,7 @@ def maybe_coerce_enum(
|
|
52
53
|
register_widget_result: RegisterWidgetResult[T],
|
53
54
|
options: type_util.OptionSequence[T],
|
54
55
|
opt_sequence: Sequence[T],
|
55
|
-
) -> RegisterWidgetResult[T]:
|
56
|
-
...
|
56
|
+
) -> RegisterWidgetResult[T]: ...
|
57
57
|
|
58
58
|
|
59
59
|
def maybe_coerce_enum(register_widget_result, options, opt_sequence):
|
@@ -86,8 +86,7 @@ def maybe_coerce_enum_sequence(
|
|
86
86
|
register_widget_result: RegisterWidgetResult[list[T]],
|
87
87
|
options: type_util.OptionSequence[T],
|
88
88
|
opt_sequence: Sequence[T],
|
89
|
-
) -> RegisterWidgetResult[list[T]]:
|
90
|
-
...
|
89
|
+
) -> RegisterWidgetResult[list[T]]: ...
|
91
90
|
|
92
91
|
|
93
92
|
@overload
|
@@ -95,8 +94,7 @@ def maybe_coerce_enum_sequence(
|
|
95
94
|
register_widget_result: RegisterWidgetResult[tuple[T, T]],
|
96
95
|
options: type_util.OptionSequence[T],
|
97
96
|
opt_sequence: Sequence[T],
|
98
|
-
) -> RegisterWidgetResult[tuple[T, T]]:
|
99
|
-
...
|
97
|
+
) -> RegisterWidgetResult[tuple[T, T]]: ...
|
100
98
|
|
101
99
|
|
102
100
|
def maybe_coerce_enum_sequence(register_widget_result, options, opt_sequence):
|
@@ -279,15 +279,13 @@ class PlotlyMixin:
|
|
279
279
|
theme: Literal["streamlit"] | None = "streamlit",
|
280
280
|
key: Key | None = None,
|
281
281
|
on_select: Literal["ignore"], # No default value here to make it work with mypy
|
282
|
-
selection_mode: SelectionMode
|
283
|
-
| Iterable[SelectionMode] = (
|
282
|
+
selection_mode: SelectionMode | Iterable[SelectionMode] = (
|
284
283
|
"points",
|
285
284
|
"box",
|
286
285
|
"lasso",
|
287
286
|
),
|
288
287
|
**kwargs: Any,
|
289
|
-
) -> DeltaGenerator:
|
290
|
-
...
|
288
|
+
) -> DeltaGenerator: ...
|
291
289
|
|
292
290
|
@overload
|
293
291
|
def plotly_chart(
|
@@ -298,15 +296,13 @@ class PlotlyMixin:
|
|
298
296
|
theme: Literal["streamlit"] | None = "streamlit",
|
299
297
|
key: Key | None = None,
|
300
298
|
on_select: Literal["rerun"] | WidgetCallback = "rerun",
|
301
|
-
selection_mode: SelectionMode
|
302
|
-
| Iterable[SelectionMode] = (
|
299
|
+
selection_mode: SelectionMode | Iterable[SelectionMode] = (
|
303
300
|
"points",
|
304
301
|
"box",
|
305
302
|
"lasso",
|
306
303
|
),
|
307
304
|
**kwargs: Any,
|
308
|
-
) -> PlotlyState:
|
309
|
-
...
|
305
|
+
) -> PlotlyState: ...
|
310
306
|
|
311
307
|
@gather_metrics("plotly_chart")
|
312
308
|
def plotly_chart(
|
@@ -317,8 +313,7 @@ class PlotlyMixin:
|
|
317
313
|
theme: Literal["streamlit"] | None = "streamlit",
|
318
314
|
key: Key | None = None,
|
319
315
|
on_select: Literal["rerun", "ignore"] | WidgetCallback = "ignore",
|
320
|
-
selection_mode: SelectionMode
|
321
|
-
| Iterable[SelectionMode] = (
|
316
|
+
selection_mode: SelectionMode | Iterable[SelectionMode] = (
|
322
317
|
"points",
|
323
318
|
"box",
|
324
319
|
"lasso",
|
streamlit/elements/pyplot.py
CHANGED
streamlit/elements/toast.py
CHANGED
@@ -20,16 +20,16 @@ from streamlit.errors import StreamlitAPIException
|
|
20
20
|
from streamlit.proto.Toast_pb2 import Toast as ToastProto
|
21
21
|
from streamlit.runtime.metrics_util import gather_metrics
|
22
22
|
from streamlit.string_util import clean_text, validate_icon_or_emoji
|
23
|
-
from streamlit.type_util import SupportsStr
|
24
23
|
|
25
24
|
if TYPE_CHECKING:
|
26
25
|
from streamlit.delta_generator import DeltaGenerator
|
26
|
+
from streamlit.type_util import SupportsStr
|
27
27
|
|
28
28
|
|
29
29
|
def validate_text(toast_text: SupportsStr) -> SupportsStr:
|
30
30
|
if str(toast_text) == "":
|
31
31
|
raise StreamlitAPIException(
|
32
|
-
|
32
|
+
"Toast body cannot be blank - please provide a message."
|
33
33
|
)
|
34
34
|
else:
|
35
35
|
return toast_text
|
@@ -450,7 +450,7 @@ def _parse_selection_mode(
|
|
450
450
|
|
451
451
|
if selection_mode is None:
|
452
452
|
# Activate all selection parameters:
|
453
|
-
return sorted(
|
453
|
+
return sorted(all_selection_params)
|
454
454
|
|
455
455
|
if isinstance(selection_mode, str):
|
456
456
|
# Convert single string to list:
|
@@ -463,7 +463,7 @@ def _parse_selection_mode(
|
|
463
463
|
f"Selection parameter '{selection_name}' is not defined in the chart spec. "
|
464
464
|
f"Available selection parameters are: {all_selection_params}."
|
465
465
|
)
|
466
|
-
return sorted(
|
466
|
+
return sorted(selection_mode)
|
467
467
|
|
468
468
|
|
469
469
|
def _reset_counter_pattern(prefix: str, vega_spec: str) -> str:
|
@@ -565,6 +565,8 @@ class VegaChartsMixin:
|
|
565
565
|
*,
|
566
566
|
x: str | None = None,
|
567
567
|
y: str | Sequence[str] | None = None,
|
568
|
+
x_label: str | None = None,
|
569
|
+
y_label: str | None = None,
|
568
570
|
color: str | Color | list[Color] | None = None,
|
569
571
|
width: int | None = None,
|
570
572
|
height: int | None = None,
|
@@ -594,6 +596,12 @@ class VegaChartsMixin:
|
|
594
596
|
table into a long-format table behind the scenes. If None, draws
|
595
597
|
the data of all remaining columns as data series.
|
596
598
|
|
599
|
+
x_label : str or None
|
600
|
+
The label for the x-axis. If None, either the column name specified in x will be used, or no label will be displayed.
|
601
|
+
|
602
|
+
y_label : str or None
|
603
|
+
The label for the y-axis. If None, either the column name specified in y will be used, or no label will be displayed.
|
604
|
+
|
597
605
|
color : str, tuple, Sequence of str, Sequence of tuple, or None
|
598
606
|
The color to use for different lines in this chart.
|
599
607
|
|
@@ -717,6 +725,8 @@ class VegaChartsMixin:
|
|
717
725
|
data=data,
|
718
726
|
x_from_user=x,
|
719
727
|
y_from_user=y,
|
728
|
+
x_axis_label=x_label,
|
729
|
+
y_axis_label=y_label,
|
720
730
|
color_from_user=color,
|
721
731
|
size_from_user=None,
|
722
732
|
width=width,
|
@@ -739,6 +749,8 @@ class VegaChartsMixin:
|
|
739
749
|
*,
|
740
750
|
x: str | None = None,
|
741
751
|
y: str | Sequence[str] | None = None,
|
752
|
+
x_label: str | None = None,
|
753
|
+
y_label: str | None = None,
|
742
754
|
color: str | Color | list[Color] | None = None,
|
743
755
|
width: int | None = None,
|
744
756
|
height: int | None = None,
|
@@ -768,6 +780,12 @@ class VegaChartsMixin:
|
|
768
780
|
table into a long-format table behind the scenes. If None, draws
|
769
781
|
the data of all remaining columns as data series.
|
770
782
|
|
783
|
+
x_label : str or None
|
784
|
+
The label for the x-axis. If None, either the column name specified in x will be used, or no label will be displayed.
|
785
|
+
|
786
|
+
y_label : str or None
|
787
|
+
The label for the y-axis. If None, either the column name specified in y will be used, or no label will be displayed.
|
788
|
+
|
771
789
|
color : str, tuple, Sequence of str, Sequence of tuple, or None
|
772
790
|
The color to use for different series in this chart.
|
773
791
|
|
@@ -891,6 +909,8 @@ class VegaChartsMixin:
|
|
891
909
|
data=data,
|
892
910
|
x_from_user=x,
|
893
911
|
y_from_user=y,
|
912
|
+
x_axis_label=x_label,
|
913
|
+
y_axis_label=y_label,
|
894
914
|
color_from_user=color,
|
895
915
|
size_from_user=None,
|
896
916
|
width=width,
|
@@ -913,6 +933,8 @@ class VegaChartsMixin:
|
|
913
933
|
*,
|
914
934
|
x: str | None = None,
|
915
935
|
y: str | Sequence[str] | None = None,
|
936
|
+
x_label: str | None = None,
|
937
|
+
y_label: str | None = None,
|
916
938
|
color: str | Color | list[Color] | None = None,
|
917
939
|
width: int | None = None,
|
918
940
|
height: int | None = None,
|
@@ -942,6 +964,12 @@ class VegaChartsMixin:
|
|
942
964
|
table into a long-format table behind the scenes. If None, draws
|
943
965
|
the data of all remaining columns as data series.
|
944
966
|
|
967
|
+
x_label : str or None
|
968
|
+
The label for the x-axis. If None, either the column name specified in x will be used, or no label will be displayed.
|
969
|
+
|
970
|
+
y_label : str or None
|
971
|
+
The label for the y-axis. If None, either the column name specified in y will be used, or no label will be displayed.
|
972
|
+
|
945
973
|
color : str, tuple, Sequence of str, Sequence of tuple, or None
|
946
974
|
The color to use for different series in this chart.
|
947
975
|
|
@@ -1067,6 +1095,8 @@ class VegaChartsMixin:
|
|
1067
1095
|
data=data,
|
1068
1096
|
x_from_user=x,
|
1069
1097
|
y_from_user=y,
|
1098
|
+
x_axis_label=x_label,
|
1099
|
+
y_axis_label=y_label,
|
1070
1100
|
color_from_user=color,
|
1071
1101
|
size_from_user=None,
|
1072
1102
|
width=width,
|
@@ -1089,6 +1119,8 @@ class VegaChartsMixin:
|
|
1089
1119
|
*,
|
1090
1120
|
x: str | None = None,
|
1091
1121
|
y: str | Sequence[str] | None = None,
|
1122
|
+
x_label: str | None = None,
|
1123
|
+
y_label: str | None = None,
|
1092
1124
|
color: str | Color | list[Color] | None = None,
|
1093
1125
|
size: str | float | int | None = None,
|
1094
1126
|
width: int | None = None,
|
@@ -1119,6 +1151,12 @@ class VegaChartsMixin:
|
|
1119
1151
|
table into a long-format table behind the scenes. If None, draws
|
1120
1152
|
the data of all remaining columns as data series.
|
1121
1153
|
|
1154
|
+
x_label : str or None
|
1155
|
+
The label for the x-axis. If None, either the column name specified in x will be used, or no label will be displayed.
|
1156
|
+
|
1157
|
+
y_label : str or None
|
1158
|
+
The label for the y-axis. If None, either the column name specified in y will be used, or no label will be displayed.
|
1159
|
+
|
1122
1160
|
color : str, tuple, Sequence of str, Sequence of tuple, or None
|
1123
1161
|
The color of the circles representing each datapoint.
|
1124
1162
|
|
@@ -1256,6 +1294,8 @@ class VegaChartsMixin:
|
|
1256
1294
|
data=data,
|
1257
1295
|
x_from_user=x,
|
1258
1296
|
y_from_user=y,
|
1297
|
+
x_axis_label=x_label,
|
1298
|
+
y_axis_label=y_label,
|
1259
1299
|
color_from_user=color,
|
1260
1300
|
size_from_user=size,
|
1261
1301
|
width=width,
|
@@ -1281,8 +1321,7 @@ class VegaChartsMixin:
|
|
1281
1321
|
key: Key | None = None,
|
1282
1322
|
on_select: Literal["ignore"], # No default value here to make it work with mypy
|
1283
1323
|
selection_mode: str | Iterable[str] | None = None,
|
1284
|
-
) -> DeltaGenerator:
|
1285
|
-
...
|
1324
|
+
) -> DeltaGenerator: ...
|
1286
1325
|
|
1287
1326
|
@overload
|
1288
1327
|
def altair_chart(
|
@@ -1294,8 +1333,7 @@ class VegaChartsMixin:
|
|
1294
1333
|
key: Key | None = None,
|
1295
1334
|
on_select: Literal["rerun"] | WidgetCallback = "rerun",
|
1296
1335
|
selection_mode: str | Iterable[str] | None = None,
|
1297
|
-
) -> VegaLiteState:
|
1298
|
-
...
|
1336
|
+
) -> VegaLiteState: ...
|
1299
1337
|
|
1300
1338
|
@gather_metrics("altair_chart")
|
1301
1339
|
def altair_chart(
|
@@ -1435,8 +1473,7 @@ class VegaChartsMixin:
|
|
1435
1473
|
on_select: Literal["ignore"], # No default value here to make it work with mypy
|
1436
1474
|
selection_mode: str | Iterable[str] | None = None,
|
1437
1475
|
**kwargs: Any,
|
1438
|
-
) -> DeltaGenerator:
|
1439
|
-
...
|
1476
|
+
) -> DeltaGenerator: ...
|
1440
1477
|
|
1441
1478
|
@overload
|
1442
1479
|
def vega_lite_chart(
|
@@ -1450,8 +1487,7 @@ class VegaChartsMixin:
|
|
1450
1487
|
on_select: Literal["rerun"] | WidgetCallback = "rerun",
|
1451
1488
|
selection_mode: str | Iterable[str] | None = None,
|
1452
1489
|
**kwargs: Any,
|
1453
|
-
) -> VegaLiteState:
|
1454
|
-
...
|
1490
|
+
) -> VegaLiteState: ...
|
1455
1491
|
|
1456
1492
|
@gather_metrics("vega_lite_chart")
|
1457
1493
|
def vega_lite_chart(
|
@@ -17,9 +17,8 @@ from __future__ import annotations
|
|
17
17
|
import re
|
18
18
|
from dataclasses import dataclass
|
19
19
|
from textwrap import dedent
|
20
|
-
from typing import cast
|
20
|
+
from typing import TYPE_CHECKING, cast
|
21
21
|
|
22
|
-
import streamlit
|
23
22
|
from streamlit.elements.form import current_form_id
|
24
23
|
from streamlit.elements.lib.policies import (
|
25
24
|
check_cache_replay_rules,
|
@@ -41,6 +40,9 @@ from streamlit.runtime.state import (
|
|
41
40
|
from streamlit.runtime.state.common import compute_widget_id
|
42
41
|
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
43
42
|
|
43
|
+
if TYPE_CHECKING:
|
44
|
+
from streamlit.delta_generator import DeltaGenerator
|
45
|
+
|
44
46
|
|
45
47
|
@dataclass
|
46
48
|
class ColorPickerSerde:
|
@@ -253,6 +255,6 @@ class ColorPickerMixin:
|
|
253
255
|
return widget_state.value
|
254
256
|
|
255
257
|
@property
|
256
|
-
def dg(self) ->
|
258
|
+
def dg(self) -> DeltaGenerator:
|
257
259
|
"""Get our DeltaGenerator."""
|
258
|
-
return cast("
|
260
|
+
return cast("DeltaGenerator", self)
|