streamlit-nightly 1.43.3.dev20250312__py3-none-any.whl → 1.43.3.dev20250314__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 (153) hide show
  1. streamlit/auth_util.py +2 -1
  2. streamlit/commands/experimental_query_params.py +1 -1
  3. streamlit/commands/logo.py +3 -3
  4. streamlit/components/v1/__init__.py +1 -3
  5. streamlit/components/v1/custom_component.py +1 -1
  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/media.py +2 -1
  25. streamlit/elements/metric.py +0 -1
  26. streamlit/elements/plotly_chart.py +2 -2
  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 +4 -2
  38. streamlit/external/langchain/streamlit_callback_handler.py +1 -2
  39. streamlit/file_util.py +4 -2
  40. streamlit/navigation/page.py +2 -3
  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 +5 -3
  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.C9csNfwR.js → FileDownload.esm.C9LJHGQA.js} +1 -1
  70. streamlit/static/static/js/{FileHelper.CTWNHaVI.js → FileHelper.jkT1raGU.js} +1 -1
  71. streamlit/static/static/js/{FormClearHelper.1VkFJY3v.js → FormClearHelper.DhbIpC8c.js} +1 -1
  72. streamlit/static/static/js/{Hooks.vPqq3xQ5.js → Hooks.CriWgW_b.js} +1 -1
  73. streamlit/static/static/js/{InputInstructions.7jABRwB0.js → InputInstructions.D3RY91P2.js} +1 -1
  74. streamlit/static/static/js/{ProgressBar.BWY8ITDS.js → ProgressBar.C3Pzm-B2.js} +1 -1
  75. streamlit/static/static/js/{RenderInPortalIfExists.CP_sn1OG.js → RenderInPortalIfExists.BZnHZgZS.js} +1 -1
  76. streamlit/static/static/js/{Toolbar.DzqMcgvB.js → Toolbar.B5rV1WJt.js} +1 -1
  77. streamlit/static/static/js/{base-input.DjuthXF0.js → base-input.Cw4qDIMU.js} +1 -1
  78. streamlit/static/static/js/{checkbox.BddRUN3_.js → checkbox.DkQySTTm.js} +1 -1
  79. streamlit/static/static/js/{createSuper.BAGgahBq.js → createSuper.BSo5GDIi.js} +1 -1
  80. streamlit/static/static/js/{data-grid-overlay-editor.Bscjz8_-.js → data-grid-overlay-editor.B1mf5JDE.js} +1 -1
  81. streamlit/static/static/js/{downloader.BgDSv-Ig.js → downloader.B1pPErIQ.js} +1 -1
  82. streamlit/static/static/js/{es6.3kVHyEdR.js → es6.DMqquk5e.js} +2 -2
  83. streamlit/static/static/js/{iframeResizer.contentWindow.n2oqEwdf.js → iframeResizer.contentWindow.ChumCRtp.js} +1 -1
  84. streamlit/static/static/js/{index.UJT9uVs_.js → index.5WgntJXP.js} +1 -1
  85. streamlit/static/static/js/{index.k2DDVmzp.js → index.7Uw588Xk.js} +1 -1
  86. streamlit/static/static/js/{index.DbI6X421.js → index.B3IKgYX5.js} +1 -1
  87. streamlit/static/static/js/{index.BfTunuGf.js → index.B3eHKw73.js} +1 -1
  88. streamlit/static/static/js/{index.D7k3QVrz.js → index.B740eLHm.js} +1 -1
  89. streamlit/static/static/js/{index.Bd5GUMH8.js → index.B96IeQgZ.js} +1 -1
  90. streamlit/static/static/js/{index.DAAc9Gb3.js → index.BFTTgLeU.js} +1 -1
  91. streamlit/static/static/js/{index.CFbiFnmq.js → index.BOaNnKYB.js} +1 -1
  92. streamlit/static/static/js/{index.C8ZHYetm.js → index.BTOGrbrn.js} +1 -1
  93. streamlit/static/static/js/{index.D3uVQMaA.js → index.BbRfGs1X.js} +1 -1
  94. streamlit/static/static/js/{index.0JqsAt5p.js → index.BgDVGIiW.js} +1 -1
  95. streamlit/static/static/js/{index.D3EE2F77.js → index.BlL9sy9J.js} +147 -146
  96. streamlit/static/static/js/{index.C28BRw13.js → index.BlmSw6QY.js} +1 -1
  97. streamlit/static/static/js/{index.BNTyamf9.js → index.C5YEuIXg.js} +1 -1
  98. streamlit/static/static/js/{index.BQXOwXQG.js → index.CKXJOTqx.js} +1 -1
  99. streamlit/static/static/js/{index.DlXteNnv.js → index.CSTjg2CK.js} +1 -1
  100. streamlit/static/static/js/{index.ChDimwy6.js → index.CVd_6WNy.js} +1 -1
  101. streamlit/static/static/js/{index.FJszpQ-y.js → index.Cd6xqijF.js} +5 -5
  102. streamlit/static/static/js/{index.svH5ea22.js → index.CfNMuIIh.js} +1 -1
  103. streamlit/static/static/js/{index.zrNj-omI.js → index.CrkWnEhn.js} +1 -1
  104. streamlit/static/static/js/{index.j6cgFK9c.js → index.D0wPNnz8.js} +1 -1
  105. streamlit/static/static/js/{index.mMuChmJi.js → index.DK1PVQ6C.js} +1 -1
  106. streamlit/static/static/js/{index.OtBp-Blq.js → index.DT_OGzkj.js} +1 -1
  107. streamlit/static/static/js/{index.S_LaABz9.js → index.DWAHTwxW.js} +1 -1
  108. streamlit/static/static/js/{index.pEU90S1o.js → index.DaaBud_u.js} +5 -5
  109. streamlit/static/static/js/{index.BaYVwylD.js → index.DbQZTVYH.js} +1 -1
  110. streamlit/static/static/js/{index.CrZncPLs.js → index.DqPipBPf.js} +1 -1
  111. streamlit/static/static/js/{index.3k9e_sFT.js → index.Dz2EqLgY.js} +1 -1
  112. streamlit/static/static/js/{index.DAghU1FB.js → index.LgpTjYjs.js} +1 -1
  113. streamlit/static/static/js/{index.BPcgpI5G.js → index.Sd38jGo-.js} +1 -1
  114. streamlit/static/static/js/{index.Dv6XiWKs.js → index.TcpXhGIM.js} +1 -1
  115. streamlit/static/static/js/{index.Cj7yHfOR.js → index._70PT65v.js} +1 -1
  116. streamlit/static/static/js/{index.B1ZLFKil.js → index.bVsz2ldg.js} +1 -1
  117. streamlit/static/static/js/{index.B8IuPu4x.js → index.lVcG4OCJ.js} +1 -1
  118. streamlit/static/static/js/{index.N6CP_9Qh.js → index.rPVy0ui5.js} +1 -1
  119. streamlit/static/static/js/{index.CrjCtGqg.js → index.szAaQUP4.js} +1 -1
  120. streamlit/static/static/js/{index.CYrF9jN2.js → index.w7piGYbJ.js} +1 -1
  121. streamlit/static/static/js/{input.A7Xel5Mz.js → input.CGLa0Mkr.js} +1 -1
  122. streamlit/static/static/js/{memory.DKAi1aOw.js → memory.u6Bv68yh.js} +1 -1
  123. streamlit/static/static/js/{mergeWith.BOXngkwE.js → mergeWith.BEgniPh1.js} +1 -1
  124. streamlit/static/static/js/{number-overlay-editor.Dr9nZLr4.js → number-overlay-editor.94bIlYUC.js} +1 -1
  125. streamlit/static/static/js/{possibleConstructorReturn.Dmq70n5Q.js → possibleConstructorReturn.Dfpu-j0D.js} +1 -1
  126. streamlit/static/static/js/{sandbox.OiNVhKVk.js → sandbox.CYYH_geg.js} +1 -1
  127. streamlit/static/static/js/{textarea.BvcErhuX.js → textarea.ByGG-B4n.js} +1 -1
  128. streamlit/static/static/js/{timepicker.BndxQ_56.js → timepicker.B7cgXhs2.js} +1 -1
  129. streamlit/static/static/js/{toConsumableArray.Bvyh5k2t.js → toConsumableArray.K_KdQrnP.js} +1 -1
  130. streamlit/static/static/js/{uniqueId.BJXawxf6.js → uniqueId.BoMGywDL.js} +1 -1
  131. streamlit/static/static/js/{useBasicWidgetState.-z6NaxAe.js → useBasicWidgetState.DJ657I97.js} +1 -1
  132. streamlit/static/static/js/{useOnInputChange.DvBUKld6.js → useOnInputChange.BT-TUWed.js} +1 -1
  133. streamlit/static/static/js/{withFullScreenWrapper.CubK7zml.js → withFullScreenWrapper.DpT3_k8t.js} +1 -1
  134. streamlit/string_util.py +3 -2
  135. streamlit/testing/v1/element_tree.py +30 -30
  136. streamlit/testing/v1/util.py +2 -1
  137. streamlit/time_util.py +1 -3
  138. streamlit/type_util.py +2 -1
  139. streamlit/user_info.py +0 -1
  140. streamlit/watcher/event_based_path_watcher.py +1 -1
  141. streamlit/web/bootstrap.py +3 -1
  142. streamlit/web/cache_storage_manager_config.py +1 -1
  143. streamlit/web/cli.py +2 -2
  144. streamlit/web/server/authlib_tornado_integration.py +1 -1
  145. streamlit/web/server/browser_websocket_handler.py +2 -1
  146. streamlit/web/server/routes.py +2 -2
  147. streamlit/web/server/server_util.py +2 -4
  148. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/METADATA +1 -1
  149. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/RECORD +153 -153
  150. {streamlit_nightly-1.43.3.dev20250312.data → streamlit_nightly-1.43.3.dev20250314.data}/scripts/streamlit.cmd +0 -0
  151. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/WHEEL +0 -0
  152. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/entry_points.txt +0 -0
  153. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/top_level.txt +0 -0
@@ -73,10 +73,12 @@ def _srt_to_vtt(srt_data: str | bytes) -> bytes:
73
73
  Convert subtitles from SubRip (.srt) format to WebVTT (.vtt) format.
74
74
  This function accepts the content of the .srt file either as a string
75
75
  or as a BytesIO stream.
76
+
76
77
  Parameters
77
78
  ----------
78
79
  srt_data : str or bytes
79
80
  The content of the .srt file as a string or a bytes stream.
81
+
80
82
  Returns
81
83
  -------
82
84
  bytes
@@ -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
 
@@ -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
@@ -49,7 +49,7 @@ from streamlit.runtime.state import WidgetCallback, register_widget
49
49
  if TYPE_CHECKING:
50
50
  from collections.abc import Iterable
51
51
 
52
- import matplotlib
52
+ import matplotlib as mpl
53
53
  import plotly.graph_objs as go
54
54
  from plotly.basedatatypes import BaseFigure
55
55
 
@@ -70,7 +70,7 @@ FigureOrData: TypeAlias = Union[
70
70
  # align with the docstring.
71
71
  dict[str, _AtomicFigureOrData],
72
72
  "BaseFigure",
73
- "matplotlib.figure.Figure",
73
+ "mpl.figure.Figure",
74
74
  ]
75
75
 
76
76
  SelectionMode: TypeAlias = Literal["lasso", "points", "box"]
@@ -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 = (
@@ -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
@@ -293,8 +292,8 @@ class StreamlitPage:
293
292
  else:
294
293
  code = ctx.pages_manager.get_page_script_byte_code(str(self._page))
295
294
  module = types.ModuleType("__main__")
296
- # We want __file__ to be the path to the script
297
- module.__dict__["__file__"] = self._page
295
+ # We want __file__ to be the string path to the script
296
+ module.__dict__["__file__"] = str(self._page)
298
297
  exec(code, module.__dict__)
299
298
 
300
299
  @property
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:
@@ -91,7 +91,7 @@ _CACHED_FILE_EXTENSION: Final = "memo"
91
91
 
92
92
  class LocalDiskCacheStorageManager(CacheStorageManager):
93
93
  def create(self, context: CacheStorageContext) -> CacheStorage:
94
- """Creates a new cache storage instance wrapped with in-memory cache layer"""
94
+ """Creates a new cache storage instance wrapped with in-memory cache layer."""
95
95
  persist_storage = LocalDiskCacheStorage(context)
96
96
  return InMemoryCacheStorageWrapper(
97
97
  persist_storage=persist_storage, context=context
@@ -117,7 +117,7 @@ class LocalDiskCacheStorageManager(CacheStorageManager):
117
117
 
118
118
  class LocalDiskCacheStorage(CacheStorage):
119
119
  """Cache storage that persists data to disk
120
- This is the default cache persistence layer for `@st.cache_data`
120
+ This is the default cache persistence layer for `@st.cache_data`.
121
121
  """
122
122
 
123
123
  def __init__(self, context: CacheStorageContext):
@@ -138,7 +138,7 @@ class LocalDiskCacheStorage(CacheStorage):
138
138
  """
139
139
  Returns the stored value for the key if persisted,
140
140
  raise CacheStorageKeyNotFoundError if not found, or not configured
141
- with persist="disk"
141
+ with persist="disk".
142
142
  """
143
143
  if self.persist == "disk":
144
144
  path = self._get_cache_file_path(key)
@@ -158,7 +158,7 @@ class LocalDiskCacheStorage(CacheStorage):
158
158
  )
159
159
 
160
160
  def set(self, key: str, value: bytes) -> None:
161
- """Sets the value for a given key"""
161
+ """Sets the value for a given key."""
162
162
  if self.persist == "disk":
163
163
  path = self._get_cache_file_path(key)
164
164
  try:
@@ -191,7 +191,7 @@ class LocalDiskCacheStorage(CacheStorage):
191
191
  )
192
192
 
193
193
  def clear(self) -> None:
194
- """Delete all keys for the current storage"""
194
+ """Delete all keys for the current storage."""
195
195
  cache_dir = get_cache_folder_path()
196
196
 
197
197
  if os.path.isdir(cache_dir):
@@ -203,7 +203,7 @@ class LocalDiskCacheStorage(CacheStorage):
203
203
  os.remove(os.path.join(cache_dir, file_name))
204
204
 
205
205
  def close(self) -> None:
206
- """Dummy implementation of close, we don't need to actually "close" anything"""
206
+ """Dummy implementation of close, we don't need to actually "close" anything."""
207
207
 
208
208
  def _get_cache_file_path(self, value_key: str) -> str:
209
209
  """Return the path of the disk cache file for the given value."""
@@ -278,7 +278,6 @@ def connection_factory(
278
278
 
279
279
  Examples
280
280
  --------
281
-
282
281
  **Example 1: Inferred connection type**
283
282
 
284
283
  The easiest way to create a first-party (SQL, Snowflake, or Snowpark) connection is
@@ -273,7 +273,7 @@ class ContextProxy:
273
273
  @property
274
274
  @gather_metrics("context.locale")
275
275
  def locale(self) -> str | None:
276
- """The locale of the user browser, read-only"""
276
+ """The locale of the user browser, read-only."""
277
277
  ctx = get_script_run_ctx()
278
278
  if ctx is None or ctx.context_info is None:
279
279
  return None
@@ -66,7 +66,7 @@ Collecting usage statistics. To deactivate, set browser.gatherUsageStats to fals
66
66
 
67
67
 
68
68
  def _send_email(email: str) -> None:
69
- """Send the user's email for metrics, if submitted"""
69
+ """Send the user's email for metrics, if submitted."""
70
70
  import requests
71
71
 
72
72
  if email is None or "@" not in email:
@@ -281,7 +281,7 @@ class ForwardMsgCache(CacheStatsProvider):
281
281
  del self._entries[msg_hash]
282
282
 
283
283
  def clear(self) -> None:
284
- """Remove all entries from the cache"""
284
+ """Remove all entries from the cache."""
285
285
  self._entries.clear()
286
286
 
287
287
  def get_stats(self) -> list[CacheStat]:
@@ -40,7 +40,8 @@ class ForwardMsgQueue:
40
40
  before_enqueue_msg: Callable[[ForwardMsg], None] | None,
41
41
  ) -> None:
42
42
  """Set a callback to be called before a message is enqueued.
43
- Used in static streamlit app generation."""
43
+ Used in static streamlit app generation.
44
+ """
44
45
  ForwardMsgQueue._before_enqueue_msg = before_enqueue_msg
45
46
 
46
47
  def __init__(self):
@@ -61,7 +61,8 @@ class FragmentStorage(Protocol):
61
61
  @abstractmethod
62
62
  def clear(self, new_fragment_ids: set[str] | None = None) -> None:
63
63
  """Remove all fragments saved in this FragmentStorage unless listed in
64
- new_fragment_ids."""
64
+ new_fragment_ids.
65
+ """
65
66
  raise NotImplementedError
66
67
 
67
68
  @abstractmethod