streamlit-nightly 1.38.1.dev20240909__py2.py3-none-any.whl → 1.38.1.dev20240910__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 +1 -1
- streamlit/cli_util.py +59 -0
- streamlit/commands/experimental_query_params.py +33 -10
- streamlit/commands/page_config.py +6 -3
- streamlit/components/v1/custom_component.py +3 -5
- streamlit/config_option.py +3 -3
- streamlit/delta_generator.py +1 -1
- streamlit/elements/arrow.py +1 -1
- streamlit/elements/form.py +1 -1
- streamlit/elements/lib/built_in_chart_utils.py +1 -2
- streamlit/{color_util.py → elements/lib/color_util.py} +8 -20
- streamlit/elements/lib/options_selector_utils.py +191 -4
- streamlit/elements/lib/policies.py +1 -1
- streamlit/elements/lib/utils.py +11 -168
- streamlit/elements/map.py +6 -1
- streamlit/elements/plotly_chart.py +1 -1
- streamlit/elements/vega_charts.py +2 -2
- streamlit/elements/widgets/button.py +7 -5
- streamlit/elements/widgets/button_group.py +8 -8
- streamlit/elements/widgets/camera_input.py +1 -1
- streamlit/elements/widgets/chat.py +7 -5
- streamlit/elements/widgets/checkbox.py +1 -1
- streamlit/elements/widgets/color_picker.py +1 -1
- streamlit/elements/widgets/data_editor.py +1 -1
- streamlit/elements/widgets/file_uploader.py +1 -1
- streamlit/elements/widgets/multiselect.py +3 -5
- streamlit/elements/widgets/number_input.py +2 -2
- streamlit/elements/widgets/radio.py +3 -6
- streamlit/elements/widgets/select_slider.py +7 -5
- streamlit/elements/widgets/selectbox.py +3 -6
- streamlit/elements/widgets/slider.py +2 -2
- streamlit/elements/widgets/text_widgets.py +1 -1
- streamlit/elements/widgets/time_widgets.py +1 -1
- streamlit/errors.py +22 -0
- streamlit/file_util.py +4 -4
- streamlit/net_util.py +4 -2
- streamlit/runtime/app_session.py +1 -1
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +2 -2
- streamlit/runtime/state/__init__.py +1 -5
- streamlit/runtime/state/common.py +1 -14
- streamlit/runtime/state/query_params.py +9 -2
- streamlit/runtime/state/widgets.py +0 -9
- streamlit/static/asset-manifest.json +19 -19
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/1260.4017a70f.chunk.js +5 -0
- streamlit/static/static/js/{245.532167ed.chunk.js → 245.68a062da.chunk.js} +1 -1
- streamlit/static/static/js/{3156.0542d233.chunk.js → 3156.002c6ee0.chunk.js} +1 -1
- streamlit/static/static/js/3560.ce031236.chunk.js +1 -0
- streamlit/static/static/js/{4103.2a961369.chunk.js → 4103.d863052a.chunk.js} +1 -1
- streamlit/static/static/js/{5180.5e064ef1.chunk.js → 5180.e826dd46.chunk.js} +1 -1
- streamlit/static/static/js/5618.08be9e66.chunk.js +5 -0
- streamlit/static/static/js/{5625.0394ecdc.chunk.js → 5625.3a8dc81f.chunk.js} +1 -1
- streamlit/static/static/js/{5711.28939a95.chunk.js → 5711.2f36e813.chunk.js} +1 -1
- streamlit/static/static/js/6088.c137d543.chunk.js +1 -0
- streamlit/static/static/js/{6360.17e58a87.chunk.js → 6360.6d7cfa35.chunk.js} +1 -1
- streamlit/static/static/js/{7193.bc9bdd04.chunk.js → 7193.2594a18c.chunk.js} +1 -1
- streamlit/static/static/js/8166.11abccb8.chunk.js +1 -0
- streamlit/static/static/js/{8237.ed5d881b.chunk.js → 8237.210a5ac4.chunk.js} +1 -1
- streamlit/static/static/js/8815.0284d089.chunk.js +1 -0
- streamlit/static/static/js/9114.1ee3d4dd.chunk.js +1 -0
- streamlit/static/static/js/954.3cc76210.chunk.js +5 -0
- streamlit/static/static/js/{main.5d1dd93c.js → main.7b7fe9ac.js} +2 -2
- streamlit/string_util.py +13 -5
- streamlit/time_util.py +3 -14
- streamlit/util.py +1 -127
- streamlit/watcher/local_sources_watcher.py +1 -1
- streamlit/web/bootstrap.py +2 -2
- streamlit/web/cli.py +2 -2
- {streamlit_nightly-1.38.1.dev20240909.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.38.1.dev20240909.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/RECORD +79 -82
- streamlit/case_converters.py +0 -91
- streamlit/code_util.py +0 -90
- streamlit/constants.py +0 -19
- streamlit/static/static/js/1260.5ebd5704.chunk.js +0 -5
- streamlit/static/static/js/3560.17463b1c.chunk.js +0 -1
- streamlit/static/static/js/5618.6d42e995.chunk.js +0 -5
- streamlit/static/static/js/6088.00849717.chunk.js +0 -1
- streamlit/static/static/js/8166.0d1971ea.chunk.js +0 -1
- streamlit/static/static/js/8815.0b7dc879.chunk.js +0 -1
- streamlit/static/static/js/9114.c676bef4.chunk.js +0 -1
- streamlit/static/static/js/954.bf90fe19.chunk.js +0 -5
- /streamlit/{echo.py → commands/echo.py} +0 -0
- /streamlit/elements/{form_utils.py → lib/form_utils.py} +0 -0
- /streamlit/{js_number.py → elements/lib/js_number.py} +0 -0
- /streamlit/static/static/js/{main.5d1dd93c.js.LICENSE.txt → main.7b7fe9ac.js.LICENSE.txt} +0 -0
- /streamlit/{folder_black_list.py → watcher/folder_black_list.py} +0 -0
- {streamlit_nightly-1.38.1.dev20240909.data → streamlit_nightly-1.38.1.dev20240910.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.38.1.dev20240909.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.38.1.dev20240909.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.38.1.dev20240909.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/top_level.txt +0 -0
streamlit/elements/lib/utils.py
CHANGED
@@ -16,15 +16,11 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
import hashlib
|
18
18
|
from datetime import date, datetime, time, timedelta
|
19
|
-
from enum import Enum, EnumMeta
|
20
19
|
from typing import (
|
21
20
|
TYPE_CHECKING,
|
22
21
|
Any,
|
23
|
-
Final,
|
24
22
|
Iterable,
|
25
23
|
Literal,
|
26
|
-
Sequence,
|
27
|
-
TypeVar,
|
28
24
|
Union,
|
29
25
|
overload,
|
30
26
|
)
|
@@ -32,15 +28,16 @@ from typing import (
|
|
32
28
|
from google.protobuf.message import Message
|
33
29
|
from typing_extensions import TypeAlias
|
34
30
|
|
35
|
-
from streamlit import config
|
31
|
+
from streamlit import config
|
36
32
|
from streamlit.errors import StreamlitDuplicateElementId, StreamlitDuplicateElementKey
|
37
33
|
from streamlit.proto.LabelVisibilityMessage_pb2 import LabelVisibilityMessage
|
38
34
|
from streamlit.runtime.scriptrunner_utils.script_run_context import (
|
35
|
+
ScriptRunContext,
|
39
36
|
get_script_run_ctx,
|
40
37
|
)
|
41
38
|
from streamlit.runtime.state.common import (
|
42
39
|
GENERATED_ELEMENT_ID_PREFIX,
|
43
|
-
|
40
|
+
TESTING_KEY,
|
44
41
|
user_key_from_element_id,
|
45
42
|
)
|
46
43
|
from streamlit.util import HASHLIB_KWARGS
|
@@ -48,10 +45,6 @@ from streamlit.util import HASHLIB_KWARGS
|
|
48
45
|
if TYPE_CHECKING:
|
49
46
|
from builtins import ellipsis
|
50
47
|
|
51
|
-
from streamlit.runtime.state.widgets import NoValue
|
52
|
-
from streamlit.type_util import T
|
53
|
-
|
54
|
-
_LOGGER: Final = logger.get_logger(__name__)
|
55
48
|
|
56
49
|
Key: TypeAlias = Union[str, int]
|
57
50
|
|
@@ -64,7 +57,6 @@ SAFE_VALUES = Union[
|
|
64
57
|
datetime,
|
65
58
|
timedelta,
|
66
59
|
None,
|
67
|
-
"NoValue",
|
68
60
|
"ellipsis",
|
69
61
|
Message,
|
70
62
|
PROTO_SCALAR_VALUE,
|
@@ -98,163 +90,6 @@ def to_key(key: Key | None) -> str | None:
|
|
98
90
|
return None if key is None else str(key)
|
99
91
|
|
100
92
|
|
101
|
-
E1 = TypeVar("E1", bound=Enum)
|
102
|
-
E2 = TypeVar("E2", bound=Enum)
|
103
|
-
|
104
|
-
_ALLOWED_ENUM_COERCION_CONFIG_SETTINGS = ("off", "nameOnly", "nameAndValue")
|
105
|
-
|
106
|
-
|
107
|
-
def _coerce_enum(from_enum_value: E1, to_enum_class: type[E2]) -> E1 | E2:
|
108
|
-
"""Attempt to coerce an Enum value to another EnumMeta.
|
109
|
-
|
110
|
-
An Enum value of EnumMeta E1 is considered coercable to EnumType E2
|
111
|
-
if the EnumMeta __qualname__ match and the names of their members
|
112
|
-
match as well. (This is configurable in streamlist configs)
|
113
|
-
"""
|
114
|
-
if not isinstance(from_enum_value, Enum):
|
115
|
-
raise ValueError(
|
116
|
-
f"Expected an Enum in the first argument. Got {type(from_enum_value)}"
|
117
|
-
)
|
118
|
-
if not isinstance(to_enum_class, EnumMeta):
|
119
|
-
raise ValueError(
|
120
|
-
f"Expected an EnumMeta/Type in the second argument. Got {type(to_enum_class)}"
|
121
|
-
)
|
122
|
-
if isinstance(from_enum_value, to_enum_class):
|
123
|
-
return from_enum_value # Enum is already a member, no coersion necessary
|
124
|
-
|
125
|
-
coercion_type = config.get_option("runner.enumCoercion")
|
126
|
-
if coercion_type not in _ALLOWED_ENUM_COERCION_CONFIG_SETTINGS:
|
127
|
-
raise errors.StreamlitAPIException(
|
128
|
-
"Invalid value for config option runner.enumCoercion. "
|
129
|
-
f"Expected one of {_ALLOWED_ENUM_COERCION_CONFIG_SETTINGS}, "
|
130
|
-
f"but got '{coercion_type}'."
|
131
|
-
)
|
132
|
-
if coercion_type == "off":
|
133
|
-
return from_enum_value # do not attempt to coerce
|
134
|
-
|
135
|
-
# We now know this is an Enum AND the user has configured coercion enabled.
|
136
|
-
# Check if we do NOT meet the required conditions and log a failure message
|
137
|
-
# if that is the case.
|
138
|
-
from_enum_class = from_enum_value.__class__
|
139
|
-
if (
|
140
|
-
from_enum_class.__qualname__ != to_enum_class.__qualname__
|
141
|
-
or (
|
142
|
-
coercion_type == "nameOnly"
|
143
|
-
and set(to_enum_class._member_names_) != set(from_enum_class._member_names_)
|
144
|
-
)
|
145
|
-
or (
|
146
|
-
coercion_type == "nameAndValue"
|
147
|
-
and set(to_enum_class._value2member_map_)
|
148
|
-
!= set(from_enum_class._value2member_map_)
|
149
|
-
)
|
150
|
-
):
|
151
|
-
_LOGGER.debug("Failed to coerce %s to class %s", from_enum_value, to_enum_class)
|
152
|
-
return from_enum_value # do not attempt to coerce
|
153
|
-
|
154
|
-
# At this point we think the Enum is coercable, and we know
|
155
|
-
# E1 and E2 have the same member names. We convert from E1 to E2 using _name_
|
156
|
-
# (since user Enum subclasses can override the .name property in 3.11)
|
157
|
-
_LOGGER.debug("Coerced %s to class %s", from_enum_value, to_enum_class)
|
158
|
-
return to_enum_class[from_enum_value._name_]
|
159
|
-
|
160
|
-
|
161
|
-
@overload
|
162
|
-
def maybe_coerce_enum(
|
163
|
-
register_widget_result: RegisterWidgetResult[Enum],
|
164
|
-
options: type[Enum],
|
165
|
-
opt_sequence: Sequence[Any],
|
166
|
-
) -> RegisterWidgetResult[Enum]: ...
|
167
|
-
|
168
|
-
|
169
|
-
@overload
|
170
|
-
def maybe_coerce_enum(
|
171
|
-
register_widget_result: RegisterWidgetResult[T],
|
172
|
-
options: dataframe_util.OptionSequence[T],
|
173
|
-
opt_sequence: Sequence[T],
|
174
|
-
) -> RegisterWidgetResult[T]: ...
|
175
|
-
|
176
|
-
|
177
|
-
def maybe_coerce_enum(register_widget_result, options, opt_sequence):
|
178
|
-
"""Maybe Coerce a RegisterWidgetResult with an Enum member value to
|
179
|
-
RegisterWidgetResult[option] if option is an EnumType, otherwise just return
|
180
|
-
the original RegisterWidgetResult."""
|
181
|
-
|
182
|
-
# If the value is not a Enum, return early
|
183
|
-
if not isinstance(register_widget_result.value, Enum):
|
184
|
-
return register_widget_result
|
185
|
-
|
186
|
-
coerce_class: EnumMeta | None
|
187
|
-
if isinstance(options, EnumMeta):
|
188
|
-
coerce_class = options
|
189
|
-
else:
|
190
|
-
coerce_class = _extract_common_class_from_iter(opt_sequence)
|
191
|
-
if coerce_class is None:
|
192
|
-
return register_widget_result
|
193
|
-
|
194
|
-
return RegisterWidgetResult(
|
195
|
-
_coerce_enum(register_widget_result.value, coerce_class),
|
196
|
-
register_widget_result.value_changed,
|
197
|
-
)
|
198
|
-
|
199
|
-
|
200
|
-
# slightly ugly typing because TypeVars with Generic Bounds are not supported
|
201
|
-
# (https://github.com/python/typing/issues/548)
|
202
|
-
@overload
|
203
|
-
def maybe_coerce_enum_sequence(
|
204
|
-
register_widget_result: RegisterWidgetResult[list[T]],
|
205
|
-
options: dataframe_util.OptionSequence[T],
|
206
|
-
opt_sequence: Sequence[T],
|
207
|
-
) -> RegisterWidgetResult[list[T]]: ...
|
208
|
-
|
209
|
-
|
210
|
-
@overload
|
211
|
-
def maybe_coerce_enum_sequence(
|
212
|
-
register_widget_result: RegisterWidgetResult[tuple[T, T]],
|
213
|
-
options: dataframe_util.OptionSequence[T],
|
214
|
-
opt_sequence: Sequence[T],
|
215
|
-
) -> RegisterWidgetResult[tuple[T, T]]: ...
|
216
|
-
|
217
|
-
|
218
|
-
def maybe_coerce_enum_sequence(register_widget_result, options, opt_sequence):
|
219
|
-
"""Maybe Coerce a RegisterWidgetResult with a sequence of Enum members as value
|
220
|
-
to RegisterWidgetResult[Sequence[option]] if option is an EnumType, otherwise just return
|
221
|
-
the original RegisterWidgetResult."""
|
222
|
-
|
223
|
-
# If not all widget values are Enums, return early
|
224
|
-
if not all(isinstance(val, Enum) for val in register_widget_result.value):
|
225
|
-
return register_widget_result
|
226
|
-
|
227
|
-
# Extract the class to coerce
|
228
|
-
coerce_class: EnumMeta | None
|
229
|
-
if isinstance(options, EnumMeta):
|
230
|
-
coerce_class = options
|
231
|
-
else:
|
232
|
-
coerce_class = _extract_common_class_from_iter(opt_sequence)
|
233
|
-
if coerce_class is None:
|
234
|
-
return register_widget_result
|
235
|
-
|
236
|
-
# Return a new RegisterWidgetResult with the coerced enum values sequence
|
237
|
-
return RegisterWidgetResult(
|
238
|
-
type(register_widget_result.value)(
|
239
|
-
_coerce_enum(val, coerce_class) for val in register_widget_result.value
|
240
|
-
),
|
241
|
-
register_widget_result.value_changed,
|
242
|
-
)
|
243
|
-
|
244
|
-
|
245
|
-
def _extract_common_class_from_iter(iterable: Iterable[Any]) -> Any:
|
246
|
-
"""Return the common class of all elements in a iterable if they share one.
|
247
|
-
Otherwise, return None."""
|
248
|
-
try:
|
249
|
-
inner_iter = iter(iterable)
|
250
|
-
first_class = type(next(inner_iter))
|
251
|
-
except StopIteration:
|
252
|
-
return None
|
253
|
-
if all(type(item) is first_class for item in inner_iter):
|
254
|
-
return first_class
|
255
|
-
return None
|
256
|
-
|
257
|
-
|
258
93
|
def _register_element_id(element_type: str, element_id: str) -> None:
|
259
94
|
"""Register the element ID and key for the given element.
|
260
95
|
|
@@ -344,3 +179,11 @@ def compute_and_register_element_id(
|
|
344
179
|
element_id = _compute_element_id(element_type, user_key, **kwargs)
|
345
180
|
_register_element_id(element_type, element_id)
|
346
181
|
return element_id
|
182
|
+
|
183
|
+
|
184
|
+
def save_for_app_testing(ctx: ScriptRunContext, k: str, v: Any):
|
185
|
+
if config.get_option("global.appTest"):
|
186
|
+
try:
|
187
|
+
ctx.session_state[TESTING_KEY][k] = v
|
188
|
+
except KeyError:
|
189
|
+
ctx.session_state[TESTING_KEY] = {k: v}
|
streamlit/elements/map.py
CHANGED
@@ -22,7 +22,12 @@ from typing import TYPE_CHECKING, Any, Collection, Final, cast
|
|
22
22
|
|
23
23
|
import streamlit.elements.deck_gl_json_chart as deck_gl_json_chart
|
24
24
|
from streamlit import config, dataframe_util
|
25
|
-
from streamlit.color_util import
|
25
|
+
from streamlit.elements.lib.color_util import (
|
26
|
+
Color,
|
27
|
+
IntColorTuple,
|
28
|
+
is_color_like,
|
29
|
+
to_int_color_tuple,
|
30
|
+
)
|
26
31
|
from streamlit.errors import StreamlitAPIException
|
27
32
|
from streamlit.proto.DeckGlJsonChart_pb2 import DeckGlJsonChart as DeckGlJsonChartProto
|
28
33
|
from streamlit.runtime.metrics_util import gather_metrics
|
@@ -36,8 +36,8 @@ from typing_extensions import TypeAlias
|
|
36
36
|
|
37
37
|
from streamlit import type_util
|
38
38
|
from streamlit.deprecation_util import show_deprecation_warning
|
39
|
-
from streamlit.elements.form_utils import current_form_id
|
40
39
|
from streamlit.elements.lib.event_utils import AttributeDictionary
|
40
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
41
41
|
from streamlit.elements.lib.policies import check_widget_policies
|
42
42
|
from streamlit.elements.lib.streamlit_plotly_theme import (
|
43
43
|
configure_streamlit_plotly_theme,
|
@@ -37,7 +37,6 @@ from typing_extensions import TypeAlias
|
|
37
37
|
|
38
38
|
import streamlit.elements.lib.dicttools as dicttools
|
39
39
|
from streamlit import dataframe_util, type_util
|
40
|
-
from streamlit.elements.form_utils import current_form_id
|
41
40
|
from streamlit.elements.lib.built_in_chart_utils import (
|
42
41
|
AddRowsMetadata,
|
43
42
|
ChartStackType,
|
@@ -46,6 +45,7 @@ from streamlit.elements.lib.built_in_chart_utils import (
|
|
46
45
|
maybe_raise_stack_warning,
|
47
46
|
)
|
48
47
|
from streamlit.elements.lib.event_utils import AttributeDictionary
|
48
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
49
49
|
from streamlit.elements.lib.policies import check_widget_policies
|
50
50
|
from streamlit.elements.lib.utils import Key, compute_and_register_element_id, to_key
|
51
51
|
from streamlit.errors import StreamlitAPIException
|
@@ -60,9 +60,9 @@ from streamlit.util import HASHLIB_KWARGS
|
|
60
60
|
if TYPE_CHECKING:
|
61
61
|
import altair as alt
|
62
62
|
|
63
|
-
from streamlit.color_util import Color
|
64
63
|
from streamlit.dataframe_util import Data
|
65
64
|
from streamlit.delta_generator import DeltaGenerator
|
65
|
+
from streamlit.elements.lib.color_util import Color
|
66
66
|
|
67
67
|
# See https://vega.github.io/vega-lite/docs/encoding.html
|
68
68
|
_CHANNELS: Final = {
|
@@ -31,9 +31,14 @@ from typing import (
|
|
31
31
|
from typing_extensions import TypeAlias
|
32
32
|
|
33
33
|
from streamlit import runtime
|
34
|
-
from streamlit.elements.form_utils import current_form_id, is_in_form
|
34
|
+
from streamlit.elements.lib.form_utils import current_form_id, is_in_form
|
35
35
|
from streamlit.elements.lib.policies import check_widget_policies
|
36
|
-
from streamlit.elements.lib.utils import
|
36
|
+
from streamlit.elements.lib.utils import (
|
37
|
+
Key,
|
38
|
+
compute_and_register_element_id,
|
39
|
+
save_for_app_testing,
|
40
|
+
to_key,
|
41
|
+
)
|
37
42
|
from streamlit.errors import (
|
38
43
|
StreamlitAPIException,
|
39
44
|
StreamlitMissingPageLabelError,
|
@@ -53,9 +58,6 @@ from streamlit.runtime.state import (
|
|
53
58
|
WidgetKwargs,
|
54
59
|
register_widget,
|
55
60
|
)
|
56
|
-
from streamlit.runtime.state.common import (
|
57
|
-
save_for_app_testing,
|
58
|
-
)
|
59
61
|
from streamlit.string_util import validate_icon_or_emoji
|
60
62
|
from streamlit.url_util import is_url
|
61
63
|
|
@@ -26,16 +26,17 @@ from typing import (
|
|
26
26
|
overload,
|
27
27
|
)
|
28
28
|
|
29
|
-
from streamlit.elements.form_utils import current_form_id
|
29
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
30
30
|
from streamlit.elements.lib.options_selector_utils import (
|
31
31
|
convert_to_sequence_and_check_comparable,
|
32
32
|
get_default_indices,
|
33
|
+
maybe_coerce_enum_sequence,
|
33
34
|
)
|
34
35
|
from streamlit.elements.lib.policies import check_widget_policies
|
35
36
|
from streamlit.elements.lib.utils import (
|
36
37
|
Key,
|
37
38
|
compute_and_register_element_id,
|
38
|
-
|
39
|
+
save_for_app_testing,
|
39
40
|
to_key,
|
40
41
|
)
|
41
42
|
from streamlit.elements.widgets.multiselect import MultiSelectSerde
|
@@ -44,12 +45,6 @@ from streamlit.proto.ButtonGroup_pb2 import ButtonGroup as ButtonGroupProto
|
|
44
45
|
from streamlit.runtime.metrics_util import gather_metrics
|
45
46
|
from streamlit.runtime.scriptrunner_utils.script_run_context import get_script_run_ctx
|
46
47
|
from streamlit.runtime.state import register_widget
|
47
|
-
from streamlit.runtime.state.common import (
|
48
|
-
RegisterWidgetResult,
|
49
|
-
WidgetDeserializer,
|
50
|
-
WidgetSerializer,
|
51
|
-
save_for_app_testing,
|
52
|
-
)
|
53
48
|
|
54
49
|
if TYPE_CHECKING:
|
55
50
|
from streamlit.dataframe_util import OptionSequence
|
@@ -59,6 +54,11 @@ if TYPE_CHECKING:
|
|
59
54
|
WidgetCallback,
|
60
55
|
WidgetKwargs,
|
61
56
|
)
|
57
|
+
from streamlit.runtime.state.common import (
|
58
|
+
RegisterWidgetResult,
|
59
|
+
WidgetDeserializer,
|
60
|
+
WidgetSerializer,
|
61
|
+
)
|
62
62
|
from streamlit.type_util import T
|
63
63
|
|
64
64
|
|
@@ -20,7 +20,7 @@ from typing import TYPE_CHECKING, Union, cast
|
|
20
20
|
|
21
21
|
from typing_extensions import TypeAlias
|
22
22
|
|
23
|
-
from streamlit.elements.form_utils import current_form_id
|
23
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
24
24
|
from streamlit.elements.lib.policies import (
|
25
25
|
check_widget_policies,
|
26
26
|
maybe_raise_label_warnings,
|
@@ -20,10 +20,15 @@ from typing import TYPE_CHECKING, Literal, cast
|
|
20
20
|
|
21
21
|
from streamlit import runtime
|
22
22
|
from streamlit.delta_generator_singletons import get_dg_singleton_instance
|
23
|
-
from streamlit.elements.form_utils import is_in_form
|
24
23
|
from streamlit.elements.image import AtomicImage, WidthBehaviour, image_to_url
|
24
|
+
from streamlit.elements.lib.form_utils import is_in_form
|
25
25
|
from streamlit.elements.lib.policies import check_widget_policies
|
26
|
-
from streamlit.elements.lib.utils import
|
26
|
+
from streamlit.elements.lib.utils import (
|
27
|
+
Key,
|
28
|
+
compute_and_register_element_id,
|
29
|
+
save_for_app_testing,
|
30
|
+
to_key,
|
31
|
+
)
|
27
32
|
from streamlit.errors import StreamlitAPIException
|
28
33
|
from streamlit.proto.Block_pb2 import Block as BlockProto
|
29
34
|
from streamlit.proto.ChatInput_pb2 import ChatInput as ChatInputProto
|
@@ -37,9 +42,6 @@ from streamlit.runtime.state import (
|
|
37
42
|
WidgetKwargs,
|
38
43
|
register_widget,
|
39
44
|
)
|
40
|
-
from streamlit.runtime.state.common import (
|
41
|
-
save_for_app_testing,
|
42
|
-
)
|
43
45
|
from streamlit.string_util import is_emoji, validate_material_icon
|
44
46
|
|
45
47
|
if TYPE_CHECKING:
|
@@ -18,7 +18,7 @@ from dataclasses import dataclass
|
|
18
18
|
from textwrap import dedent
|
19
19
|
from typing import TYPE_CHECKING, cast
|
20
20
|
|
21
|
-
from streamlit.elements.form_utils import current_form_id
|
21
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
22
22
|
from streamlit.elements.lib.policies import (
|
23
23
|
check_widget_policies,
|
24
24
|
maybe_raise_label_warnings,
|
@@ -19,7 +19,7 @@ from dataclasses import dataclass
|
|
19
19
|
from textwrap import dedent
|
20
20
|
from typing import TYPE_CHECKING, cast
|
21
21
|
|
22
|
-
from streamlit.elements.form_utils import current_form_id
|
22
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
23
23
|
from streamlit.elements.lib.policies import (
|
24
24
|
check_widget_policies,
|
25
25
|
maybe_raise_label_warnings,
|
@@ -39,7 +39,6 @@ from typing_extensions import TypeAlias
|
|
39
39
|
|
40
40
|
from streamlit import dataframe_util
|
41
41
|
from streamlit import logger as _logger
|
42
|
-
from streamlit.elements.form_utils import current_form_id
|
43
42
|
from streamlit.elements.lib.column_config_utils import (
|
44
43
|
INDEX_IDENTIFIER,
|
45
44
|
ColumnConfigMapping,
|
@@ -53,6 +52,7 @@ from streamlit.elements.lib.column_config_utils import (
|
|
53
52
|
process_config_mapping,
|
54
53
|
update_column_config,
|
55
54
|
)
|
55
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
56
56
|
from streamlit.elements.lib.pandas_styler_utils import marshall_styler
|
57
57
|
from streamlit.elements.lib.policies import check_widget_policies
|
58
58
|
from streamlit.elements.lib.utils import Key, compute_and_register_element_id, to_key
|
@@ -21,7 +21,7 @@ from typing import TYPE_CHECKING, List, Literal, Sequence, Union, cast, overload
|
|
21
21
|
from typing_extensions import TypeAlias
|
22
22
|
|
23
23
|
from streamlit import config
|
24
|
-
from streamlit.elements.form_utils import current_form_id
|
24
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
25
25
|
from streamlit.elements.lib.policies import (
|
26
26
|
check_widget_policies,
|
27
27
|
maybe_raise_label_warnings,
|
@@ -19,11 +19,12 @@ from textwrap import dedent
|
|
19
19
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
|
20
20
|
|
21
21
|
from streamlit.dataframe_util import OptionSequence
|
22
|
-
from streamlit.elements.form_utils import current_form_id
|
22
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
23
23
|
from streamlit.elements.lib.options_selector_utils import (
|
24
24
|
check_and_convert_to_indices,
|
25
25
|
convert_to_sequence_and_check_comparable,
|
26
26
|
get_default_indices,
|
27
|
+
maybe_coerce_enum_sequence,
|
27
28
|
)
|
28
29
|
from streamlit.elements.lib.policies import (
|
29
30
|
check_widget_policies,
|
@@ -34,7 +35,7 @@ from streamlit.elements.lib.utils import (
|
|
34
35
|
LabelVisibility,
|
35
36
|
compute_and_register_element_id,
|
36
37
|
get_label_visibility_proto_value,
|
37
|
-
|
38
|
+
save_for_app_testing,
|
38
39
|
to_key,
|
39
40
|
)
|
40
41
|
from streamlit.errors import (
|
@@ -44,9 +45,6 @@ from streamlit.proto.MultiSelect_pb2 import MultiSelect as MultiSelectProto
|
|
44
45
|
from streamlit.runtime.metrics_util import gather_metrics
|
45
46
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
46
47
|
from streamlit.runtime.state import register_widget
|
47
|
-
from streamlit.runtime.state.common import (
|
48
|
-
save_for_app_testing,
|
49
|
-
)
|
50
48
|
from streamlit.type_util import (
|
51
49
|
T,
|
52
50
|
is_iterable,
|
@@ -21,7 +21,8 @@ from typing import TYPE_CHECKING, Literal, TypeVar, Union, cast, overload
|
|
21
21
|
|
22
22
|
from typing_extensions import TypeAlias
|
23
23
|
|
24
|
-
from streamlit.elements.form_utils import current_form_id
|
24
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
25
|
+
from streamlit.elements.lib.js_number import JSNumber, JSNumberBoundsException
|
25
26
|
from streamlit.elements.lib.policies import (
|
26
27
|
check_widget_policies,
|
27
28
|
maybe_raise_label_warnings,
|
@@ -40,7 +41,6 @@ from streamlit.errors import (
|
|
40
41
|
StreamlitValueAboveMaxError,
|
41
42
|
StreamlitValueBelowMinError,
|
42
43
|
)
|
43
|
-
from streamlit.js_number import JSNumber, JSNumberBoundsException
|
44
44
|
from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
|
45
45
|
from streamlit.runtime.metrics_util import gather_metrics
|
46
46
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
@@ -19,7 +19,8 @@ from textwrap import dedent
|
|
19
19
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast, overload
|
20
20
|
|
21
21
|
from streamlit.dataframe_util import OptionSequence, convert_anything_to_list
|
22
|
-
from streamlit.elements.form_utils import current_form_id
|
22
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
23
|
+
from streamlit.elements.lib.options_selector_utils import index_, maybe_coerce_enum
|
23
24
|
from streamlit.elements.lib.policies import (
|
24
25
|
check_widget_policies,
|
25
26
|
maybe_raise_label_warnings,
|
@@ -29,7 +30,7 @@ from streamlit.elements.lib.utils import (
|
|
29
30
|
LabelVisibility,
|
30
31
|
compute_and_register_element_id,
|
31
32
|
get_label_visibility_proto_value,
|
32
|
-
|
33
|
+
save_for_app_testing,
|
33
34
|
to_key,
|
34
35
|
)
|
35
36
|
from streamlit.errors import StreamlitAPIException
|
@@ -43,14 +44,10 @@ from streamlit.runtime.state import (
|
|
43
44
|
get_session_state,
|
44
45
|
register_widget,
|
45
46
|
)
|
46
|
-
from streamlit.runtime.state.common import (
|
47
|
-
save_for_app_testing,
|
48
|
-
)
|
49
47
|
from streamlit.type_util import (
|
50
48
|
T,
|
51
49
|
check_python_comparable,
|
52
50
|
)
|
53
|
-
from streamlit.util import index_
|
54
51
|
|
55
52
|
if TYPE_CHECKING:
|
56
53
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -30,7 +30,12 @@ from typing import (
|
|
30
30
|
from typing_extensions import TypeGuard
|
31
31
|
|
32
32
|
from streamlit.dataframe_util import OptionSequence, convert_anything_to_list
|
33
|
-
from streamlit.elements.form_utils import current_form_id
|
33
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
34
|
+
from streamlit.elements.lib.options_selector_utils import (
|
35
|
+
index_,
|
36
|
+
maybe_coerce_enum,
|
37
|
+
maybe_coerce_enum_sequence,
|
38
|
+
)
|
34
39
|
from streamlit.elements.lib.policies import (
|
35
40
|
check_widget_policies,
|
36
41
|
maybe_raise_label_warnings,
|
@@ -40,8 +45,7 @@ from streamlit.elements.lib.utils import (
|
|
40
45
|
LabelVisibility,
|
41
46
|
compute_and_register_element_id,
|
42
47
|
get_label_visibility_proto_value,
|
43
|
-
|
44
|
-
maybe_coerce_enum_sequence,
|
48
|
+
save_for_app_testing,
|
45
49
|
to_key,
|
46
50
|
)
|
47
51
|
from streamlit.errors import StreamlitAPIException
|
@@ -56,10 +60,8 @@ from streamlit.runtime.state import (
|
|
56
60
|
)
|
57
61
|
from streamlit.runtime.state.common import (
|
58
62
|
RegisterWidgetResult,
|
59
|
-
save_for_app_testing,
|
60
63
|
)
|
61
64
|
from streamlit.type_util import T, check_python_comparable
|
62
|
-
from streamlit.util import index_
|
63
65
|
|
64
66
|
if TYPE_CHECKING:
|
65
67
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -18,7 +18,8 @@ from textwrap import dedent
|
|
18
18
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast, overload
|
19
19
|
|
20
20
|
from streamlit.dataframe_util import OptionSequence, convert_anything_to_list
|
21
|
-
from streamlit.elements.form_utils import current_form_id
|
21
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
22
|
+
from streamlit.elements.lib.options_selector_utils import index_, maybe_coerce_enum
|
22
23
|
from streamlit.elements.lib.policies import (
|
23
24
|
check_widget_policies,
|
24
25
|
maybe_raise_label_warnings,
|
@@ -28,7 +29,7 @@ from streamlit.elements.lib.utils import (
|
|
28
29
|
LabelVisibility,
|
29
30
|
compute_and_register_element_id,
|
30
31
|
get_label_visibility_proto_value,
|
31
|
-
|
32
|
+
save_for_app_testing,
|
32
33
|
to_key,
|
33
34
|
)
|
34
35
|
from streamlit.errors import StreamlitAPIException
|
@@ -42,14 +43,10 @@ from streamlit.runtime.state import (
|
|
42
43
|
get_session_state,
|
43
44
|
register_widget,
|
44
45
|
)
|
45
|
-
from streamlit.runtime.state.common import (
|
46
|
-
save_for_app_testing,
|
47
|
-
)
|
48
46
|
from streamlit.type_util import (
|
49
47
|
T,
|
50
48
|
check_python_comparable,
|
51
49
|
)
|
52
|
-
from streamlit.util import index_
|
53
50
|
|
54
51
|
if TYPE_CHECKING:
|
55
52
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -33,7 +33,8 @@ from typing import (
|
|
33
33
|
|
34
34
|
from typing_extensions import TypeAlias
|
35
35
|
|
36
|
-
from streamlit.elements.form_utils import current_form_id
|
36
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
37
|
+
from streamlit.elements.lib.js_number import JSNumber, JSNumberBoundsException
|
37
38
|
from streamlit.elements.lib.policies import (
|
38
39
|
check_widget_policies,
|
39
40
|
maybe_raise_label_warnings,
|
@@ -46,7 +47,6 @@ from streamlit.elements.lib.utils import (
|
|
46
47
|
to_key,
|
47
48
|
)
|
48
49
|
from streamlit.errors import StreamlitAPIException
|
49
|
-
from streamlit.js_number import JSNumber, JSNumberBoundsException
|
50
50
|
from streamlit.proto.Slider_pb2 import Slider as SliderProto
|
51
51
|
from streamlit.runtime.metrics_util import gather_metrics
|
52
52
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
@@ -18,7 +18,7 @@ from dataclasses import dataclass
|
|
18
18
|
from textwrap import dedent
|
19
19
|
from typing import TYPE_CHECKING, Literal, cast, overload
|
20
20
|
|
21
|
-
from streamlit.elements.form_utils import current_form_id
|
21
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
22
22
|
from streamlit.elements.lib.policies import (
|
23
23
|
check_widget_policies,
|
24
24
|
maybe_raise_label_warnings,
|
@@ -32,7 +32,7 @@ from typing import (
|
|
32
32
|
|
33
33
|
from typing_extensions import TypeAlias
|
34
34
|
|
35
|
-
from streamlit.elements.form_utils import current_form_id
|
35
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
36
36
|
from streamlit.elements.lib.policies import (
|
37
37
|
check_widget_policies,
|
38
38
|
maybe_raise_label_warnings,
|
streamlit/errors.py
CHANGED
@@ -430,3 +430,25 @@ class StreamlitValueAssignmentNotAllowedError(LocalizableStreamlitException):
|
|
430
430
|
"Values for the widget with `key` '{key}' cannot be set using `st.session_state`.",
|
431
431
|
key=key,
|
432
432
|
)
|
433
|
+
|
434
|
+
|
435
|
+
class StreamlitInvalidColorError(LocalizableStreamlitException):
|
436
|
+
def __init__(self, color):
|
437
|
+
super().__init__(
|
438
|
+
"This does not look like a valid color: {color}.\n\n"
|
439
|
+
"Colors must be in one of the following formats:"
|
440
|
+
"* Hex string with 3, 4, 6, or 8 digits. Example: `'#00ff00'`"
|
441
|
+
"* List or tuple with 3 or 4 components. Example: `[1.0, 0.5, 0, 0.2]`",
|
442
|
+
color=repr(color),
|
443
|
+
)
|
444
|
+
|
445
|
+
|
446
|
+
class StreamlitBadTimeStringError(LocalizableStreamlitException):
|
447
|
+
"""Exception Raised when a time string argument is passed that cannot be parsed."""
|
448
|
+
|
449
|
+
def __init__(self, time_string: str):
|
450
|
+
super().__init__(
|
451
|
+
"Time string doesn't look right. It should be formatted as"
|
452
|
+
"`'1d2h34m'` or `2 days`, for example. Got: {time_string}",
|
453
|
+
time_string=time_string,
|
454
|
+
)
|