streamlit-nightly 1.33.1.dev20240415__py2.py3-none-any.whl → 1.33.1.dev20240417__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.
Files changed (45) hide show
  1. streamlit/components/v1/custom_component.py +2 -0
  2. streamlit/delta_generator.py +0 -5
  3. streamlit/elements/__init__.py +0 -57
  4. streamlit/elements/arrow_vega_lite.py +8 -1
  5. streamlit/elements/form.py +5 -1
  6. streamlit/elements/lib/column_types.py +2 -2
  7. streamlit/elements/spinner.py +16 -30
  8. streamlit/elements/utils.py +36 -1
  9. streamlit/elements/widgets/button.py +21 -2
  10. streamlit/elements/widgets/camera_input.py +3 -0
  11. streamlit/elements/widgets/chat.py +8 -1
  12. streamlit/elements/widgets/checkbox.py +3 -1
  13. streamlit/elements/widgets/color_picker.py +3 -0
  14. streamlit/elements/widgets/data_editor.py +10 -1
  15. streamlit/elements/widgets/file_uploader.py +3 -0
  16. streamlit/elements/widgets/multiselect.py +4 -1
  17. streamlit/elements/widgets/number_input.py +3 -0
  18. streamlit/elements/widgets/radio.py +4 -0
  19. streamlit/elements/widgets/select_slider.py +4 -0
  20. streamlit/elements/widgets/selectbox.py +3 -1
  21. streamlit/elements/widgets/slider.py +3 -1
  22. streamlit/elements/widgets/text_widgets.py +4 -2
  23. streamlit/elements/widgets/time_widgets.py +4 -1
  24. streamlit/runtime/caching/__init__.py +1 -19
  25. streamlit/runtime/caching/cache_errors.py +0 -38
  26. streamlit/runtime/caching/cached_message_replay.py +27 -69
  27. streamlit/runtime/fragment.py +1 -1
  28. streamlit/runtime/legacy_caching/__init__.py +2 -12
  29. streamlit/runtime/legacy_caching/caching.py +1 -80
  30. streamlit/runtime/scriptrunner/script_run_context.py +4 -0
  31. streamlit/static/asset-manifest.json +4 -4
  32. streamlit/static/index.html +1 -1
  33. streamlit/static/static/js/3092.152fd2b7.chunk.js +1 -0
  34. streamlit/static/static/js/43.05a14cc7.chunk.js +1 -0
  35. streamlit/static/static/js/{main.4a20073e.js → main.f215a056.js} +2 -2
  36. streamlit/type_util.py +11 -0
  37. {streamlit_nightly-1.33.1.dev20240415.dist-info → streamlit_nightly-1.33.1.dev20240417.dist-info}/METADATA +1 -1
  38. {streamlit_nightly-1.33.1.dev20240415.dist-info → streamlit_nightly-1.33.1.dev20240417.dist-info}/RECORD +43 -43
  39. streamlit/static/static/js/3092.ad569cc8.chunk.js +0 -1
  40. streamlit/static/static/js/43.9ae03282.chunk.js +0 -1
  41. /streamlit/static/static/js/{main.4a20073e.js.LICENSE.txt → main.f215a056.js.LICENSE.txt} +0 -0
  42. {streamlit_nightly-1.33.1.dev20240415.data → streamlit_nightly-1.33.1.dev20240417.data}/scripts/streamlit.cmd +0 -0
  43. {streamlit_nightly-1.33.1.dev20240415.dist-info → streamlit_nightly-1.33.1.dev20240417.dist-info}/WHEEL +0 -0
  44. {streamlit_nightly-1.33.1.dev20240415.dist-info → streamlit_nightly-1.33.1.dev20240417.dist-info}/entry_points.txt +0 -0
  45. {streamlit_nightly-1.33.1.dev20240415.dist-info → streamlit_nightly-1.33.1.dev20240417.dist-info}/top_level.txt +0 -0
@@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, Any
20
20
  from streamlit import _main, type_util
21
21
  from streamlit.components.types.base_custom_component import BaseCustomComponent
22
22
  from streamlit.elements.form import current_form_id
23
+ from streamlit.elements.utils import check_cache_replay_rules
23
24
  from streamlit.errors import StreamlitAPIException
24
25
  from streamlit.proto.Components_pb2 import ArrowTable as ArrowTableProto
25
26
  from streamlit.proto.Components_pb2 import SpecialArg
@@ -101,6 +102,7 @@ PyArrow. To do so locally:
101
102
  And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt."""
102
103
  )
103
104
 
105
+ check_cache_replay_rules()
104
106
  # In addition to the custom kwargs passed to the component, we also
105
107
  # send the special 'default' and 'key' params to the component
106
108
  # frontend.
@@ -528,11 +528,6 @@ class DeltaGenerator(
528
528
  "call your fragment function inside a `with st.sidebar` context manager."
529
529
  )
530
530
 
531
- # Warn if we're called from within a legacy @st.cache function
532
- legacy_caching.maybe_show_cached_st_function_warning(dg, delta_type)
533
- # Warn if we're called from within @st.memo or @st.singleton
534
- caching.maybe_show_cached_st_function_warning(dg, delta_type)
535
-
536
531
  # Warn if an element is being changed but the user isn't running the streamlit server.
537
532
  _maybe_print_use_warning()
538
533
 
@@ -11,60 +11,3 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
-
15
- WIDGETS = [
16
- "button",
17
- "camera_input",
18
- "chat_input",
19
- "checkbox",
20
- "color_picker",
21
- "component_instance",
22
- "download_button",
23
- "file_uploader",
24
- "form",
25
- "multiselect",
26
- "number_input",
27
- "radio",
28
- "selectbox",
29
- "select_slider",
30
- "slider",
31
- "text_input",
32
- "text_area",
33
- "time_input",
34
- "date_input",
35
- ]
36
- NONWIDGET_ELEMENTS = [
37
- "alert",
38
- "arrow_area_chart",
39
- "arrow_bar_chart",
40
- "arrow_data_frame",
41
- "arrow_line_chart",
42
- "arrow_table",
43
- "arrow_vega_lite_chart",
44
- "audio",
45
- "balloons",
46
- "bokeh_chart",
47
- "code",
48
- "deck_gl_json_chart",
49
- "doc_string",
50
- "empty",
51
- "exception",
52
- "graphviz_chart",
53
- "heading",
54
- "iframe",
55
- "imgs",
56
- "json",
57
- # link_button unlike button and download_button is not a widget. It only sends a
58
- # forward messages to the frontend, and not sends trigger value back.
59
- "link_button",
60
- "markdown",
61
- "metric",
62
- "page_link",
63
- "plotly_chart",
64
- "progress",
65
- "pyplot",
66
- "snow",
67
- "text",
68
- "video",
69
- "write",
70
- ]
@@ -155,7 +155,14 @@ def marshall(
155
155
  raise ValueError("Vega-Lite charts require a non-empty spec dict.")
156
156
 
157
157
  if "autosize" not in spec:
158
- spec["autosize"] = {"type": "fit", "contains": "padding"}
158
+ # type fit does not work for many chart types. This change focuses
159
+ # on vconcat with use_container_width=True as there are unintended
160
+ # consequences of changing the default autosize for all charts.
161
+ # fit-x fits the width and height can be adjusted.
162
+ if "vconcat" in spec and use_container_width:
163
+ spec["autosize"] = {"type": "fit-x", "contains": "padding"}
164
+ else:
165
+ spec["autosize"] = {"type": "fit", "contains": "padding"}
159
166
 
160
167
  # Pull data out of spec dict when it's in a 'datasets' key:
161
168
  # marshall(proto, {datasets: {foo: df1, bar: df2}, ...})
@@ -194,11 +194,15 @@ class FormMixin:
194
194
 
195
195
  """
196
196
  # Import this here to avoid circular imports.
197
- from streamlit.elements.utils import check_session_state_rules
197
+ from streamlit.elements.utils import (
198
+ check_cache_replay_rules,
199
+ check_session_state_rules,
200
+ )
198
201
 
199
202
  if is_in_form(self.dg):
200
203
  raise StreamlitAPIException("Forms cannot be nested in other forms.")
201
204
 
205
+ check_cache_replay_rules()
202
206
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
203
207
 
204
208
  # A form is uniquely identified by its key.
@@ -532,8 +532,8 @@ def LinkColumn(
532
532
  * A string that is displayed in every cell, e.g. ``"Open link"``.
533
533
 
534
534
  * A regular expression (JS flavor, detected by usage of parentheses)
535
- to extract a part of the URL via a capture group, e.g. ``"https://(.*?)\.example\.com"``
536
- to extract the display text "foo" from the URL "\https://foo.example.com".
535
+ to extract a part of the URL via a capture group, e.g. ``"https://(.*?)\\.example\\.com"``
536
+ to extract the display text "foo" from the URL "https://foo.example.com".
537
537
 
538
538
  For more complex cases, you may use `Pandas Styler's format \
539
539
  <https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.format.html>`_
@@ -42,20 +42,10 @@ def spinner(text: str = "In progress...", *, _cache: bool = False) -> Iterator[N
42
42
  >>> st.success('Done!')
43
43
 
44
44
  """
45
- import streamlit.runtime.caching as caching
46
- import streamlit.runtime.legacy_caching.caching as legacy_caching
47
45
  from streamlit.proto.Spinner_pb2 import Spinner as SpinnerProto
48
46
  from streamlit.string_util import clean_text
49
47
 
50
- # @st.cache optionally uses spinner for long-running computations.
51
- # Normally, streamlit warns the user when they call st functions
52
- # from within an @st.cache'd function. But we do *not* want to show
53
- # these warnings for spinner's message, so we create and mutate this
54
- # message delta within the "suppress_cached_st_function_warning"
55
- # context.
56
- with legacy_caching.suppress_cached_st_function_warning():
57
- with caching.suppress_cached_st_function_warning():
58
- message = st.empty()
48
+ message = st.empty()
59
49
 
60
50
  # Set the message 0.5 seconds in the future to avoid annoying
61
51
  # flickering if this spinner runs too quickly.
@@ -68,12 +58,10 @@ def spinner(text: str = "In progress...", *, _cache: bool = False) -> Iterator[N
68
58
  def set_message():
69
59
  with display_message_lock:
70
60
  if display_message:
71
- with legacy_caching.suppress_cached_st_function_warning():
72
- with caching.suppress_cached_st_function_warning():
73
- spinner_proto = SpinnerProto()
74
- spinner_proto.text = clean_text(text)
75
- spinner_proto.cache = _cache
76
- message._enqueue("spinner", spinner_proto)
61
+ spinner_proto = SpinnerProto()
62
+ spinner_proto.text = clean_text(text)
63
+ spinner_proto.cache = _cache
64
+ message._enqueue("spinner", spinner_proto)
77
65
 
78
66
  add_script_run_ctx(threading.Timer(DELAY_SECS, set_message)).start()
79
67
 
@@ -83,16 +71,14 @@ def spinner(text: str = "In progress...", *, _cache: bool = False) -> Iterator[N
83
71
  if display_message_lock:
84
72
  with display_message_lock:
85
73
  display_message = False
86
- with legacy_caching.suppress_cached_st_function_warning():
87
- with caching.suppress_cached_st_function_warning():
88
- if "chat_message" in set(message._active_dg._ancestor_block_types):
89
- # Temporary stale element fix:
90
- # For chat messages, we are resetting the spinner placeholder to an
91
- # empty container instead of an empty placeholder (st.empty) to have
92
- # it removed from the delta path. Empty containers are ignored in the
93
- # frontend since they are configured with allow_empty=False. This
94
- # prevents issues with stale elements caused by the spinner being
95
- # rendered only in some situations (e.g. for caching).
96
- message.container()
97
- else:
98
- message.empty()
74
+ if "chat_message" in set(message._active_dg._ancestor_block_types):
75
+ # Temporary stale element fix:
76
+ # For chat messages, we are resetting the spinner placeholder to an
77
+ # empty container instead of an empty placeholder (st.empty) to have
78
+ # it removed from the delta path. Empty containers are ignored in the
79
+ # frontend since they are configured with allow_empty=False. This
80
+ # prevents issues with stale elements caused by the spinner being
81
+ # rendered only in some situations (e.g. for caching).
82
+ message.container()
83
+ else:
84
+ message.empty()
@@ -20,7 +20,7 @@ from typing import TYPE_CHECKING, Any, Hashable, Iterable, Sequence, cast, overl
20
20
  import streamlit
21
21
  from streamlit import config, runtime, type_util
22
22
  from streamlit.elements.form import is_in_form
23
- from streamlit.errors import StreamlitAPIException
23
+ from streamlit.errors import StreamlitAPIException, StreamlitAPIWarning
24
24
  from streamlit.proto.LabelVisibilityMessage_pb2 import LabelVisibilityMessage
25
25
  from streamlit.runtime.state import WidgetCallback, get_session_state
26
26
  from streamlit.runtime.state.common import RegisterWidgetResult
@@ -86,6 +86,41 @@ def check_session_state_rules(
86
86
  _shown_default_value_warning = True
87
87
 
88
88
 
89
+ class CachedWidgetWarning(StreamlitAPIWarning):
90
+ def __init__(self):
91
+ super().__init__(
92
+ """
93
+ Your script uses a widget command in a cached function
94
+ (function decorated with `@st.cache_data` or `@st.cache_resource`).
95
+ This code will only be called when we detect a cache "miss",
96
+ which can lead to unexpected results.
97
+
98
+ How to fix this:
99
+ * Move all widget commands outside the cached function.
100
+ * Or, if you know what you're doing, use `experimental_allow_widgets=True`
101
+ in the cache decorator to enable widget replay and suppress this warning.
102
+ """
103
+ )
104
+
105
+
106
+ def check_cache_replay_rules() -> None:
107
+ """Check if a widget is allowed to be used in the current context.
108
+ More specifically, this checks if the current context is inside a
109
+ cached function that disallows widget usage. If so, it raises a warning.
110
+
111
+ If there are other similar checks in the future, we could extend this
112
+ function to check for those as well. And rename it to check_widget_usage_rules.
113
+ """
114
+ if runtime.exists():
115
+ from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx
116
+
117
+ ctx = get_script_run_ctx()
118
+ if ctx and ctx.disallow_cached_widget_usage:
119
+ # We use an exception here to show a proper stack trace
120
+ # that indicates to the user where the issue is.
121
+ streamlit.exception(CachedWidgetWarning())
122
+
123
+
89
124
  def get_label_visibility_proto_value(
90
125
  label_visibility_string: type_util.LabelVisibility,
91
126
  ) -> LabelVisibilityMessage.LabelVisibilityOptions.ValueType:
@@ -24,7 +24,6 @@ from typing_extensions import TypeAlias
24
24
 
25
25
  from streamlit import runtime, source_util
26
26
  from streamlit.elements.form import current_form_id, is_in_form
27
- from streamlit.elements.utils import check_callback_rules, check_session_state_rules
28
27
  from streamlit.errors import StreamlitAPIException
29
28
  from streamlit.file_util import get_main_script_directory, normalize_path_join
30
29
  from streamlit.proto.Button_pb2 import Button as ButtonProto
@@ -438,7 +437,7 @@ class ButtonMixin:
438
437
  disabled: bool = False,
439
438
  use_container_width: bool | None = None,
440
439
  ) -> DeltaGenerator:
441
- """Display a link to another page in a multipage app or to an external page.
440
+ r"""Display a link to another page in a multipage app or to an external page.
442
441
 
443
442
  If another page in a multipage app is specified, clicking ``st.page_link``
444
443
  stops the current page execution and runs the specified page as if the
@@ -551,7 +550,17 @@ class ButtonMixin:
551
550
  ctx: ScriptRunContext | None = None,
552
551
  ) -> bool:
553
552
  key = to_key(key)
553
+
554
+ # Importing these functions here to avoid circular imports
555
+ from streamlit.elements.utils import (
556
+ check_cache_replay_rules,
557
+ check_callback_rules,
558
+ check_session_state_rules,
559
+ )
560
+
561
+ check_cache_replay_rules()
554
562
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
563
+ check_callback_rules(self.dg, on_click)
555
564
 
556
565
  id = compute_widget_id(
557
566
  "download_button",
@@ -704,8 +713,18 @@ class ButtonMixin:
704
713
  use_container_width: bool = False,
705
714
  ctx: ScriptRunContext | None = None,
706
715
  ) -> bool:
716
+ key = to_key(key)
717
+
718
+ # Importing these functions here to avoid circular imports
719
+ from streamlit.elements.utils import (
720
+ check_cache_replay_rules,
721
+ check_callback_rules,
722
+ check_session_state_rules,
723
+ )
724
+
707
725
  if not is_form_submitter:
708
726
  check_callback_rules(self.dg, on_click)
727
+ check_cache_replay_rules()
709
728
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
710
729
 
711
730
  id = compute_widget_id(
@@ -22,6 +22,7 @@ from typing_extensions import TypeAlias
22
22
 
23
23
  from streamlit.elements.form import current_form_id
24
24
  from streamlit.elements.utils import (
25
+ check_cache_replay_rules,
25
26
  check_callback_rules,
26
27
  check_session_state_rules,
27
28
  get_label_visibility_proto_value,
@@ -195,6 +196,8 @@ class CameraInputMixin:
195
196
  ctx: ScriptRunContext | None = None,
196
197
  ) -> UploadedFile | None:
197
198
  key = to_key(key)
199
+
200
+ check_cache_replay_rules()
198
201
  check_callback_rules(self.dg, on_change)
199
202
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
200
203
  maybe_raise_label_warnings(label, label_visibility)
@@ -21,7 +21,6 @@ from typing import TYPE_CHECKING, Literal, cast
21
21
  from streamlit import runtime
22
22
  from streamlit.elements.form import is_in_form
23
23
  from streamlit.elements.image import AtomicImage, WidthBehaviour, image_to_url
24
- from streamlit.elements.utils import check_callback_rules, check_session_state_rules
25
24
  from streamlit.errors import StreamlitAPIException
26
25
  from streamlit.proto.Block_pb2 import Block as BlockProto
27
26
  from streamlit.proto.ChatInput_pb2 import ChatInput as ChatInputProto
@@ -289,6 +288,14 @@ class ChatMixin:
289
288
  # We default to an empty string here and disallow user choice intentionally
290
289
  default = ""
291
290
  key = to_key(key)
291
+
292
+ from streamlit.elements.utils import (
293
+ check_cache_replay_rules,
294
+ check_callback_rules,
295
+ check_session_state_rules,
296
+ )
297
+
298
+ check_cache_replay_rules()
292
299
  check_callback_rules(self.dg, on_submit)
293
300
  check_session_state_rules(default_value=default, key=key, writes_allowed=False)
294
301
 
@@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, cast
20
20
 
21
21
  from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.utils import (
23
+ check_cache_replay_rules,
23
24
  check_callback_rules,
24
25
  check_session_state_rules,
25
26
  get_label_visibility_proto_value,
@@ -274,11 +275,12 @@ class CheckboxMixin:
274
275
  ctx: ScriptRunContext | None = None,
275
276
  ) -> bool:
276
277
  key = to_key(key)
278
+
279
+ check_cache_replay_rules()
277
280
  check_callback_rules(self.dg, on_change)
278
281
  check_session_state_rules(
279
282
  default_value=None if value is False else value, key=key
280
283
  )
281
-
282
284
  maybe_raise_label_warnings(label, label_visibility)
283
285
 
284
286
  id = compute_widget_id(
@@ -22,6 +22,7 @@ from typing import cast
22
22
  import streamlit
23
23
  from streamlit.elements.form import current_form_id
24
24
  from streamlit.elements.utils import (
25
+ check_cache_replay_rules,
25
26
  check_callback_rules,
26
27
  check_session_state_rules,
27
28
  get_label_visibility_proto_value,
@@ -169,6 +170,8 @@ class ColorPickerMixin:
169
170
  ctx: ScriptRunContext | None = None,
170
171
  ) -> str:
171
172
  key = to_key(key)
173
+
174
+ check_cache_replay_rules()
172
175
  check_callback_rules(self.dg, on_change)
173
176
  check_session_state_rules(default_value=value, key=key)
174
177
  maybe_raise_label_warnings(label, label_visibility)
@@ -55,7 +55,6 @@ from streamlit.elements.lib.column_config_utils import (
55
55
  update_column_config,
56
56
  )
57
57
  from streamlit.elements.lib.pandas_styler_utils import marshall_styler
58
- from streamlit.elements.utils import check_callback_rules, check_session_state_rules
59
58
  from streamlit.errors import StreamlitAPIException
60
59
  from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
61
60
  from streamlit.runtime.metrics_util import gather_metrics
@@ -774,10 +773,20 @@ class DataEditorMixin:
774
773
  height: 350px
775
774
 
776
775
  """
776
+ # Lazy-loaded import
777
777
  import pandas as pd
778
778
  import pyarrow as pa
779
779
 
780
+ # Import here to avoid cyclic import warning
781
+ from streamlit.elements.utils import (
782
+ check_cache_replay_rules,
783
+ check_callback_rules,
784
+ check_session_state_rules,
785
+ )
786
+
780
787
  key = to_key(key)
788
+
789
+ check_cache_replay_rules()
781
790
  check_callback_rules(self.dg, on_change)
782
791
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
783
792
 
@@ -23,6 +23,7 @@ from typing_extensions import TypeAlias
23
23
  from streamlit import config
24
24
  from streamlit.elements.form import current_form_id
25
25
  from streamlit.elements.utils import (
26
+ check_cache_replay_rules,
26
27
  check_callback_rules,
27
28
  check_session_state_rules,
28
29
  get_label_visibility_proto_value,
@@ -398,6 +399,8 @@ class FileUploaderMixin:
398
399
  ctx: ScriptRunContext | None = None,
399
400
  ) -> UploadedFile | list[UploadedFile] | None:
400
401
  key = to_key(key)
402
+
403
+ check_cache_replay_rules()
401
404
  check_callback_rules(self.dg, on_change)
402
405
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
403
406
  maybe_raise_label_warnings(label, label_visibility)
@@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast, overlo
20
20
 
21
21
  from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.utils import (
23
+ check_cache_replay_rules,
23
24
  check_callback_rules,
24
25
  check_session_state_rules,
25
26
  get_label_visibility_proto_value,
@@ -282,12 +283,14 @@ class MultiSelectMixin:
282
283
  ctx: ScriptRunContext | None = None,
283
284
  ) -> list[T]:
284
285
  key = to_key(key)
286
+
287
+ check_cache_replay_rules()
285
288
  check_callback_rules(self.dg, on_change)
286
289
  check_session_state_rules(default_value=default, key=key)
290
+ maybe_raise_label_warnings(label, label_visibility)
287
291
 
288
292
  opt = ensure_indexable(options)
289
293
  check_python_comparable(opt)
290
- maybe_raise_label_warnings(label, label_visibility)
291
294
 
292
295
  indices = _check_and_convert_to_indices(opt, default)
293
296
 
@@ -23,6 +23,7 @@ from typing_extensions import TypeAlias
23
23
 
24
24
  from streamlit.elements.form import current_form_id
25
25
  from streamlit.elements.utils import (
26
+ check_cache_replay_rules,
26
27
  check_callback_rules,
27
28
  check_session_state_rules,
28
29
  get_label_visibility_proto_value,
@@ -277,6 +278,8 @@ class NumberInputMixin:
277
278
  ctx: ScriptRunContext | None = None,
278
279
  ) -> Number | None:
279
280
  key = to_key(key)
281
+
282
+ check_cache_replay_rules()
280
283
  check_callback_rules(self.dg, on_change)
281
284
  check_session_state_rules(
282
285
  default_value=value if value != "min" else None, key=key
@@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
20
20
 
21
21
  from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.utils import (
23
+ check_cache_replay_rules,
23
24
  check_callback_rules,
24
25
  check_session_state_rules,
25
26
  get_label_visibility_proto_value,
@@ -249,9 +250,12 @@ class RadioMixin:
249
250
  ctx: ScriptRunContext | None,
250
251
  ) -> T | None:
251
252
  key = to_key(key)
253
+
254
+ check_cache_replay_rules()
252
255
  check_callback_rules(self.dg, on_change)
253
256
  check_session_state_rules(default_value=None if index == 0 else index, key=key)
254
257
  maybe_raise_label_warnings(label, label_visibility)
258
+
255
259
  opt = ensure_indexable(options)
256
260
  check_python_comparable(opt)
257
261
 
@@ -22,6 +22,7 @@ from typing_extensions import TypeGuard
22
22
 
23
23
  from streamlit.elements.form import current_form_id
24
24
  from streamlit.elements.utils import (
25
+ check_cache_replay_rules,
25
26
  check_callback_rules,
26
27
  check_session_state_rules,
27
28
  get_label_visibility_proto_value,
@@ -256,9 +257,12 @@ class SelectSliderMixin:
256
257
  ctx: ScriptRunContext | None = None,
257
258
  ) -> T | tuple[T, T]:
258
259
  key = to_key(key)
260
+
261
+ check_cache_replay_rules()
259
262
  check_callback_rules(self.dg, on_change)
260
263
  check_session_state_rules(default_value=value, key=key)
261
264
  maybe_raise_label_warnings(label, label_visibility)
265
+
262
266
  opt = ensure_indexable(options)
263
267
  check_python_comparable(opt)
264
268
 
@@ -19,6 +19,7 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
19
19
 
20
20
  from streamlit.elements.form import current_form_id
21
21
  from streamlit.elements.utils import (
22
+ check_cache_replay_rules,
22
23
  check_callback_rules,
23
24
  check_session_state_rules,
24
25
  get_label_visibility_proto_value,
@@ -229,9 +230,10 @@ class SelectboxMixin:
229
230
  ctx: ScriptRunContext | None = None,
230
231
  ) -> T | None:
231
232
  key = to_key(key)
233
+
234
+ check_cache_replay_rules()
232
235
  check_callback_rules(self.dg, on_change)
233
236
  check_session_state_rules(default_value=None if index == 0 else index, key=key)
234
-
235
237
  maybe_raise_label_warnings(label, label_visibility)
236
238
 
237
239
  opt = ensure_indexable(options)
@@ -24,6 +24,7 @@ from typing_extensions import TypeAlias
24
24
 
25
25
  from streamlit.elements.form import current_form_id
26
26
  from streamlit.elements.utils import (
27
+ check_cache_replay_rules,
27
28
  check_callback_rules,
28
29
  check_session_state_rules,
29
30
  get_label_visibility_proto_value,
@@ -364,9 +365,10 @@ class SliderMixin:
364
365
  ctx: ScriptRunContext | None = None,
365
366
  ) -> SliderReturn:
366
367
  key = to_key(key)
368
+
369
+ check_cache_replay_rules()
367
370
  check_callback_rules(self.dg, on_change)
368
371
  check_session_state_rules(default_value=value, key=key)
369
-
370
372
  maybe_raise_label_warnings(label, label_visibility)
371
373
 
372
374
  id = compute_widget_id(
@@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, Literal, cast, overload
20
20
 
21
21
  from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.utils import (
23
+ check_cache_replay_rules,
23
24
  check_callback_rules,
24
25
  check_session_state_rules,
25
26
  get_label_visibility_proto_value,
@@ -254,9 +255,9 @@ class TextWidgetsMixin:
254
255
  ctx: ScriptRunContext | None = None,
255
256
  ) -> str | None:
256
257
  key = to_key(key)
258
+ check_cache_replay_rules()
257
259
  check_callback_rules(self.dg, on_change)
258
260
  check_session_state_rules(default_value=None if value == "" else value, key=key)
259
-
260
261
  maybe_raise_label_warnings(label, label_visibility)
261
262
 
262
263
  # Make sure value is always string or None:
@@ -515,9 +516,10 @@ class TextWidgetsMixin:
515
516
  ctx: ScriptRunContext | None = None,
516
517
  ) -> str | None:
517
518
  key = to_key(key)
519
+
520
+ check_cache_replay_rules()
518
521
  check_callback_rules(self.dg, on_change)
519
522
  check_session_state_rules(default_value=None if value == "" else value, key=key)
520
-
521
523
  maybe_raise_label_warnings(label, label_visibility)
522
524
 
523
525
  value = str(value) if value is not None else None
@@ -33,6 +33,7 @@ from typing_extensions import TypeAlias
33
33
 
34
34
  from streamlit.elements.form import current_form_id
35
35
  from streamlit.elements.utils import (
36
+ check_cache_replay_rules,
36
37
  check_callback_rules,
37
38
  check_session_state_rules,
38
39
  get_label_visibility_proto_value,
@@ -413,6 +414,7 @@ class TimeWidgetsMixin:
413
414
  ctx: ScriptRunContext | None = None,
414
415
  ) -> time | None:
415
416
  key = to_key(key)
417
+ check_cache_replay_rules()
416
418
  check_callback_rules(self.dg, on_change)
417
419
  check_session_state_rules(
418
420
  default_value=value if value != "now" else None, key=key
@@ -668,11 +670,12 @@ class TimeWidgetsMixin:
668
670
  ctx: ScriptRunContext | None = None,
669
671
  ) -> DateWidgetReturn:
670
672
  key = to_key(key)
673
+
674
+ check_cache_replay_rules()
671
675
  check_callback_rules(self.dg, on_change)
672
676
  check_session_state_rules(
673
677
  default_value=value if value != "default_value_today" else None, key=key
674
678
  )
675
-
676
679
  maybe_raise_label_warnings(label, label_visibility)
677
680
 
678
681
  def parse_date_deterministic(
@@ -14,8 +14,7 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- import contextlib
18
- from typing import Any, Iterator
17
+ from typing import Any
19
18
 
20
19
  from google.protobuf.message import Message
21
20
 
@@ -84,21 +83,6 @@ def save_media_data(image_data: bytes | str, mimetype: str, image_id: str) -> No
84
83
  CACHE_RESOURCE_MESSAGE_REPLAY_CTX.save_image_data(image_data, mimetype, image_id)
85
84
 
86
85
 
87
- def maybe_show_cached_st_function_warning(dg, st_func_name: str) -> None:
88
- CACHE_DATA_MESSAGE_REPLAY_CTX.maybe_show_cached_st_function_warning(
89
- dg, st_func_name
90
- )
91
- CACHE_RESOURCE_MESSAGE_REPLAY_CTX.maybe_show_cached_st_function_warning(
92
- dg, st_func_name
93
- )
94
-
95
-
96
- @contextlib.contextmanager
97
- def suppress_cached_st_function_warning() -> Iterator[None]:
98
- with CACHE_DATA_MESSAGE_REPLAY_CTX.suppress_cached_st_function_warning(), CACHE_RESOURCE_MESSAGE_REPLAY_CTX.suppress_cached_st_function_warning():
99
- yield
100
-
101
-
102
86
  # Explicitly export public symbols
103
87
  from streamlit.runtime.caching.cache_data_api import get_data_cache_stats_provider
104
88
  from streamlit.runtime.caching.cache_resource_api import (
@@ -136,8 +120,6 @@ __all__ = [
136
120
  "save_block_message",
137
121
  "save_widget_metadata",
138
122
  "save_media_data",
139
- "maybe_show_cached_st_function_warning",
140
- "suppress_cached_st_function_warning",
141
123
  "get_data_cache_stats_provider",
142
124
  "get_resource_cache_stats_provider",
143
125
  "cache_data",