streamlit-nightly 1.45.2.dev20250513__py3-none-any.whl → 1.45.2.dev20250515__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 (115) hide show
  1. streamlit/commands/execution_control.py +30 -30
  2. streamlit/connections/sql_connection.py +10 -7
  3. streamlit/connections/util.py +2 -2
  4. streamlit/elements/heading.py +3 -4
  5. streamlit/elements/html.py +3 -4
  6. streamlit/elements/lib/built_in_chart_utils.py +1 -3
  7. streamlit/elements/lib/image_utils.py +2 -3
  8. streamlit/elements/lib/options_selector_utils.py +11 -4
  9. streamlit/elements/lib/pandas_styler_utils.py +1 -3
  10. streamlit/elements/lib/subtitle_utils.py +6 -9
  11. streamlit/elements/map.py +1 -2
  12. streamlit/elements/markdown.py +1 -1
  13. streamlit/elements/plotly_chart.py +8 -9
  14. streamlit/elements/toast.py +1 -2
  15. streamlit/elements/vega_charts.py +7 -7
  16. streamlit/elements/widgets/chat.py +25 -27
  17. streamlit/elements/widgets/file_uploader.py +4 -4
  18. streamlit/elements/widgets/number_input.py +3 -3
  19. streamlit/elements/widgets/radio.py +25 -5
  20. streamlit/elements/widgets/select_slider.py +10 -24
  21. streamlit/elements/widgets/selectbox.py +22 -0
  22. streamlit/elements/widgets/slider.py +35 -9
  23. streamlit/navigation/page.py +5 -6
  24. streamlit/runtime/caching/cache_data_api.py +18 -14
  25. streamlit/runtime/caching/cache_errors.py +1 -1
  26. streamlit/runtime/caching/cached_message_replay.py +1 -2
  27. streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +2 -3
  28. streamlit/runtime/connection_factory.py +1 -1
  29. streamlit/runtime/context.py +1 -5
  30. streamlit/runtime/media_file_manager.py +1 -2
  31. streamlit/runtime/scriptrunner/script_runner.py +1 -2
  32. streamlit/runtime/secrets.py +10 -8
  33. streamlit/runtime/state/query_params_proxy.py +14 -12
  34. streamlit/runtime/state/session_state.py +3 -4
  35. streamlit/static/index.html +1 -1
  36. streamlit/static/static/js/{ErrorOutline.esm.CxkgXqSh.js → ErrorOutline.esm.DZL6W-d3.js} +1 -1
  37. streamlit/static/static/js/{FileDownload.esm.DVrjmwoh.js → FileDownload.esm.BTdAw4zC.js} +1 -1
  38. streamlit/static/static/js/{FileHelper.CMA9s0t3.js → FileHelper.Beb1sf3m.js} +1 -1
  39. streamlit/static/static/js/{FormClearHelper.Ca3GFjxv.js → FormClearHelper.BJursVXh.js} +1 -1
  40. streamlit/static/static/js/{Hooks.BpCPXt5n.js → Hooks.C9-XVXXu.js} +1 -1
  41. streamlit/static/static/js/{InputInstructions.BO_BnHv5.js → InputInstructions.DFH2wY93.js} +1 -1
  42. streamlit/static/static/js/{ProgressBar.Ctk1m4EX.js → ProgressBar.6M24tsRk.js} +1 -1
  43. streamlit/static/static/js/{RenderInPortalIfExists.kuKoxpXt.js → RenderInPortalIfExists.BjKKk4eZ.js} +1 -1
  44. streamlit/static/static/js/{Toolbar.Cde1fEcQ.js → Toolbar.AcZDbsfk.js} +1 -1
  45. streamlit/static/static/js/{base-input.BwCmIYba.js → base-input.DbRAJnqp.js} +1 -1
  46. streamlit/static/static/js/{checkbox.CwPOyuag.js → checkbox.0qSLqyAl.js} +1 -1
  47. streamlit/static/static/js/{createSuper.BMtevhyt.js → createSuper.BVzb0XXY.js} +1 -1
  48. streamlit/static/static/js/{data-grid-overlay-editor.gtfE9z1L.js → data-grid-overlay-editor.veQYOXpb.js} +1 -1
  49. streamlit/static/static/js/{downloader.-58ZXBvx.js → downloader.C_vYtX1r.js} +1 -1
  50. streamlit/static/static/js/{es6.6JpsZqpF.js → es6.DlS5aK2H.js} +2 -2
  51. streamlit/static/static/js/{iframeResizer.contentWindow.Dvm_jxul.js → iframeResizer.contentWindow.DYLRAnnn.js} +1 -1
  52. streamlit/static/static/js/{index.DenamHJl.js → index.7-HGyLk8.js} +1 -1
  53. streamlit/static/static/js/{index.CiiU1-bS.js → index.B4jkkFu1.js} +1 -1
  54. streamlit/static/static/js/{index.D1ccH_2Z.js → index.B7lVUFiI.js} +1 -1
  55. streamlit/static/static/js/{index.BhODUTaJ.js → index.BA7OvX6X.js} +1 -1
  56. streamlit/static/static/js/{index.WVgPkrrw.js → index.BNNdZZ73.js} +1 -1
  57. streamlit/static/static/js/{index.hQ5adhxG.js → index.Bs42fx1x.js} +1 -1
  58. streamlit/static/static/js/{index.D0G-y_z6.js → index.C-SVYz-x.js} +1 -1
  59. streamlit/static/static/js/{index.bkU6rhIM.js → index.C8AfWtJ-.js} +1 -1
  60. streamlit/static/static/js/{index.D3ES4sSL.js → index.CEN6fgTl.js} +1 -1
  61. streamlit/static/static/js/{index.BXdNB_A0.js → index.COQpmMRs.js} +1 -1
  62. streamlit/static/static/js/{index.DNNQBTM6.js → index.CVpOBIPc.js} +1 -1
  63. streamlit/static/static/js/{index.Ce-7kIl6.js → index.CZ_7kbSY.js} +1 -1
  64. streamlit/static/static/js/{index.BnK8pWHN.js → index.CdJve-c-.js} +1 -1
  65. streamlit/static/static/js/{index.B9LBeTzL.js → index.ChCdyltc.js} +1 -1
  66. streamlit/static/static/js/{index.lYSTjxV_.js → index.CnuHgtvi.js} +1 -1
  67. streamlit/static/static/js/{index.DR9ekgzX.js → index.CpBBbkiT.js} +1 -1
  68. streamlit/static/static/js/{index.DJ0X7aeY.js → index.CqJn4aNa.js} +1 -1
  69. streamlit/static/static/js/{index.9Bu4pGgs.js → index.CsMycx_g.js} +1 -1
  70. streamlit/static/static/js/{index.Bd91GXu8.js → index.CzjlNese.js} +1 -1
  71. streamlit/static/static/js/{index.DUizq_aW.js → index.D6vjCnF6.js} +1 -1
  72. streamlit/static/static/js/{index.NfOJ2GJ6.js → index.DI4lQWQ9.js} +1 -1
  73. streamlit/static/static/js/{index.CGJjlswG.js → index.DOZrTqtO.js} +1 -1
  74. streamlit/static/static/js/{index.Dqcp7EZB.js → index.DQoQce-F.js} +77 -77
  75. streamlit/static/static/js/{index.ClE8XHxl.js → index.DU1Hm4Vy.js} +1 -1
  76. streamlit/static/static/js/{index.CD3lJu6g.js → index.D_NeaxbH.js} +1 -1
  77. streamlit/static/static/js/{index.DW60zbv4.js → index.DawYHwts.js} +1 -1
  78. streamlit/static/static/js/{index.CIZd1q4K.js → index.DgKQMQQ-.js} +1 -1
  79. streamlit/static/static/js/{index.BdEKCy-o.js → index.Dh9pGVkc.js} +1 -1
  80. streamlit/static/static/js/{index.DgnhzFgr.js → index.DvaGxMeZ.js} +1 -1
  81. streamlit/static/static/js/{index.DQJE0i9s.js → index.Dx0WWCBs.js} +5 -5
  82. streamlit/static/static/js/{index.DVE5BhiT.js → index.KEBclOiy.js} +1 -1
  83. streamlit/static/static/js/{index.CZy9JHE4.js → index.SG-0kuQk.js} +6 -6
  84. streamlit/static/static/js/{index.CvKH37SN.js → index.TZA6glxs.js} +1 -1
  85. streamlit/static/static/js/{index.C5xsotRs.js → index.bbxNeuVP.js} +1 -1
  86. streamlit/static/static/js/{index.B1T1N6vQ.js → index.pKO-QKd7.js} +1 -1
  87. streamlit/static/static/js/{index.Dk_aZplH.js → index.qHLLYZv1.js} +1 -1
  88. streamlit/static/static/js/{index.BjtSRm-c.js → index.vXLfHXtB.js} +1 -1
  89. streamlit/static/static/js/{input.JEUWF6Z-.js → input.4UlvIkvl.js} +1 -1
  90. streamlit/static/static/js/{memory.BToPJrCN.js → memory.CjAKg4CS.js} +1 -1
  91. streamlit/static/static/js/{mergeWith.DGon2YId.js → mergeWith.Bnn9a11J.js} +1 -1
  92. streamlit/static/static/js/{number-overlay-editor.kqkFTYSn.js → number-overlay-editor.BGyA8GbD.js} +1 -1
  93. streamlit/static/static/js/{possibleConstructorReturn.twGQoCQl.js → possibleConstructorReturn.Cu-FTKlF.js} +1 -1
  94. streamlit/static/static/js/{sandbox.o85HOKwq.js → sandbox.D4Wf-7jE.js} +1 -1
  95. streamlit/static/static/js/{textarea.CdOYpTta.js → textarea.B0_fGlpz.js} +1 -1
  96. streamlit/static/static/js/{timepicker.Cy1BKBo3.js → timepicker._IYyhmJr.js} +1 -1
  97. streamlit/static/static/js/{toConsumableArray.BVXfsvDc.js → toConsumableArray.BRgjiMf8.js} +1 -1
  98. streamlit/static/static/js/{uniqueId.Dz7-nY8K.js → uniqueId.DWtxcoYp.js} +1 -1
  99. streamlit/static/static/js/{useBasicWidgetState.CeKdNkz-.js → useBasicWidgetState.CJa4vrfr.js} +1 -1
  100. streamlit/static/static/js/{useOnInputChange.CM8BtP-c.js → useOnInputChange.DXDP3ow3.js} +1 -1
  101. streamlit/static/static/js/{withFullScreenWrapper.DuyW554J.js → withFullScreenWrapper.BYUNeZvy.js} +1 -1
  102. streamlit/string_util.py +1 -5
  103. streamlit/testing/v1/element_tree.py +2 -4
  104. streamlit/testing/v1/local_script_runner.py +1 -2
  105. streamlit/type_util.py +1 -1
  106. streamlit/url_util.py +1 -1
  107. streamlit/vendor/pympler/asizeof.py +2 -1
  108. streamlit/watcher/local_sources_watcher.py +3 -3
  109. streamlit/web/server/oidc_mixin.py +2 -2
  110. {streamlit_nightly-1.45.2.dev20250513.dist-info → streamlit_nightly-1.45.2.dev20250515.dist-info}/METADATA +1 -1
  111. {streamlit_nightly-1.45.2.dev20250513.dist-info → streamlit_nightly-1.45.2.dev20250515.dist-info}/RECORD +115 -115
  112. {streamlit_nightly-1.45.2.dev20250513.dist-info → streamlit_nightly-1.45.2.dev20250515.dist-info}/WHEEL +1 -1
  113. {streamlit_nightly-1.45.2.dev20250513.data → streamlit_nightly-1.45.2.dev20250515.data}/scripts/streamlit.cmd +0 -0
  114. {streamlit_nightly-1.45.2.dev20250513.dist-info → streamlit_nightly-1.45.2.dev20250515.dist-info}/entry_points.txt +0 -0
  115. {streamlit_nightly-1.45.2.dev20250513.dist-info → streamlit_nightly-1.45.2.dev20250515.dist-info}/top_level.txt +0 -0
@@ -16,6 +16,8 @@ from __future__ import annotations
16
16
  from textwrap import dedent
17
17
  from typing import TYPE_CHECKING, Any, Callable, Generic, Literal, cast, overload
18
18
 
19
+ from typing_extensions import Never
20
+
19
21
  from streamlit.dataframe_util import OptionSequence, convert_anything_to_list
20
22
  from streamlit.elements.lib.form_utils import current_form_id
21
23
  from streamlit.elements.lib.layout_utils import WidthWithoutContent, validate_width
@@ -132,6 +134,26 @@ class SelectboxSerde(Generic[T]):
132
134
 
133
135
 
134
136
  class SelectboxMixin:
137
+ @overload
138
+ def selectbox(
139
+ self,
140
+ label: str,
141
+ options: Sequence[Never], # Type for empty or Never-inferred options
142
+ index: int = 0,
143
+ format_func: Callable[[Any], str] = str,
144
+ key: Key | None = None,
145
+ help: str | None = None,
146
+ on_change: WidgetCallback | None = None,
147
+ args: WidgetArgs | None = None,
148
+ kwargs: WidgetKwargs | None = None,
149
+ *, # keyword-only arguments:
150
+ placeholder: str | None = None,
151
+ disabled: bool = False,
152
+ label_visibility: LabelVisibility = "visible",
153
+ accept_new_options: Literal[False] = False,
154
+ width: WidthWithoutContent = "stretch",
155
+ ) -> None: ... # Returns None if options is empty and accept_new_options is False
156
+
135
157
  @overload
136
158
  def selectbox(
137
159
  self,
@@ -23,6 +23,7 @@ from typing import (
23
23
  TYPE_CHECKING,
24
24
  Any,
25
25
  Final,
26
+ TypedDict,
26
27
  TypeVar,
27
28
  Union,
28
29
  cast,
@@ -155,6 +156,13 @@ def _micros_to_datetime(micros: int, orig_tz: tzinfo | None) -> datetime:
155
156
  return utc_dt.replace(tzinfo=orig_tz)
156
157
 
157
158
 
159
+ class SliderDefaultValues(TypedDict):
160
+ min_value: SliderScalar
161
+ max_value: SliderScalar
162
+ step: SliderStep
163
+ format: str
164
+
165
+
158
166
  @dataclass
159
167
  class SliderSerde:
160
168
  value: list[float]
@@ -192,14 +200,21 @@ class SliderSerde:
192
200
 
193
201
  def serialize(self, v: Any) -> list[Any]:
194
202
  range_value = isinstance(v, (list, tuple))
195
- value = list(v) if range_value else [v]
203
+ # Convert to list to handle tuples
204
+ processed_value = list(v) if range_value else [v]
205
+
196
206
  if self.data_type == SliderProto.DATE:
197
- value = [_datetime_to_micros(_date_to_datetime(v)) for v in value]
207
+ return [
208
+ _datetime_to_micros(_date_to_datetime(val)) for val in processed_value
209
+ ]
198
210
  if self.data_type == SliderProto.TIME:
199
- value = [_datetime_to_micros(_time_to_datetime(v)) for v in value]
211
+ return [
212
+ _datetime_to_micros(_time_to_datetime(val)) for val in processed_value
213
+ ]
200
214
  if self.data_type == SliderProto.DATETIME:
201
- value = [_datetime_to_micros(v) for v in value]
202
- return value
215
+ return [_datetime_to_micros(val) for val in processed_value]
216
+ # For numeric types, ensure they are floats if not already
217
+ return [float(val) for val in processed_value]
203
218
 
204
219
 
205
220
  class SliderMixin:
@@ -222,6 +237,7 @@ class SliderMixin:
222
237
  *,
223
238
  disabled: bool = False,
224
239
  label_visibility: LabelVisibility = "visible",
240
+ width: WidthWithoutContent = "stretch",
225
241
  ) -> int: ...
226
242
 
227
243
  # If min-value or max_value is provided and a numeric type, and value (if provided)
@@ -243,6 +259,7 @@ class SliderMixin:
243
259
  *,
244
260
  disabled: bool = False,
245
261
  label_visibility: LabelVisibility = "visible",
262
+ width: WidthWithoutContent = "stretch",
246
263
  ) -> SliderNumericT: ...
247
264
 
248
265
  # If value is provided and a sequence of numeric type,
@@ -264,6 +281,7 @@ class SliderMixin:
264
281
  kwargs: WidgetKwargs | None = None,
265
282
  disabled: bool = False,
266
283
  label_visibility: LabelVisibility = "visible",
284
+ width: WidthWithoutContent = "stretch",
267
285
  ) -> tuple[SliderNumericT, SliderNumericT]: ...
268
286
 
269
287
  # If value is provided positionally and a sequence of numeric type,
@@ -285,6 +303,7 @@ class SliderMixin:
285
303
  *,
286
304
  disabled: bool = False,
287
305
  label_visibility: LabelVisibility = "visible",
306
+ width: WidthWithoutContent = "stretch",
288
307
  ) -> tuple[SliderNumericT, SliderNumericT]: ...
289
308
 
290
309
  # If min-value is provided and a datelike type, and value (if provided)
@@ -306,6 +325,7 @@ class SliderMixin:
306
325
  *,
307
326
  disabled: bool = False,
308
327
  label_visibility: LabelVisibility = "visible",
328
+ width: WidthWithoutContent = "stretch",
309
329
  ) -> SliderDatelikeT: ...
310
330
 
311
331
  # If max-value is provided and a datelike type, and value (if provided)
@@ -314,7 +334,7 @@ class SliderMixin:
314
334
  def slider(
315
335
  self,
316
336
  label: str,
317
- min_value: SliderDatelikeT | None = None,
337
+ min_value: None = None,
318
338
  *,
319
339
  max_value: SliderDatelikeT,
320
340
  value: SliderDatelikeT | None = None,
@@ -327,6 +347,7 @@ class SliderMixin:
327
347
  kwargs: WidgetKwargs | None = None,
328
348
  disabled: bool = False,
329
349
  label_visibility: LabelVisibility = "visible",
350
+ width: WidthWithoutContent = "stretch",
330
351
  ) -> SliderDatelikeT: ...
331
352
 
332
353
  # If value is provided and a datelike type, return the same datelike type.
@@ -334,8 +355,8 @@ class SliderMixin:
334
355
  def slider(
335
356
  self,
336
357
  label: str,
337
- min_value: SliderDatelikeT | None = None,
338
- max_value: SliderDatelikeT | None = None,
358
+ min_value: None = None,
359
+ max_value: None = None,
339
360
  *,
340
361
  value: SliderDatelikeT,
341
362
  step: StepDatelikeT | None = None,
@@ -347,6 +368,7 @@ class SliderMixin:
347
368
  kwargs: WidgetKwargs | None = None,
348
369
  disabled: bool = False,
349
370
  label_visibility: LabelVisibility = "visible",
371
+ width: WidthWithoutContent = "stretch",
350
372
  ) -> SliderDatelikeT: ...
351
373
 
352
374
  # If value is provided and a sequence of datelike type,
@@ -358,7 +380,9 @@ class SliderMixin:
358
380
  min_value: SliderDatelikeT | None = None,
359
381
  max_value: SliderDatelikeT | None = None,
360
382
  *,
361
- value: SliderDatelikeSpanT[SliderDatelikeT],
383
+ value: list[SliderDatelikeT]
384
+ | tuple[SliderDatelikeT]
385
+ | tuple[SliderDatelikeT, SliderDatelikeT],
362
386
  step: StepDatelikeT | None = None,
363
387
  format: str | None = None,
364
388
  key: Key | None = None,
@@ -368,6 +392,7 @@ class SliderMixin:
368
392
  kwargs: WidgetKwargs | None = None,
369
393
  disabled: bool = False,
370
394
  label_visibility: LabelVisibility = "visible",
395
+ width: WidthWithoutContent = "stretch",
371
396
  ) -> tuple[SliderDatelikeT, SliderDatelikeT]: ...
372
397
 
373
398
  # If value is provided positionally and a sequence of datelike type,
@@ -390,6 +415,7 @@ class SliderMixin:
390
415
  *,
391
416
  disabled: bool = False,
392
417
  label_visibility: LabelVisibility = "visible",
418
+ width: WidthWithoutContent = "stretch",
393
419
  ) -> tuple[SliderDatelikeT, SliderDatelikeT]: ...
394
420
 
395
421
  # https://github.com/python/mypy/issues/17614
@@ -289,12 +289,11 @@ class StreamlitPage:
289
289
  if callable(self._page):
290
290
  self._page()
291
291
  return
292
- else:
293
- code = ctx.pages_manager.get_page_script_byte_code(str(self._page))
294
- module = types.ModuleType("__main__")
295
- # We want __file__ to be the string path to the script
296
- module.__dict__["__file__"] = str(self._page)
297
- exec(code, module.__dict__) # noqa: S102
292
+ code = ctx.pages_manager.get_page_script_byte_code(str(self._page))
293
+ module = types.ModuleType("__main__")
294
+ # We want __file__ to be the string path to the script
295
+ module.__dict__["__file__"] = str(self._page)
296
+ exec(code, module.__dict__) # noqa: S102
298
297
 
299
298
  @property
300
299
  def _script_hash(self) -> str:
@@ -316,6 +316,11 @@ def get_data_cache_stats_provider() -> CacheStatsProvider:
316
316
  return _data_caches
317
317
 
318
318
 
319
+ # Type-annotate the decorator function.
320
+ # (See https://mypy.readthedocs.io/en/stable/generics.html#decorator-factories)
321
+ F = TypeVar("F", bound=Callable[..., Any])
322
+
323
+
319
324
  class CacheDataAPI:
320
325
  """Implements the public st.cache_data API: the @st.cache_data decorator, and
321
326
  st.cache_data.clear().
@@ -336,10 +341,6 @@ class CacheDataAPI:
336
341
  decorator_metric_name, self._decorator
337
342
  )
338
343
 
339
- # Type-annotate the decorator function.
340
- # (See https://mypy.readthedocs.io/en/stable/generics.html#decorator-factories)
341
- F = TypeVar("F", bound=Callable[..., Any])
342
-
343
344
  # Bare decorator usage
344
345
  @overload
345
346
  def __call__(self, func: F) -> F: ...
@@ -566,16 +567,19 @@ class CacheDataAPI:
566
567
  if experimental_allow_widgets:
567
568
  show_widget_replay_deprecation("cache_data")
568
569
 
569
- def wrapper(f): # noqa: ANN001, ANN202
570
- return make_cached_func_wrapper(
571
- CachedDataFuncInfo(
572
- func=f,
573
- persist=persist_string,
574
- show_spinner=show_spinner,
575
- max_entries=max_entries,
576
- ttl=ttl,
577
- hash_funcs=hash_funcs,
578
- )
570
+ def wrapper(f: F) -> F:
571
+ return cast(
572
+ "F",
573
+ make_cached_func_wrapper(
574
+ CachedDataFuncInfo(
575
+ func=f, # type: ignore
576
+ persist=persist_string,
577
+ show_spinner=show_spinner,
578
+ max_entries=max_entries,
579
+ ttl=ttl,
580
+ hash_funcs=hash_funcs,
581
+ )
582
+ ),
579
583
  )
580
584
 
581
585
  if func is None:
@@ -30,7 +30,7 @@ def get_cached_func_name_md(func: Any) -> str:
30
30
  """Get markdown representation of the function name."""
31
31
  if hasattr(func, "__name__"):
32
32
  return f"`{func.__name__}()`"
33
- elif hasattr(type(func), "__name__"):
33
+ if hasattr(type(func), "__name__"):
34
34
  return f"`{type(func).__name__}`"
35
35
  return f"`{type(func)}`"
36
36
 
@@ -218,8 +218,7 @@ class CachedMessageReplayContext(threading.local):
218
218
  """
219
219
  if len(self._seen_dg_stack) > 0 and acting_on_id in self._seen_dg_stack[-1]:
220
220
  return acting_on_id
221
- else:
222
- return invoked_id
221
+ return invoked_id
223
222
 
224
223
  def save_image_data(
225
224
  self, image_data: bytes | str, mimetype: str, image_id: str
@@ -131,9 +131,8 @@ class InMemoryCacheStorageWrapper(CacheStorage):
131
131
  _LOGGER.debug("Memory cache HIT: %s", key)
132
132
  return entry
133
133
 
134
- else:
135
- _LOGGER.debug("Memory cache MISS: %s", key)
136
- raise CacheStorageKeyNotFoundError("Key not found in mem cache")
134
+ _LOGGER.debug("Memory cache MISS: %s", key)
135
+ raise CacheStorageKeyNotFoundError("Key not found in mem cache")
137
136
 
138
137
  def _write_to_mem_cache(self, key: str, entry_bytes: bytes) -> None:
139
138
  with self._mem_cache_lock:
@@ -202,7 +202,7 @@ def connection_factory(
202
202
  pass
203
203
 
204
204
 
205
- def connection_factory(
205
+ def connection_factory( # type: ignore
206
206
  name,
207
207
  type=None,
208
208
  max_entries=None,
@@ -328,11 +328,7 @@ class ContextProxy:
328
328
  url_without_page_prefix = maybe_trim_page_path(
329
329
  url_from_frontend, ctx.pages_manager
330
330
  )
331
- url_with_page_prefix = maybe_add_page_path(
332
- url_without_page_prefix, ctx.pages_manager
333
- )
334
-
335
- return url_with_page_prefix
331
+ return maybe_add_page_path(url_without_page_prefix, ctx.pages_manager)
336
332
 
337
333
  @property
338
334
  @gather_metrics("context.ip_address")
@@ -38,8 +38,7 @@ def _get_session_id() -> str:
38
38
  # "streamlit run myscript.py". In which case the session ID doesn't
39
39
  # matter and can just be a constant, as there's only ever "session".
40
40
  return "dontcare"
41
- else:
42
- return ctx.session_id
41
+ return ctx.session_id
43
42
 
44
43
 
45
44
  class MediaFileMetadata:
@@ -134,11 +134,10 @@ def _mpa_v1(main_script_path: str) -> None:
134
134
  PAGES_FOLDER = MAIN_SCRIPT_PATH.parent / "pages"
135
135
 
136
136
  # Read out the my_pages folder and create a page for every script:
137
- pages = PAGES_FOLDER.glob("*.py")
138
137
  pages = sorted(
139
138
  [
140
139
  page
141
- for page in pages
140
+ for page in PAGES_FOLDER.glob("*.py")
142
141
  if page.name.endswith(".py")
143
142
  and not page.name.startswith(".")
144
143
  and page.name != "__init__.py"
@@ -45,29 +45,31 @@ class SecretErrorMessages:
45
45
  """
46
46
 
47
47
  def __init__(self) -> None:
48
- self.missing_attr_message = lambda attr_name: (
48
+ self.missing_attr_message: Callable[[str], str] = lambda attr_name: (
49
49
  f'st.secrets has no attribute "{attr_name}". '
50
50
  "Did you forget to add it to secrets.toml, mount it to secret directory, or the app settings "
51
51
  "on Streamlit Cloud? More info: "
52
52
  "https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
53
53
  )
54
- self.missing_key_message = lambda key: (
54
+ self.missing_key_message: Callable[[str], str] = lambda key: (
55
55
  f'st.secrets has no key "{key}". '
56
56
  "Did you forget to add it to secrets.toml, mount it to secret directory, or the app settings "
57
57
  "on Streamlit Cloud? More info: "
58
58
  "https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
59
59
  )
60
- self.no_secrets_found = lambda file_paths: (
60
+ self.no_secrets_found: Callable[[list[str]], str] = lambda file_paths: (
61
61
  f"No secrets found. Valid paths for a secrets.toml file or secret directories are: {', '.join(file_paths)}"
62
62
  )
63
- self.error_parsing_file_at_path = (
63
+ self.error_parsing_file_at_path: Callable[[str, Exception], str] = (
64
64
  lambda path, ex: f"Error parsing secrets file at {path}: {ex}"
65
65
  )
66
- self.subfolder_path_is_not_a_folder = lambda sub_folder_path: (
67
- f"{sub_folder_path} is not a folder. "
68
- "To use directory based secrets, mount every secret in a subfolder under the secret directory"
66
+ self.subfolder_path_is_not_a_folder: Callable[[str], str] = (
67
+ lambda sub_folder_path: (
68
+ f"{sub_folder_path} is not a folder. "
69
+ "To use directory based secrets, mount every secret in a subfolder under the secret directory"
70
+ )
69
71
  )
70
- self.invalid_secret_path = lambda path: (
72
+ self.invalid_secret_path: Callable[[str], str] = lambda path: (
71
73
  f"Invalid secrets path: {path}: path is not a .toml file or a directory"
72
74
  )
73
75
 
@@ -15,7 +15,7 @@
15
15
  from __future__ import annotations
16
16
 
17
17
  from collections.abc import Iterable, Iterator, MutableMapping
18
- from typing import TYPE_CHECKING, overload
18
+ from typing import TYPE_CHECKING, Any, overload
19
19
 
20
20
  from streamlit.runtime.metrics_util import gather_metrics
21
21
  from streamlit.runtime.state.session_state_proxy import get_session_state
@@ -55,7 +55,7 @@ class QueryParamsProxy(MutableMapping[str, str]):
55
55
  del qp[key]
56
56
 
57
57
  @gather_metrics("query_params.set_item")
58
- def __setitem__(self, key: str, value: str | Iterable[str]) -> None:
58
+ def __setitem__(self, key: str, value: Any) -> None:
59
59
  with get_session_state().query_params() as qp:
60
60
  qp[key] = value
61
61
 
@@ -76,18 +76,18 @@ class QueryParamsProxy(MutableMapping[str, str]):
76
76
 
77
77
  @overload
78
78
  def update(
79
- self, mapping: SupportsKeysAndGetItem[str, str | Iterable[str]], /, **kwds: str
79
+ self, params: SupportsKeysAndGetItem[str, str | Iterable[str]], /, **kwds: str
80
80
  ) -> None: ...
81
81
 
82
82
  @overload
83
83
  def update(
84
- self, keys_and_values: Iterable[tuple[str, str | Iterable[str]]], /, **kwds: str
84
+ self, params: Iterable[tuple[str, str | Iterable[str]]], /, **kwds: str
85
85
  ) -> None: ...
86
86
 
87
87
  @overload
88
88
  def update(self, **kwds: str | Iterable[str]) -> None: ...
89
89
 
90
- def update(self, other=(), /, **kwds):
90
+ def update(self, params=(), /, **kwds) -> None: # type: ignore
91
91
  """
92
92
  Update one or more values in query_params at once from a dictionary or
93
93
  dictionary-like object.
@@ -102,10 +102,10 @@ class QueryParamsProxy(MutableMapping[str, str]):
102
102
  Additional key/value pairs to update passed as keyword arguments.
103
103
  """
104
104
  with get_session_state().query_params() as qp:
105
- qp.update(other, **kwds)
105
+ qp.update(params, **kwds)
106
106
 
107
107
  @gather_metrics("query_params.set_attr")
108
- def __setattr__(self, key: str, value: str | Iterable[str]) -> None:
108
+ def __setattr__(self, key: str, value: Any) -> None:
109
109
  with get_session_state().query_params() as qp:
110
110
  qp[key] = value
111
111
 
@@ -165,17 +165,19 @@ class QueryParamsProxy(MutableMapping[str, str]):
165
165
  return qp.to_dict()
166
166
 
167
167
  @overload
168
- def from_dict(
169
- self, keys_and_values: Iterable[tuple[str, str | Iterable[str]]]
170
- ) -> None: ...
168
+ def from_dict(self, params: Iterable[tuple[str, str | Iterable[str]]]) -> None: ...
171
169
 
172
170
  @overload
173
171
  def from_dict(
174
- self, mapping: SupportsKeysAndGetItem[str, str | Iterable[str]]
172
+ self, params: SupportsKeysAndGetItem[str, str | Iterable[str]]
175
173
  ) -> None: ...
176
174
 
177
175
  @gather_metrics("query_params.from_dict")
178
- def from_dict(self, params):
176
+ def from_dict(
177
+ self,
178
+ params: SupportsKeysAndGetItem[str, str | Iterable[str]]
179
+ | Iterable[tuple[str, str | Iterable[str]]],
180
+ ) -> None:
179
181
  """
180
182
  Set all of the query parameters from a dictionary or dictionary-like object.
181
183
 
@@ -147,7 +147,7 @@ class WStates(MutableMapping[str, Any]):
147
147
  def __len__(self) -> int:
148
148
  return len(self.states)
149
149
 
150
- def __iter__(self):
150
+ def __iter__(self) -> Iterator[str]:
151
151
  # For this and many other methods, we can't simply delegate to the
152
152
  # states field, because we need to invoke `__getitem__` for any
153
153
  # values, to handle deserialization and unwrapping of values.
@@ -252,8 +252,7 @@ class WStates(MutableMapping[str, Any]):
252
252
  for widget_id in self.states
253
253
  if self.get_serialized(widget_id)
254
254
  ]
255
- states = cast("list[WidgetStateProto]", states)
256
- return states
255
+ return cast("list[WidgetStateProto]", states)
257
256
 
258
257
  def call_callback(self, widget_id: str) -> None:
259
258
  """Call the given widget's callback and return the callback's
@@ -326,7 +325,7 @@ class KeyIdMapper:
326
325
  self._key_id_mapping.update(other._key_id_mapping)
327
326
  self._id_key_mapping.update(other._id_key_mapping)
328
327
 
329
- def clear(self):
328
+ def clear(self) -> None:
330
329
  self._key_id_mapping.clear()
331
330
  self._id_key_mapping.clear()
332
331
 
@@ -51,7 +51,7 @@
51
51
  <script>
52
52
  window.prerenderReady = false
53
53
  </script>
54
- <script type="module" crossorigin src="./static/js/index.Dqcp7EZB.js"></script>
54
+ <script type="module" crossorigin src="./static/js/index.DQoQce-F.js"></script>
55
55
  <link rel="stylesheet" crossorigin href="./static/css/index.C6rq3aMZ.css">
56
56
  </head>
57
57
  <body>
@@ -1 +1 @@
1
- import{r,E as a,_ as n}from"./index.Dqcp7EZB.js";var i=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(a,n({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});i.displayName="ErrorOutline";export{i as E};
1
+ import{r,E as a,_ as n}from"./index.DQoQce-F.js";var i=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(a,n({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});i.displayName="ErrorOutline";export{i as E};
@@ -1 +1 @@
1
- import{r as e,E as n,_ as a}from"./index.Dqcp7EZB.js";var o=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),e.createElement("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}))});o.displayName="Delete";var i=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("rect",{width:24,height:24,fill:"none"}),e.createElement("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4l-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}))});i.displayName="FileDownload";export{o as D,i as F};
1
+ import{r as e,E as n,_ as a}from"./index.DQoQce-F.js";var o=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),e.createElement("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}))});o.displayName="Delete";var i=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("rect",{width:24,height:24,fill:"none"}),e.createElement("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4l-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}))});i.displayName="FileDownload";export{o as D,i as F};