streamlit-nightly 1.43.3.dev20250311__py3-none-any.whl → 1.43.3.dev20250313__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 (159) hide show
  1. streamlit/__init__.py +1 -0
  2. streamlit/auth_util.py +2 -1
  3. streamlit/commands/experimental_query_params.py +1 -1
  4. streamlit/commands/logo.py +3 -3
  5. streamlit/components/v1/__init__.py +1 -3
  6. streamlit/config.py +3 -2
  7. streamlit/config_option.py +1 -3
  8. streamlit/connections/snowflake_connection.py +0 -1
  9. streamlit/connections/sql_connection.py +0 -1
  10. streamlit/dataframe_util.py +7 -6
  11. streamlit/delta_generator_singletons.py +2 -2
  12. streamlit/elements/arrow.py +0 -1
  13. streamlit/elements/exception.py +3 -1
  14. streamlit/elements/form.py +3 -3
  15. streamlit/elements/json.py +2 -2
  16. streamlit/elements/layouts.py +0 -5
  17. streamlit/elements/lib/built_in_chart_utils.py +1 -2
  18. streamlit/elements/lib/column_config_utils.py +0 -3
  19. streamlit/elements/lib/column_types.py +6 -39
  20. streamlit/elements/lib/image_utils.py +2 -1
  21. streamlit/elements/lib/options_selector_utils.py +6 -3
  22. streamlit/elements/lib/subtitle_utils.py +2 -0
  23. streamlit/elements/lib/utils.py +0 -2
  24. streamlit/elements/markdown.py +98 -2
  25. streamlit/elements/media.py +2 -1
  26. streamlit/elements/metric.py +0 -1
  27. streamlit/elements/progress.py +1 -1
  28. streamlit/elements/text.py +2 -2
  29. streamlit/elements/vega_charts.py +2 -1
  30. streamlit/elements/widgets/audio_input.py +2 -1
  31. streamlit/elements/widgets/button.py +0 -1
  32. streamlit/elements/widgets/button_group.py +2 -3
  33. streamlit/elements/widgets/data_editor.py +2 -3
  34. streamlit/elements/widgets/slider.py +1 -1
  35. streamlit/elements/widgets/text_widgets.py +1 -0
  36. streamlit/elements/write.py +0 -1
  37. streamlit/errors.py +11 -2
  38. streamlit/external/langchain/streamlit_callback_handler.py +1 -2
  39. streamlit/file_util.py +4 -2
  40. streamlit/navigation/page.py +0 -1
  41. streamlit/platform.py +1 -3
  42. streamlit/runtime/caching/cache_data_api.py +5 -5
  43. streamlit/runtime/caching/cache_errors.py +1 -1
  44. streamlit/runtime/caching/cache_resource_api.py +4 -4
  45. streamlit/runtime/caching/cache_utils.py +6 -4
  46. streamlit/runtime/caching/storage/cache_storage_protocol.py +6 -6
  47. streamlit/runtime/caching/storage/dummy_cache_storage.py +2 -2
  48. streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +6 -6
  49. streamlit/runtime/caching/storage/local_disk_cache_storage.py +6 -6
  50. streamlit/runtime/connection_factory.py +0 -1
  51. streamlit/runtime/context.py +1 -1
  52. streamlit/runtime/credentials.py +1 -1
  53. streamlit/runtime/forward_msg_cache.py +1 -1
  54. streamlit/runtime/forward_msg_queue.py +2 -1
  55. streamlit/runtime/fragment.py +2 -1
  56. streamlit/runtime/memory_media_file_storage.py +2 -2
  57. streamlit/runtime/metrics_util.py +2 -2
  58. streamlit/runtime/runtime_util.py +1 -1
  59. streamlit/runtime/scriptrunner/script_runner.py +1 -1
  60. streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
  61. streamlit/runtime/scriptrunner_utils/script_run_context.py +1 -0
  62. streamlit/runtime/secrets.py +28 -31
  63. streamlit/runtime/state/common.py +1 -1
  64. streamlit/runtime/state/safe_session_state.py +1 -1
  65. streamlit/runtime/state/session_state.py +4 -3
  66. streamlit/runtime/stats.py +1 -1
  67. streamlit/runtime/uploaded_file_manager.py +4 -3
  68. streamlit/static/index.html +1 -1
  69. streamlit/static/static/js/{FileDownload.esm.B-R2xJ_2.js → FileDownload.esm.imTamlxP.js} +1 -1
  70. streamlit/static/static/js/{FileHelper.Dpame4Yy.js → FileHelper.BwPSCUvG.js} +1 -1
  71. streamlit/static/static/js/{FormClearHelper.CJtgEcyv.js → FormClearHelper.DB5q2Avl.js} +1 -1
  72. streamlit/static/static/js/{Hooks.eMU4yP9C.js → Hooks.Cxijo2P7.js} +1 -1
  73. streamlit/static/static/js/{InputInstructions.Bt5nMAh-.js → InputInstructions.B3OvMrKL.js} +1 -1
  74. streamlit/static/static/js/{ProgressBar.CRfY498S.js → ProgressBar.DmTol130.js} +1 -1
  75. streamlit/static/static/js/{RenderInPortalIfExists.CjsBZs42.js → RenderInPortalIfExists.B8t62565.js} +1 -1
  76. streamlit/static/static/js/{Toolbar.CBmSHKas.js → Toolbar.CbG49UPG.js} +1 -1
  77. streamlit/static/static/js/{base-input.pwi2uHY4.js → base-input.D7sJ1S2g.js} +1 -1
  78. streamlit/static/static/js/{checkbox.BRMCIUrT.js → checkbox.0Qx7AQxA.js} +1 -1
  79. streamlit/static/static/js/{createSuper.BT2FfU2u.js → createSuper.DYiyAta_.js} +1 -1
  80. streamlit/static/static/js/{data-grid-overlay-editor.DR231PaH.js → data-grid-overlay-editor.DH61CZYo.js} +1 -1
  81. streamlit/static/static/js/{downloader.Cwh9Q8n3.js → downloader.ClUad3SK.js} +1 -1
  82. streamlit/static/static/js/{es6.DXFo1lzk.js → es6.oePMPTIo.js} +2 -2
  83. streamlit/static/static/js/{iframeResizer.contentWindow.BqHH3gN-.js → iframeResizer.contentWindow.DWkIX4K7.js} +1 -1
  84. streamlit/static/static/js/{index.SGdFItlP.js → index.1VrMb7Gq.js} +1 -1
  85. streamlit/static/static/js/index.62zz5frt.js +1 -0
  86. streamlit/static/static/js/index.BJRyQckV.js +1 -0
  87. streamlit/static/static/js/{index.C8ZQWk_P.js → index.BQVZQA1G.js} +1 -1
  88. streamlit/static/static/js/{index.-J5N3GRT.js → index.BSZRb65z.js} +1 -1
  89. streamlit/static/static/js/{index.oH2t20_d.js → index.BUJE3tb_.js} +1 -1
  90. streamlit/static/static/js/{index.DAIPHdqL.js → index.BWsaTYC-.js} +1 -1
  91. streamlit/static/static/js/{index.B9ftDzXT.js → index.BccrUqFL.js} +1 -1
  92. streamlit/static/static/js/index.BhzKPoO6.js +1 -0
  93. streamlit/static/static/js/{index._HJ2bgYb.js → index.BpNXx3zc.js} +6 -6
  94. streamlit/static/static/js/{index.DzJ-K9FH.js → index.BzEstIKX.js} +1 -1
  95. streamlit/static/static/js/{index.Cqy-AKUq.js → index.C-ilKj2l.js} +1 -1
  96. streamlit/static/static/js/{index.DBAW0l2y.js → index.CCAIkxXD.js} +2367 -1541
  97. streamlit/static/static/js/{index.DklFRDjI.js → index.CEXlj4h2.js} +1 -1
  98. streamlit/static/static/js/{index.E4BOW70b.js → index.CEtBn4Yo.js} +1 -1
  99. streamlit/static/static/js/{index.Y1Qnwm4b.js → index.CM7PC5PD.js} +1 -1
  100. streamlit/static/static/js/{index.BAQ_1jSz.js → index.CSLXWDcG.js} +1 -1
  101. streamlit/static/static/js/{index.7mbSZESp.js → index.CqywW5KK.js} +1 -1
  102. streamlit/static/static/js/{index.DGe1v1i2.js → index.CyRCgpSs.js} +1 -1
  103. streamlit/static/static/js/{index.BiPCWEUM.js → index.CzFs8nXc.js} +45 -45
  104. streamlit/static/static/js/{index.DTC2KQEB.js → index.Czxn5B2N.js} +1 -1
  105. streamlit/static/static/js/{index.BhhnIkTX.js → index.D0OLo5Dp.js} +1 -1
  106. streamlit/static/static/js/{index.DC7tm9ca.js → index.D2JlVfHE.js} +1 -1
  107. streamlit/static/static/js/{index.BtuGy7By.js → index.D8rVyQy1.js} +2 -2
  108. streamlit/static/static/js/{index.BN2fMHzp.js → index.DJRmF7dm.js} +1 -1
  109. streamlit/static/static/js/{index.eHde7unb.js → index.Dd9D963h.js} +1 -1
  110. streamlit/static/static/js/{index.CtDd3Kvg.js → index.DhcpqbOJ.js} +1 -1
  111. streamlit/static/static/js/{index.DJZrR-yh.js → index.DlEF0vUx.js} +1 -1
  112. streamlit/static/static/js/{index.pfdwKIIK.js → index.DnJimAdR.js} +1 -1
  113. streamlit/static/static/js/index.DoqMrowT.js +1 -0
  114. streamlit/static/static/js/{index.B71BDPil.js → index.DqsHy8ck.js} +1 -1
  115. streamlit/static/static/js/{index.DbtNEUBr.js → index.DtS10fdK.js} +1 -1
  116. streamlit/static/static/js/{index.BtaSeLy3.js → index.XZw2NTV4.js} +1 -1
  117. streamlit/static/static/js/index.YB9Oe71d.js +1 -0
  118. streamlit/static/static/js/{index.Bt4_I4Hr.js → index.axjxDsFs.js} +1 -1
  119. streamlit/static/static/js/{index.CKLHvpe_.js → index.kB2IGVOe.js} +1 -1
  120. streamlit/static/static/js/{index.ClCou1d2.js → index.tVO_vJdT.js} +1 -1
  121. streamlit/static/static/js/{index.DIxz2WrU.js → index.uPQFE7KD.js} +1 -1
  122. streamlit/static/static/js/{input.Rf6xGN5X.js → input.od7ufwko.js} +1 -1
  123. streamlit/static/static/js/{memory.D5NLCYdA.js → memory.B4tdC6o-.js} +1 -1
  124. streamlit/static/static/js/{mergeWith.Bcdwg8Ac.js → mergeWith.BIQlVIWW.js} +1 -1
  125. streamlit/static/static/js/{number-overlay-editor.CCjfRIEO.js → number-overlay-editor.yJDCpy9b.js} +1 -1
  126. streamlit/static/static/js/{possibleConstructorReturn.B8bXiVQj.js → possibleConstructorReturn.CarGSmuW.js} +1 -1
  127. streamlit/static/static/js/{sandbox.lrrkbqxh.js → sandbox.DMCKOK6i.js} +1 -1
  128. streamlit/static/static/js/{textarea.DCEYRe9D.js → textarea.CKKbJt6B.js} +1 -1
  129. streamlit/static/static/js/{timepicker.DpQ3WAC_.js → timepicker.BgsARtBm.js} +1 -1
  130. streamlit/static/static/js/{toConsumableArray.EduObuzm.js → toConsumableArray.DXHhbr1a.js} +1 -1
  131. streamlit/static/static/js/{uniqueId.qyd-2U_A.js → uniqueId.Cb5oTCCd.js} +1 -1
  132. streamlit/static/static/js/{useBasicWidgetState.B0zc_tpZ.js → useBasicWidgetState.8rZ80dWq.js} +1 -1
  133. streamlit/static/static/js/{useOnInputChange.tzktvOeD.js → useOnInputChange.Bc5KC47X.js} +1 -1
  134. streamlit/static/static/js/{withFullScreenWrapper.TezXOJ_z.js → withFullScreenWrapper.CSP3iCNz.js} +1 -1
  135. streamlit/string_util.py +3 -2
  136. streamlit/testing/v1/element_tree.py +30 -30
  137. streamlit/testing/v1/util.py +2 -1
  138. streamlit/time_util.py +1 -3
  139. streamlit/type_util.py +2 -1
  140. streamlit/user_info.py +0 -1
  141. streamlit/watcher/event_based_path_watcher.py +1 -1
  142. streamlit/web/bootstrap.py +3 -1
  143. streamlit/web/cache_storage_manager_config.py +1 -1
  144. streamlit/web/cli.py +44 -2
  145. streamlit/web/server/authlib_tornado_integration.py +1 -1
  146. streamlit/web/server/browser_websocket_handler.py +2 -1
  147. streamlit/web/server/routes.py +2 -2
  148. streamlit/web/server/server_util.py +2 -4
  149. {streamlit_nightly-1.43.3.dev20250311.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/METADATA +1 -1
  150. {streamlit_nightly-1.43.3.dev20250311.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/RECORD +154 -154
  151. streamlit/static/static/js/index.BMcgy3Eb.js +0 -1
  152. streamlit/static/static/js/index.COJ2HeaK.js +0 -1
  153. streamlit/static/static/js/index.D6iEZATu.js +0 -1
  154. streamlit/static/static/js/index.DuXQiNfC.js +0 -1
  155. streamlit/static/static/js/index.Fi_0UKZA.js +0 -1
  156. {streamlit_nightly-1.43.3.dev20250311.data → streamlit_nightly-1.43.3.dev20250313.data}/scripts/streamlit.cmd +0 -0
  157. {streamlit_nightly-1.43.3.dev20250311.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/WHEEL +0 -0
  158. {streamlit_nightly-1.43.3.dev20250311.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/entry_points.txt +0 -0
  159. {streamlit_nightly-1.43.3.dev20250311.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/top_level.txt +0 -0
@@ -114,7 +114,6 @@ def _register_element_id(
114
114
 
115
115
  Parameters
116
116
  ----------
117
-
118
117
  element_type : str
119
118
  The type of the element to register.
120
119
 
@@ -123,7 +122,6 @@ def _register_element_id(
123
122
 
124
123
  Raises
125
124
  ------
126
-
127
125
  StreamlitDuplicateElementKey
128
126
  If the element key is not unique.
129
127
 
@@ -14,11 +14,11 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- from typing import TYPE_CHECKING, Final, cast
17
+ from typing import TYPE_CHECKING, Final, Literal, cast
18
18
 
19
19
  from streamlit.proto.Markdown_pb2 import Markdown as MarkdownProto
20
20
  from streamlit.runtime.metrics_util import gather_metrics
21
- from streamlit.string_util import clean_text
21
+ from streamlit.string_util import clean_text, validate_icon_or_emoji
22
22
  from streamlit.type_util import SupportsStr, is_sympy_expression
23
23
 
24
24
  if TYPE_CHECKING:
@@ -80,8 +80,14 @@ class MarkdownMixin:
80
80
  primary accent color unless you set the ``theme.primaryColor``
81
81
  configuration option.
82
82
 
83
+ - Colored badges, using the syntax ``:color-badge[text in the badge]``.
84
+ Supported colors are: blue, green, orange, red, violet, gray/grey,
85
+ or primary. For example, you can use ``:orange-badge[your text here]``
86
+ or ``:blue-badge[your text here]``.
87
+
83
88
  - Small text, using the syntax ``:small[text to show small]``.
84
89
 
90
+
85
91
  unsafe_allow_html : bool
86
92
  Whether to render HTML within ``body``. If this is ``False``
87
93
  (default), any HTML tags found in ``body`` will be escaped and
@@ -271,6 +277,96 @@ class MarkdownMixin:
271
277
  divider_proto.element_type = MarkdownProto.Type.DIVIDER
272
278
  return self.dg._enqueue("markdown", divider_proto)
273
279
 
280
+ @gather_metrics("badge")
281
+ def badge(
282
+ self,
283
+ label: str,
284
+ *, # keyword-only arguments:
285
+ icon: str | None = None,
286
+ color: Literal[
287
+ "blue",
288
+ "green",
289
+ "orange",
290
+ "red",
291
+ "violet",
292
+ "gray",
293
+ "grey",
294
+ "rainbow",
295
+ "primary",
296
+ ] = "blue",
297
+ ) -> DeltaGenerator:
298
+ """Display a colored badge with an icon and label.
299
+
300
+ You can also insert badges directly in Markdown, e.g. via
301
+ `st.markdown(":blue-badge[Home]")`. This works in all places where Streamlit
302
+ supports Markdown, e.g. widget labels or `st.table` cells. See `st.markdown`
303
+ for more information.
304
+
305
+ Parameters
306
+ ----------
307
+ label : str
308
+ The label to display in the badge. The label can optionally contain
309
+ GitHub-flavored Markdown of the following types: Bold, Italics,
310
+ Strikethroughs, Inline Code.
311
+
312
+ See the ``body`` parameter of |st.markdown|_ for additional,
313
+ supported Markdown directives.
314
+
315
+ .. |st.markdown| replace:: ``st.markdown``
316
+ .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
317
+
318
+ icon : str or None
319
+ An optional emoji or icon to display next to the badge label. If
320
+ ``icon`` is ``None`` (default), no icon is displayed. If ``icon``
321
+ is a string, the following options are valid:
322
+
323
+ - A single-character emoji. For example, you can set ``icon="🚨"``
324
+ or ``icon="🔥"``. Emoji short codes are not supported.
325
+
326
+ - An icon from the Material Symbols library (rounded style) in the
327
+ format ``":material/icon_name:"`` where "icon_name" is the name
328
+ of the icon in snake case.
329
+
330
+ For example, ``icon=":material/thumb_up:"`` will display the
331
+ Thumb Up icon. Find additional icons in the `Material Symbols \
332
+ <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
333
+ font library.
334
+
335
+ color : str
336
+ The color to use for the badge. Supported colors are: blue, green,
337
+ orange, red, violet, gray/grey, primary.
338
+ If you use "primary" for color, Streamlit will use the default
339
+ primary accent color unless you set the ``theme.primaryColor``
340
+ configuration option.
341
+
342
+ Examples
343
+ --------
344
+ >>> import streamlit as st
345
+ >>>
346
+ >>> # Simple badge
347
+ >>> st.badge("Home")
348
+ >>>
349
+ >>> # Badge with icon and color
350
+ >>> st.badge("Success", icon=":material/check:", color="green")
351
+ >>>
352
+ >>> # Multiple badges side by side in Markdown
353
+ >>> st.markdown(
354
+ ... "Here are some badges: :orange-badge[⭐️ Favorite] :blue-badge[🏠 Home] :green-badge[✅ Success]"
355
+ ... )
356
+ """
357
+ if icon is not None:
358
+ icon_str = validate_icon_or_emoji(icon) + " "
359
+ else:
360
+ icon_str = ""
361
+
362
+ # Escape [ and ] characters in the label to prevent breaking the directive syntax
363
+ escaped_label = label.replace("[", "\\[").replace("]", "\\]")
364
+
365
+ badge_proto = MarkdownProto()
366
+ badge_proto.body = f":{color}-badge[{icon_str}{escaped_label}]"
367
+ badge_proto.element_type = MarkdownProto.Type.NATIVE
368
+ return self.dg._enqueue("markdown", badge_proto)
369
+
274
370
  @property
275
371
  def dg(self) -> DeltaGenerator:
276
372
  """Get our DeltaGenerator."""
@@ -693,7 +693,8 @@ def _validate_and_normalize(data: npt.NDArray[Any]) -> tuple[bytes, int]:
693
693
 
694
694
  def _make_wav(data: npt.NDArray[Any], sample_rate: int) -> bytes:
695
695
  """
696
- Transform a numpy array to a PCM bytestring
696
+ Transform a numpy array to a PCM bytestring.
697
+
697
698
  We use code from IPython display module to convert numpy array to wave bytes
698
699
  https://github.com/ipython/ipython/blob/1015c392f3d50cf4ff3e9f29beede8c1abfdcb2a/IPython/lib/display.py#L146
699
700
  """
@@ -124,7 +124,6 @@ class MetricMixin:
124
124
 
125
125
  Examples
126
126
  --------
127
-
128
127
  **Example 1: Show a metric**
129
128
 
130
129
  >>> import streamlit as st
@@ -35,7 +35,7 @@ FloatOrInt: TypeAlias = Union[int, float]
35
35
  def _check_float_between(value: float, low: float = 0.0, high: float = 1.0) -> bool:
36
36
  """
37
37
  Checks given value is 'between' the bounds of [low, high],
38
- considering close values around bounds are acceptable input
38
+ considering close values around bounds are acceptable input.
39
39
 
40
40
  Notes
41
41
  -----
@@ -33,7 +33,7 @@ class TextMixin:
33
33
  *, # keyword-only arguments:
34
34
  help: str | None = None,
35
35
  ) -> DeltaGenerator:
36
- """Write text without Markdown or HTML parsing.
36
+ r"""Write text without Markdown or HTML parsing.
37
37
 
38
38
  For monospace text, use |st.code|_.
39
39
 
@@ -57,7 +57,7 @@ class TextMixin:
57
57
  -------
58
58
  >>> import streamlit as st
59
59
  >>>
60
- >>> st.text("This is text\\n[and more text](that's not a Markdown link).")
60
+ >>> st.text("This is text\n[and more text](that's not a Markdown link).")
61
61
 
62
62
  .. output ::
63
63
  https://doc-text.streamlit.app/
@@ -287,7 +287,8 @@ def _marshall_chart_data(
287
287
  data: Data = None,
288
288
  ) -> None:
289
289
  """Adds the data to the proto and removes it from the spec dict.
290
- These operations will happen in-place."""
290
+ These operations will happen in-place.
291
+ """
291
292
 
292
293
  # Pull data out of spec dict when it's in a 'datasets' key:
293
294
  # datasets: {foo: df1_bytes, bar: df2_bytes}, ...}
@@ -218,7 +218,8 @@ class AudioInputMixin:
218
218
  label_visibility: LabelVisibility = "visible",
219
219
  ) -> UploadedFile | None:
220
220
  """Deprecated alias for st.audio_input.
221
- See the docstring for the widget's new name."""
221
+ See the docstring for the widget's new name.
222
+ """
222
223
 
223
224
  show_deprecation_warning(
224
225
  make_deprecated_name_warning(
@@ -193,7 +193,6 @@ class ButtonMixin:
193
193
 
194
194
  Examples
195
195
  --------
196
-
197
196
  **Example 1: Customize your button type**
198
197
 
199
198
  >>> import streamlit as st
@@ -537,7 +537,6 @@ class ButtonGroupMixin:
537
537
 
538
538
  Examples
539
539
  --------
540
-
541
540
  **Example 1: Multi-select pills**
542
541
 
543
542
  Display a multi-select pills widget, and show the selection:
@@ -747,7 +746,6 @@ class ButtonGroupMixin:
747
746
 
748
747
  Examples
749
748
  --------
750
-
751
749
  **Example 1: Multi-select segmented control**
752
750
 
753
751
  Display a multi-select segmented control widget, and show the
@@ -831,7 +829,8 @@ class ButtonGroupMixin:
831
829
 
832
830
  def _transformed_format_func(option: V) -> ButtonGroupProto.Option:
833
831
  """If option starts with a material icon or an emoji, we extract it to send
834
- it parsed to the frontend."""
832
+ it parsed to the frontend.
833
+ """
835
834
  transformed = format_func(option) if format_func else str(option)
836
835
  transformed_parts = transformed.split(" ")
837
836
  icon: str | None = None
@@ -392,13 +392,11 @@ def _is_supported_index(df_index: pd.Index) -> bool:
392
392
 
393
393
  Parameters
394
394
  ----------
395
-
396
395
  df_index : pd.Index
397
396
  The index to check.
398
397
 
399
398
  Returns
400
399
  -------
401
-
402
400
  bool
403
401
  True if the index is supported, False otherwise.
404
402
  """
@@ -426,7 +424,8 @@ def _is_supported_index(df_index: pd.Index) -> bool:
426
424
 
427
425
  def _fix_column_headers(data_df: pd.DataFrame) -> None:
428
426
  """Fix the column headers of the provided dataframe inplace to work
429
- correctly for data editing."""
427
+ correctly for data editing.
428
+ """
430
429
  import pandas as pd
431
430
 
432
431
  if isinstance(data_df.columns, pd.MultiIndex):
@@ -145,7 +145,7 @@ def _datetime_to_micros(dt: datetime) -> int:
145
145
 
146
146
 
147
147
  def _micros_to_datetime(micros: int, orig_tz: tzinfo | None) -> datetime:
148
- """Restore times/datetimes to original timezone (dates are always naive)"""
148
+ """Restore times/datetimes to original timezone (dates are always naive)."""
149
149
  utc_dt = UTC_EPOCH + timedelta(microseconds=micros)
150
150
  # Add the original timezone. No conversion is required here,
151
151
  # since in the serialization, we also just replace the timestamp with UTC.
@@ -485,6 +485,7 @@ class TextWidgetsMixin:
485
485
  is ``"hidden"``, Streamlit displays an empty spacer instead of the
486
486
  label, which can help keep the widget alligned with other widgets.
487
487
  If this is ``"collapsed"``, Streamlit displays no label or spacer.
488
+
488
489
  Returns
489
490
  -------
490
491
  str or None
@@ -336,7 +336,6 @@ class WriteMixin:
336
336
 
337
337
  Examples
338
338
  --------
339
-
340
339
  Its basic use case is to draw Markdown-formatted text, whenever the
341
340
  input is a string:
342
341
 
streamlit/errors.py CHANGED
@@ -43,7 +43,8 @@ class DeprecationError(Error):
43
43
 
44
44
  class FragmentStorageKeyError(Error, KeyError):
45
45
  """A KeyError raised when a KeyError is encountered during a FragmentStorage
46
- operation."""
46
+ operation.
47
+ """
47
48
 
48
49
  pass
49
50
 
@@ -150,7 +151,8 @@ class StreamlitAPIWarning(StreamlitAPIException, Warning):
150
151
 
151
152
  class StreamlitModuleNotFoundError(StreamlitAPIWarning):
152
153
  """Print a pretty message when a Streamlit command requires a dependency
153
- that is not one of our core dependencies."""
154
+ that is not one of our core dependencies.
155
+ """
154
156
 
155
157
  def __init__(self, module_name, *args):
156
158
  message = (
@@ -450,3 +452,10 @@ class StreamlitBadTimeStringError(LocalizableStreamlitException):
450
452
  "`'1d2h34m'` or `2 days`, for example. Got: {time_string}",
451
453
  time_string=time_string,
452
454
  )
455
+
456
+
457
+ class StreamlitSecretNotFoundError(LocalizableStreamlitException, FileNotFoundError):
458
+ """Exception raised when a secret cannot be found or parsed in the secrets.toml file."""
459
+
460
+ def __init__(self, message: str):
461
+ super().__init__(message)
@@ -170,7 +170,7 @@ class LLMThought:
170
170
 
171
171
  @property
172
172
  def last_tool(self) -> ToolRecord | None:
173
- """The last tool executed by this thought"""
173
+ """The last tool executed by this thought."""
174
174
  return self._last_tool
175
175
 
176
176
  def _reset_llm_token_stream(self) -> None:
@@ -286,7 +286,6 @@ class StreamlitCallbackHandler(BaseCallbackHandler):
286
286
 
287
287
  Parameters
288
288
  ----------
289
-
290
289
  parent_container
291
290
  The `st.container` that will contain all the Streamlit elements that the
292
291
  Handler creates.
streamlit/file_util.py CHANGED
@@ -89,7 +89,9 @@ def streamlit_read(path, binary=False):
89
89
  @contextlib.contextmanager
90
90
  def streamlit_write(path, binary=False):
91
91
  """Opens a file for writing within the streamlit path, and
92
- ensuring that the path exists. For example:
92
+ ensuring that the path exists.
93
+
94
+ For example:
93
95
 
94
96
  with streamlit_write('foo/bar.txt') as bar:
95
97
  ...
@@ -125,7 +127,7 @@ def get_static_dir() -> str:
125
127
 
126
128
 
127
129
  def get_app_static_dir(main_script_path: str) -> str:
128
- """Get the folder where app static files live"""
130
+ """Get the folder where app static files live."""
129
131
  main_script_path = Path(main_script_path)
130
132
  static_dir = main_script_path.parent / APP_STATIC_FOLDER_NAME
131
133
  return os.path.abspath(static_dir)
@@ -49,7 +49,6 @@ def Page(
49
49
 
50
50
  Parameters
51
51
  ----------
52
-
53
52
  page : str, Path, or callable
54
53
  The page source as a ``Callable`` or path to a Python file. If the page
55
54
  source is defined by a Python file, the path can be a string or
streamlit/platform.py CHANGED
@@ -21,9 +21,7 @@ from streamlit.runtime.scriptrunner_utils.script_run_context import get_script_r
21
21
 
22
22
 
23
23
  def post_parent_message(message: str) -> None:
24
- """
25
- Sends a string message to the parent window (when host configuration allows).
26
- """
24
+ """Sends a string message to the parent window (when host configuration allows)."""
27
25
  ctx = get_script_run_ctx()
28
26
  if ctx is None:
29
27
  return
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- """@st.cache_data: pickle-based caching"""
15
+ """@st.cache_data: pickle-based caching."""
16
16
 
17
17
  from __future__ import annotations
18
18
 
@@ -81,7 +81,7 @@ CachePersistType: TypeAlias = Union[Literal["disk"], None]
81
81
 
82
82
 
83
83
  class CachedDataFuncInfo(CachedFuncInfo):
84
- """Implements the CachedFuncInfo interface for @st.cache_data"""
84
+ """Implements the CachedFuncInfo interface for @st.cache_data."""
85
85
 
86
86
  def __init__(
87
87
  self,
@@ -113,7 +113,7 @@ class CachedDataFuncInfo(CachedFuncInfo):
113
113
 
114
114
  @property
115
115
  def display_name(self) -> str:
116
- """A human-readable name for the cached function"""
116
+ """A human-readable name for the cached function."""
117
117
  return f"{self.func.__module__}.{self.func.__qualname__}"
118
118
 
119
119
  def get_function_cache(self, function_key: str) -> Cache:
@@ -127,7 +127,7 @@ class CachedDataFuncInfo(CachedFuncInfo):
127
127
 
128
128
  def validate_params(self) -> None:
129
129
  """
130
- Validate the params passed to @st.cache_data are compatible with cache storage
130
+ Validate the params passed to @st.cache_data are compatible with cache storage.
131
131
 
132
132
  When called, this method could log warnings if cache params are invalid
133
133
  for current storage.
@@ -141,7 +141,7 @@ class CachedDataFuncInfo(CachedFuncInfo):
141
141
 
142
142
 
143
143
  class DataCaches(CacheStatsProvider):
144
- """Manages all DataCache instances"""
144
+ """Manages all DataCache instances."""
145
145
 
146
146
  def __init__(self):
147
147
  self._caches_lock = threading.Lock()
@@ -137,6 +137,6 @@ class UnserializableReturnValueError(MarkdownFormattedException):
137
137
 
138
138
 
139
139
  class UnevaluatedDataFrameError(StreamlitAPIException):
140
- """Used to display a message about uncollected dataframe being used"""
140
+ """Used to display a message about uncollected dataframe being used."""
141
141
 
142
142
  pass
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- """@st.cache_resource implementation"""
15
+ """@st.cache_resource implementation."""
16
16
 
17
17
  from __future__ import annotations
18
18
 
@@ -67,7 +67,7 @@ def _equal_validate_funcs(a: ValidateFunc | None, b: ValidateFunc | None) -> boo
67
67
 
68
68
 
69
69
  class ResourceCaches(CacheStatsProvider):
70
- """Manages all ResourceCache instances"""
70
+ """Manages all ResourceCache instances."""
71
71
 
72
72
  def __init__(self):
73
73
  self._caches_lock = threading.Lock()
@@ -141,7 +141,7 @@ def get_resource_cache_stats_provider() -> CacheStatsProvider:
141
141
 
142
142
 
143
143
  class CachedResourceFuncInfo(CachedFuncInfo):
144
- """Implements the CachedFuncInfo interface for @st.cache_resource"""
144
+ """Implements the CachedFuncInfo interface for @st.cache_resource."""
145
145
 
146
146
  def __init__(
147
147
  self,
@@ -171,7 +171,7 @@ class CachedResourceFuncInfo(CachedFuncInfo):
171
171
 
172
172
  @property
173
173
  def display_name(self) -> str:
174
- """A human-readable name for the cached function"""
174
+ """A human-readable name for the cached function."""
175
175
  return f"{self.func.__module__}.{self.func.__qualname__}"
176
176
 
177
177
  def get_function_cache(self, function_key: str) -> Cache:
@@ -103,7 +103,8 @@ class Cache:
103
103
  def clear(self, key: str | None = None):
104
104
  """Clear values from this cache.
105
105
  If no argument is passed, all items are cleared from the cache.
106
- A key can be passed to clear that key from the cache only."""
106
+ A key can be passed to clear that key from the cache only.
107
+ """
107
108
  with self._value_locks_lock:
108
109
  if not key:
109
110
  self._value_locks.clear()
@@ -163,7 +164,8 @@ def make_cached_func_wrapper(info: CachedFuncInfo) -> Callable[..., Any]:
163
164
 
164
165
  class BoundCachedFunc:
165
166
  """A wrapper around a CachedFunc that binds it to a specific instance in case of
166
- decorated function is a class method."""
167
+ decorated function is a class method.
168
+ """
167
169
 
168
170
  def __init__(self, cached_func: CachedFunc, instance: Any):
169
171
  self._cached_func = cached_func
@@ -260,7 +262,8 @@ class CachedFunc:
260
262
 
261
263
  def _handle_cache_hit(self, result: CachedResult) -> Any:
262
264
  """Handle a cache hit: replay the result's cached messages, and return its
263
- value."""
265
+ value.
266
+ """
264
267
  replay_cached_messages(
265
268
  result,
266
269
  self._info.cache_type,
@@ -352,7 +355,6 @@ class CachedFunc:
352
355
 
353
356
  Parameters
354
357
  ----------
355
-
356
358
  *args: Any
357
359
  Arguments of the cached functions.
358
360
 
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  """Declares the CacheStorageContext dataclass, which contains parameter information for
16
- each function decorated by `@st.cache_data` (for example: ttl, max_entries etc.)
16
+ each function decorated by `@st.cache_data` (for example: ttl, max_entries etc.).
17
17
 
18
18
  Declares the CacheStorageManager protocol, which implementations are used
19
19
  to create CacheStorage instances and to optionally clear all cache storages,
@@ -61,11 +61,11 @@ from typing import Literal, Protocol
61
61
 
62
62
 
63
63
  class CacheStorageError(Exception):
64
- """Base exception raised by the cache storage"""
64
+ """Base exception raised by the cache storage."""
65
65
 
66
66
 
67
67
  class CacheStorageKeyNotFoundError(CacheStorageError):
68
- """Raised when the key is not found in the cache storage"""
68
+ """Raised when the key is not found in the cache storage."""
69
69
 
70
70
 
71
71
  class InvalidCacheStorageContext(CacheStorageError):
@@ -138,17 +138,17 @@ class CacheStorage(Protocol):
138
138
 
139
139
  @abstractmethod
140
140
  def set(self, key: str, value: bytes) -> None:
141
- """Sets the value for a given key"""
141
+ """Sets the value for a given key."""
142
142
  raise NotImplementedError
143
143
 
144
144
  @abstractmethod
145
145
  def delete(self, key: str) -> None:
146
- """Delete a given key"""
146
+ """Delete a given key."""
147
147
  raise NotImplementedError
148
148
 
149
149
  @abstractmethod
150
150
  def clear(self) -> None:
151
- """Remove all keys for the storage"""
151
+ """Remove all keys for the storage."""
152
152
  raise NotImplementedError
153
153
 
154
154
  def close(self) -> None:
@@ -26,7 +26,7 @@ from streamlit.runtime.caching.storage.in_memory_cache_storage_wrapper import (
26
26
 
27
27
  class MemoryCacheStorageManager(CacheStorageManager):
28
28
  def create(self, context: CacheStorageContext) -> CacheStorage:
29
- """Creates a new cache storage instance wrapped with in-memory cache layer"""
29
+ """Creates a new cache storage instance wrapped with in-memory cache layer."""
30
30
  persist_storage = DummyCacheStorage()
31
31
  return InMemoryCacheStorageWrapper(
32
32
  persist_storage=persist_storage, context=context
@@ -43,7 +43,7 @@ class DummyCacheStorage(CacheStorage):
43
43
  def get(self, key: str) -> bytes:
44
44
  """
45
45
  Dummy gets the value for a given key,
46
- always raises an CacheStorageKeyNotFoundError
46
+ always raises an CacheStorageKeyNotFoundError.
47
47
  """
48
48
  raise CacheStorageKeyNotFoundError("Key not found in dummy cache")
49
49
 
@@ -81,7 +81,7 @@ class InMemoryCacheStorageWrapper(CacheStorage):
81
81
  def get(self, key: str) -> bytes:
82
82
  """
83
83
  Returns the stored value for the key or raise CacheStorageKeyNotFoundError if
84
- the key is not found
84
+ the key is not found.
85
85
  """
86
86
  try:
87
87
  entry_bytes = self._read_from_mem_cache(key)
@@ -91,23 +91,23 @@ class InMemoryCacheStorageWrapper(CacheStorage):
91
91
  return entry_bytes
92
92
 
93
93
  def set(self, key: str, value: bytes) -> None:
94
- """Sets the value for a given key"""
94
+ """Sets the value for a given key."""
95
95
  self._write_to_mem_cache(key, value)
96
96
  self._persist_storage.set(key, value)
97
97
 
98
98
  def delete(self, key: str) -> None:
99
- """Delete a given key"""
99
+ """Delete a given key."""
100
100
  self._remove_from_mem_cache(key)
101
101
  self._persist_storage.delete(key)
102
102
 
103
103
  def clear(self) -> None:
104
- """Delete all keys for the in memory cache, and also the persistent storage"""
104
+ """Delete all keys for the in memory cache, and also the persistent storage."""
105
105
  with self._mem_cache_lock:
106
106
  self._mem_cache.clear()
107
107
  self._persist_storage.clear()
108
108
 
109
109
  def get_stats(self) -> list[CacheStat]:
110
- """Returns a list of stats in bytes for the cache memory storage per item"""
110
+ """Returns a list of stats in bytes for the cache memory storage per item."""
111
111
  stats = []
112
112
 
113
113
  with self._mem_cache_lock:
@@ -122,7 +122,7 @@ class InMemoryCacheStorageWrapper(CacheStorage):
122
122
  return stats
123
123
 
124
124
  def close(self) -> None:
125
- """Closes the cache storage"""
125
+ """Closes the cache storage."""
126
126
  self._persist_storage.close()
127
127
 
128
128
  def _read_from_mem_cache(self, key: str) -> bytes: