streamlit-nightly 1.45.1.dev20250508__py3-none-any.whl → 1.45.1.dev20250510__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 (208) hide show
  1. streamlit/auth_util.py +3 -3
  2. streamlit/cli_util.py +3 -2
  3. streamlit/commands/execution_control.py +1 -1
  4. streamlit/commands/logo.py +2 -2
  5. streamlit/commands/navigation.py +6 -5
  6. streamlit/commands/page_config.py +3 -1
  7. streamlit/components/types/base_custom_component.py +7 -7
  8. streamlit/components/v1/custom_component.py +6 -6
  9. streamlit/config.py +9 -9
  10. streamlit/config_option.py +2 -2
  11. streamlit/connections/base_connection.py +3 -3
  12. streamlit/connections/snowflake_connection.py +5 -5
  13. streamlit/connections/snowpark_connection.py +3 -3
  14. streamlit/connections/sql_connection.py +9 -10
  15. streamlit/cursor.py +6 -6
  16. streamlit/delta_generator.py +7 -6
  17. streamlit/delta_generator_singletons.py +3 -3
  18. streamlit/deprecation_util.py +1 -1
  19. streamlit/elements/arrow.py +4 -5
  20. streamlit/elements/code.py +1 -1
  21. streamlit/elements/dialog_decorator.py +3 -3
  22. streamlit/elements/doc_string.py +20 -20
  23. streamlit/elements/layouts.py +26 -7
  24. streamlit/elements/lib/built_in_chart_utils.py +38 -40
  25. streamlit/elements/lib/color_util.py +3 -3
  26. streamlit/elements/lib/column_types.py +4 -4
  27. streamlit/elements/lib/dialog.py +2 -2
  28. streamlit/elements/lib/event_utils.py +1 -1
  29. streamlit/elements/lib/image_utils.py +1 -1
  30. streamlit/elements/lib/mutable_status_container.py +1 -1
  31. streamlit/elements/lib/options_selector_utils.py +2 -2
  32. streamlit/elements/lib/policies.py +3 -3
  33. streamlit/elements/lib/utils.py +5 -5
  34. streamlit/elements/metric.py +1 -1
  35. streamlit/elements/progress.py +9 -12
  36. streamlit/elements/vega_charts.py +3 -3
  37. streamlit/elements/widgets/audio_input.py +1 -1
  38. streamlit/elements/widgets/button.py +1 -1
  39. streamlit/elements/widgets/button_group.py +4 -4
  40. streamlit/elements/widgets/camera_input.py +1 -1
  41. streamlit/elements/widgets/checkbox.py +2 -2
  42. streamlit/elements/widgets/color_picker.py +1 -1
  43. streamlit/elements/widgets/data_editor.py +3 -3
  44. streamlit/elements/widgets/file_uploader.py +1 -1
  45. streamlit/elements/widgets/multiselect.py +3 -3
  46. streamlit/elements/widgets/number_input.py +2 -2
  47. streamlit/elements/widgets/radio.py +1 -1
  48. streamlit/elements/widgets/select_slider.py +1 -1
  49. streamlit/elements/widgets/selectbox.py +2 -2
  50. streamlit/elements/widgets/slider.py +19 -17
  51. streamlit/elements/widgets/text_widgets.py +2 -2
  52. streamlit/elements/widgets/time_widgets.py +2 -2
  53. streamlit/elements/write.py +3 -6
  54. streamlit/errors.py +34 -21
  55. streamlit/external/langchain/streamlit_callback_handler.py +2 -2
  56. streamlit/file_util.py +8 -8
  57. streamlit/git_util.py +2 -2
  58. streamlit/hello/dataframe_demo.py +1 -1
  59. streamlit/hello/mapping_demo.py +1 -1
  60. streamlit/navigation/page.py +1 -1
  61. streamlit/proto/Block_pb2.py +38 -29
  62. streamlit/proto/Block_pb2.pyi +68 -4
  63. streamlit/proto/DataFrame_pb2.pyi +1 -1
  64. streamlit/proto/GapSize_pb2.py +29 -0
  65. streamlit/proto/GapSize_pb2.pyi +70 -0
  66. streamlit/proto/HeightConfig_pb2.py +27 -0
  67. streamlit/proto/HeightConfig_pb2.pyi +48 -0
  68. streamlit/proto/NamedDataSet_pb2.pyi +1 -1
  69. streamlit/proto/WidthConfig_pb2.py +2 -2
  70. streamlit/proto/WidthConfig_pb2.pyi +15 -1
  71. streamlit/runtime/app_session.py +2 -2
  72. streamlit/runtime/caching/cache_data_api.py +9 -5
  73. streamlit/runtime/caching/cache_errors.py +3 -3
  74. streamlit/runtime/caching/cache_resource_api.py +7 -7
  75. streamlit/runtime/caching/cache_utils.py +9 -9
  76. streamlit/runtime/caching/cached_message_replay.py +1 -1
  77. streamlit/runtime/caching/hashing.py +70 -74
  78. streamlit/runtime/caching/legacy_cache_api.py +1 -1
  79. streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +3 -1
  80. streamlit/runtime/caching/storage/local_disk_cache_storage.py +1 -1
  81. streamlit/runtime/connection_factory.py +15 -15
  82. streamlit/runtime/context.py +2 -2
  83. streamlit/runtime/credentials.py +3 -3
  84. streamlit/runtime/fragment.py +3 -4
  85. streamlit/runtime/media_file_manager.py +2 -2
  86. streamlit/runtime/memory_media_file_storage.py +1 -1
  87. streamlit/runtime/memory_uploaded_file_manager.py +1 -1
  88. streamlit/runtime/metrics_util.py +5 -6
  89. streamlit/runtime/pages_manager.py +3 -3
  90. streamlit/runtime/runtime.py +1 -1
  91. streamlit/runtime/runtime_util.py +2 -2
  92. streamlit/runtime/scriptrunner/exec_code.py +10 -3
  93. streamlit/runtime/scriptrunner/magic.py +13 -8
  94. streamlit/runtime/scriptrunner/script_runner.py +2 -2
  95. streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
  96. streamlit/runtime/scriptrunner_utils/script_run_context.py +6 -5
  97. streamlit/runtime/secrets.py +8 -11
  98. streamlit/runtime/state/query_params.py +2 -2
  99. streamlit/runtime/state/query_params_proxy.py +1 -1
  100. streamlit/runtime/state/safe_session_state.py +2 -2
  101. streamlit/runtime/state/session_state.py +17 -15
  102. streamlit/runtime/stats.py +1 -1
  103. streamlit/runtime/uploaded_file_manager.py +1 -1
  104. streamlit/source_util.py +3 -4
  105. streamlit/static/index.html +1 -1
  106. streamlit/static/static/js/{ErrorOutline.esm.C9UoaGEN.js → ErrorOutline.esm.BewaDzzJ.js} +1 -1
  107. streamlit/static/static/js/{FileDownload.esm.DoToR9q0.js → FileDownload.esm.D6ilL7v-.js} +1 -1
  108. streamlit/static/static/js/{FileHelper.Bt4VJ--Q.js → FileHelper.q7erXtkb.js} +1 -1
  109. streamlit/static/static/js/{FormClearHelper.D5PbW8FI.js → FormClearHelper.Dd0v0IXt.js} +1 -1
  110. streamlit/static/static/js/{Hooks.DgkQ2Xp9.js → Hooks.CchmJZGs.js} +1 -1
  111. streamlit/static/static/js/{InputInstructions.DLnLhwHI.js → InputInstructions.DI9h4PJ7.js} +1 -1
  112. streamlit/static/static/js/{ProgressBar.BtSgh_K-.js → ProgressBar.DfcVR_JA.js} +1 -1
  113. streamlit/static/static/js/{RenderInPortalIfExists.CjdyBvQX.js → RenderInPortalIfExists.BAkT-LV5.js} +1 -1
  114. streamlit/static/static/js/{Toolbar.CAYIzVZk.js → Toolbar.CNzefYiX.js} +1 -1
  115. streamlit/static/static/js/{base-input.CD4xW4_9.js → base-input.BmA1ZV9Y.js} +1 -1
  116. streamlit/static/static/js/{checkbox.Ba4jj5dR.js → checkbox.mT4TKcAG.js} +1 -1
  117. streamlit/static/static/js/{createSuper.BBGT9Ijd.js → createSuper.Duo43uhY.js} +1 -1
  118. streamlit/static/static/js/{data-grid-overlay-editor.CYuk1Aj7.js → data-grid-overlay-editor.CY3l_gmP.js} +1 -1
  119. streamlit/static/static/js/{downloader.DM9KEOCw.js → downloader.CM5asV91.js} +1 -1
  120. streamlit/static/static/js/{es6.FqM62T4b.js → es6.uiOeU51e.js} +2 -2
  121. streamlit/static/static/js/{iframeResizer.contentWindow.s2B09mw2.js → iframeResizer.contentWindow.ClkMmI3q.js} +1 -1
  122. streamlit/static/static/js/{index.Cwtbhfaf.js → index.1tDlzcmX.js} +1 -1
  123. streamlit/static/static/js/index.3d64wPzr.js +1 -0
  124. streamlit/static/static/js/{index.DQi04JYE.js → index.B-oXGsp7.js} +1 -1
  125. streamlit/static/static/js/{index.0pkoyBcb.js → index.B2EfQ-qM.js} +1 -1
  126. streamlit/static/static/js/{index.DkGCnTMe.js → index.B5wTpdet.js} +1 -1
  127. streamlit/static/static/js/{index.DG8IxVeM.js → index.B6y8ns6u.js} +2 -2
  128. streamlit/static/static/js/{index.B9FiDQ3U.js → index.BArkjssT.js} +1 -1
  129. streamlit/static/static/js/{index.CpDFZQ4Y.js → index.BPK3aPVr.js} +1 -1
  130. streamlit/static/static/js/index.BWubePhz.js +1 -0
  131. streamlit/static/static/js/{index.T5LKPcND.js → index.BmBUBll0.js} +1 -1
  132. streamlit/static/static/js/{index.BMXmhMlZ.js → index.BnmoQ0mJ.js} +1 -1
  133. streamlit/static/static/js/{index.BsjuUMyW.js → index.C1_voZpt.js} +1 -1
  134. streamlit/static/static/js/index.C6tuB1Tp.js +2 -0
  135. streamlit/static/static/js/{index.BoMRR3tN.js → index.CB8SwV8L.js} +1 -1
  136. streamlit/static/static/js/{index.CEKMSkSh.js → index.CXmZFP__.js} +36 -36
  137. streamlit/static/static/js/{index.DTi8Lw0k.js → index.CYAmxIg2.js} +1 -1
  138. streamlit/static/static/js/{index.DMrO9G6A.js → index.D-zMZsin.js} +1 -1
  139. streamlit/static/static/js/{index.JTeVe9GQ.js → index.D56z-_rt.js} +1 -1
  140. streamlit/static/static/js/index.D6AKDy4z.js +1 -0
  141. streamlit/static/static/js/{index.BFqpCk2P.js → index.D9lEoddJ.js} +1 -1
  142. streamlit/static/static/js/index.DAEzs_UL.js +1 -0
  143. streamlit/static/static/js/{index.BDTYk2an.js → index.DLO5_tVd.js} +1 -1
  144. streamlit/static/static/js/{index.BY7-qCf5.js → index.DLyB6OQM.js} +1 -1
  145. streamlit/static/static/js/index.DNWXtL99.js +1 -0
  146. streamlit/static/static/js/index.DbgE46VI.js +1 -0
  147. streamlit/static/static/js/{index.b9kK7Vzl.js → index.DeLPvnoy.js} +1 -1
  148. streamlit/static/static/js/{index.CH9XN_-G.js → index.DeeFVG0Y.js} +2 -2
  149. streamlit/static/static/js/{index.BVA8TXNT.js → index.Dhu_cVNQ.js} +1 -1
  150. streamlit/static/static/js/{index.R0peMEpV.js → index.Dj8nqcpI.js} +1 -1
  151. streamlit/static/static/js/{index.D9FvPPrI.js → index.DpWg6flp.js} +1 -1
  152. streamlit/static/static/js/{index.CeiCniCg.js → index.IqYlA3jn.js} +1 -1
  153. streamlit/static/static/js/{index.DSDkXosb.js → index.JA6OF_5t.js} +2 -2
  154. streamlit/static/static/js/{index.C2qCX1Lh.js → index.PoIwzrI7.js} +151 -151
  155. streamlit/static/static/js/{index.CqaahZPf.js → index.SW3uv22k.js} +1 -1
  156. streamlit/static/static/js/{index.DWaB7Scf.js → index.WlA_Ju7i.js} +1 -1
  157. streamlit/static/static/js/{index.CP2PmB93.js → index.blwBIOHe.js} +1 -1
  158. streamlit/static/static/js/{index.CyE1OdOj.js → index.wiodyGjO.js} +1 -1
  159. streamlit/static/static/js/{input.DMOGBelK.js → input.B3uNJm6d.js} +1 -1
  160. streamlit/static/static/js/{memory.DmCktBGW.js → memory.BWtwV556.js} +1 -1
  161. streamlit/static/static/js/{mergeWith.DeWTsJ5h.js → mergeWith.BeTmYGS_.js} +1 -1
  162. streamlit/static/static/js/{number-overlay-editor.DDFelcUP.js → number-overlay-editor.MW9-6kFx.js} +1 -1
  163. streamlit/static/static/js/{possibleConstructorReturn.CYJtAqB-.js → possibleConstructorReturn.ZgHiGHSO.js} +1 -1
  164. streamlit/static/static/js/{sandbox.CfaU9Ih9.js → sandbox.BZyTt4zT.js} +1 -1
  165. streamlit/static/static/js/{textarea.7hWYKDw2.js → textarea.CgvEg9Xi.js} +1 -1
  166. streamlit/static/static/js/{timepicker.DZsgZ9oE.js → timepicker.CHPC9KOb.js} +1 -1
  167. streamlit/static/static/js/{toConsumableArray.CqWB4Jry.js → toConsumableArray.6GvveewD.js} +1 -1
  168. streamlit/static/static/js/{uniqueId.DQ533D9O.js → uniqueId.BV5h1uCx.js} +1 -1
  169. streamlit/static/static/js/{useBasicWidgetState.-99xbU_o.js → useBasicWidgetState.DzE2MsN8.js} +1 -1
  170. streamlit/static/static/js/{useOnInputChange.B4G2Q7Bu.js → useOnInputChange.sGAnyCSU.js} +1 -1
  171. streamlit/static/static/js/{withFullScreenWrapper.BJQZ2aNc.js → withFullScreenWrapper.Bh08pTH8.js} +1 -1
  172. streamlit/string_util.py +6 -7
  173. streamlit/temporary_directory.py +12 -3
  174. streamlit/testing/v1/app_test.py +11 -6
  175. streamlit/testing/v1/element_tree.py +134 -158
  176. streamlit/testing/v1/local_script_runner.py +5 -5
  177. streamlit/testing/v1/util.py +11 -4
  178. streamlit/type_util.py +3 -4
  179. streamlit/user_info.py +3 -2
  180. streamlit/util.py +1 -1
  181. streamlit/vendor/pympler/asizeof.py +1 -1
  182. streamlit/watcher/event_based_path_watcher.py +1 -1
  183. streamlit/watcher/folder_black_list.py +1 -1
  184. streamlit/watcher/local_sources_watcher.py +5 -5
  185. streamlit/watcher/path_watcher.py +1 -1
  186. streamlit/web/cli.py +12 -11
  187. streamlit/web/server/browser_websocket_handler.py +1 -1
  188. streamlit/web/server/component_request_handler.py +1 -1
  189. streamlit/web/server/media_file_handler.py +2 -1
  190. streamlit/web/server/oauth_authlib_routes.py +2 -2
  191. streamlit/web/server/oidc_mixin.py +13 -6
  192. streamlit/web/server/routes.py +3 -3
  193. streamlit/web/server/server.py +1 -1
  194. streamlit/web/server/server_util.py +7 -6
  195. streamlit/web/server/upload_file_request_handler.py +5 -5
  196. {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250510.dist-info}/METADATA +1 -1
  197. {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250510.dist-info}/RECORD +201 -197
  198. {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250510.dist-info}/WHEEL +1 -1
  199. streamlit/static/static/js/index.CCD4LJ9Q.js +0 -1
  200. streamlit/static/static/js/index.CbLZDRQu.js +0 -1
  201. streamlit/static/static/js/index.D9qEk5xd.js +0 -1
  202. streamlit/static/static/js/index.DTXSsTgK.js +0 -1
  203. streamlit/static/static/js/index.DqVjOqxm.js +0 -1
  204. streamlit/static/static/js/index.RHbaxsqm.js +0 -1
  205. streamlit/static/static/js/index.hT9gkW3a.js +0 -2
  206. {streamlit_nightly-1.45.1.dev20250508.data → streamlit_nightly-1.45.1.dev20250510.data}/scripts/streamlit.cmd +0 -0
  207. {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250510.dist-info}/entry_points.txt +0 -0
  208. {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250510.dist-info}/top_level.txt +0 -0
@@ -168,25 +168,25 @@ def _marshall(
168
168
  doc_string_proto.width_config.CopyFrom(width_config)
169
169
 
170
170
 
171
- def _get_name(obj):
171
+ def _get_name(obj: object) -> str | None:
172
172
  # Try to get the fully-qualified name of the object.
173
173
  # For example: st.help(bar.Baz(123))
174
174
  # The name is bar.Baz
175
175
  name = getattr(obj, "__qualname__", None)
176
176
  if name:
177
- return name
177
+ return cast("str", name)
178
178
 
179
179
  # Try to get the name of the object.
180
180
  # For example: st.help(bar.Baz(123))
181
181
  # The name is Baz
182
- return getattr(obj, "__name__", None)
182
+ return cast("str | None", getattr(obj, "__name__", None))
183
183
 
184
184
 
185
- def _get_module(obj):
185
+ def _get_module(obj: object) -> str | None:
186
186
  return getattr(obj, "__module__", None)
187
187
 
188
188
 
189
- def _get_signature(obj):
189
+ def _get_signature(obj: object) -> str | None:
190
190
  if not inspect.isclass(obj) and not callable(obj):
191
191
  return None
192
192
 
@@ -215,7 +215,7 @@ def _get_signature(obj):
215
215
  return sig
216
216
 
217
217
 
218
- def _get_docstring(obj):
218
+ def _get_docstring(obj: object) -> str | None:
219
219
  doc_string = inspect.getdoc(obj)
220
220
 
221
221
  # Sometimes an object has no docstring, but the object's type does.
@@ -239,7 +239,7 @@ def _get_docstring(obj):
239
239
  return None
240
240
 
241
241
 
242
- def _get_variable_name():
242
+ def _get_variable_name() -> str | None:
243
243
  """Try to get the name of the variable in the current line, as set by the user.
244
244
 
245
245
  For example:
@@ -256,7 +256,7 @@ def _get_variable_name():
256
256
  return _get_variable_name_from_code_str(code)
257
257
 
258
258
 
259
- def _get_variable_name_from_code_str(code):
259
+ def _get_variable_name_from_code_str(code: str) -> str | None:
260
260
  tree = ast.parse(code)
261
261
 
262
262
  # Example:
@@ -295,7 +295,7 @@ def _get_variable_name_from_code_str(code):
295
295
 
296
296
  # If walrus, get name.
297
297
  # E.g. st.help(foo := 123) should give you "foo".
298
- elif type(arg_node) is ast.NamedExpr:
298
+ if type(arg_node) is ast.NamedExpr:
299
299
  # This next "if" will always be true, but need to add this for the type-checking test to
300
300
  # pass.
301
301
  if type(arg_node.target) is ast.Name:
@@ -329,7 +329,7 @@ def _get_variable_name_from_code_str(code):
329
329
  _NEWLINES = re.compile(r"[\n\r]+")
330
330
 
331
331
 
332
- def _get_current_line_of_code_as_str():
332
+ def _get_current_line_of_code_as_str() -> str | None:
333
333
  scriptrunner_frame = _get_scriptrunner_frame()
334
334
 
335
335
  if scriptrunner_frame is None:
@@ -352,7 +352,7 @@ def _get_current_line_of_code_as_str():
352
352
  return re.sub(_NEWLINES, "", code_as_string.strip())
353
353
 
354
354
 
355
- def _get_scriptrunner_frame():
355
+ def _get_scriptrunner_frame() -> inspect.FrameInfo | None:
356
356
  prev_frame = None
357
357
  scriptrunner_frame = None
358
358
 
@@ -375,7 +375,7 @@ def _get_scriptrunner_frame():
375
375
  return scriptrunner_frame
376
376
 
377
377
 
378
- def _is_stcommand(tree, command_name):
378
+ def _is_stcommand(tree: Any, command_name: str) -> bool:
379
379
  """Checks whether the AST in tree is a call for command_name."""
380
380
  root_node = tree.body[0].value
381
381
 
@@ -391,25 +391,25 @@ def _is_stcommand(tree, command_name):
391
391
  )
392
392
 
393
393
 
394
- def _get_stcommand_arg(tree):
394
+ def _get_stcommand_arg(tree: ast.Module) -> ast.expr | None:
395
395
  """Gets the argument node for the st command in tree (AST)."""
396
396
 
397
- root_node = tree.body[0].value
397
+ root_node = tree.body[0].value # type: ignore
398
398
 
399
399
  if root_node.args:
400
- return root_node.args[0]
400
+ return cast("ast.expr", root_node.args[0])
401
401
 
402
402
  return None
403
403
 
404
404
 
405
- def _get_type_as_str(obj):
405
+ def _get_type_as_str(obj: object) -> str:
406
406
  if inspect.isclass(obj):
407
407
  return "class"
408
408
 
409
409
  return str(type(obj).__name__)
410
410
 
411
411
 
412
- def _get_first_line(text):
412
+ def _get_first_line(text: str) -> str:
413
413
  if not text:
414
414
  return ""
415
415
 
@@ -417,7 +417,7 @@ def _get_first_line(text):
417
417
  return left
418
418
 
419
419
 
420
- def _get_weight(value):
420
+ def _get_weight(value: Any) -> int:
421
421
  if inspect.ismodule(value):
422
422
  return 3
423
423
  if inspect.isclass(value):
@@ -485,12 +485,12 @@ def _get_human_readable_value(value):
485
485
  return _shorten(value_str)
486
486
 
487
487
 
488
- def _shorten(s, length=300):
488
+ def _shorten(s: str, length: int = 300) -> str:
489
489
  s = s.strip()
490
490
  return s[:length] + "..." if len(s) > length else s
491
491
 
492
492
 
493
- def _is_computed_property(obj, attr_name):
493
+ def _is_computed_property(obj: object, attr_name: str) -> bool:
494
494
  obj_class = getattr(obj, "__class__", None)
495
495
 
496
496
  if not obj_class:
@@ -28,6 +28,8 @@ from streamlit.errors import (
28
28
  StreamlitInvalidVerticalAlignmentError,
29
29
  )
30
30
  from streamlit.proto.Block_pb2 import Block as BlockProto
31
+ from streamlit.proto.GapSize_pb2 import GapConfig, GapSize
32
+ from streamlit.proto.HeightConfig_pb2 import HeightConfig
31
33
  from streamlit.runtime.metrics_util import gather_metrics
32
34
  from streamlit.string_util import validate_icon_or_emoji
33
35
 
@@ -149,17 +151,21 @@ class LayoutsMixin:
149
151
  key = to_key(key)
150
152
  block_proto = BlockProto()
151
153
  block_proto.allow_empty = False
152
- block_proto.vertical.border = border or False
154
+ block_proto.flex_container.border = border or False
155
+ block_proto.flex_container.wrap = False
153
156
 
154
157
  if height:
155
158
  # Activate scrolling container behavior:
156
159
  block_proto.allow_empty = True
157
- block_proto.vertical.height = height
160
+
161
+ height_config = HeightConfig()
162
+ height_config.pixel_height = height
163
+ block_proto.flex_container.height_config.CopyFrom(height_config)
158
164
  if border is None:
159
165
  # If border is None, we activated the
160
166
  # border as default setting for scrolling
161
167
  # containers.
162
- block_proto.vertical.border = True
168
+ block_proto.flex_container.border = True
163
169
 
164
170
  if key:
165
171
  # At the moment, the ID is only used for extracting the
@@ -348,22 +354,30 @@ class LayoutsMixin:
348
354
  vertical_alignment=vertical_alignment
349
355
  )
350
356
 
351
- def column_gap(gap):
357
+ def column_gap(gap: str) -> GapSize.ValueType:
358
+ gap_mapping = {
359
+ "small": GapSize.SMALL,
360
+ "medium": GapSize.MEDIUM,
361
+ "large": GapSize.LARGE,
362
+ }
363
+
352
364
  if isinstance(gap, str):
353
365
  gap_size = gap.lower()
354
366
  valid_sizes = ["small", "medium", "large"]
355
367
 
356
368
  if gap_size in valid_sizes:
357
- return gap_size
369
+ return gap_mapping[gap_size]
358
370
 
359
371
  raise StreamlitInvalidColumnGapError(gap=gap)
360
372
 
361
373
  gap_size = column_gap(gap)
374
+ gap_config = GapConfig()
375
+ gap_config.gap_size = gap_size
362
376
 
363
377
  def column_proto(normalized_weight: float) -> BlockProto:
364
378
  col_proto = BlockProto()
365
379
  col_proto.column.weight = normalized_weight
366
- col_proto.column.gap = gap_size
380
+ col_proto.column.gap_config.CopyFrom(gap_config)
367
381
  col_proto.column.vertical_alignment = vertical_alignment_mapping[
368
382
  vertical_alignment
369
383
  ]
@@ -372,7 +386,12 @@ class LayoutsMixin:
372
386
  return col_proto
373
387
 
374
388
  block_proto = BlockProto()
375
- block_proto.horizontal.gap = gap_size
389
+ block_proto.flex_container.direction = (
390
+ BlockProto.FlexContainer.Direction.HORIZONTAL
391
+ )
392
+ block_proto.flex_container.wrap = True
393
+ block_proto.flex_container.gap_config.CopyFrom(gap_config)
394
+ block_proto.flex_container.scale = 1
376
395
  row = self.dg._block(block_proto)
377
396
  total_weight = sum(weights)
378
397
  return [row._block(column_proto(w / total_weight)) for w in weights]
@@ -126,7 +126,7 @@ _NON_EXISTENT_COLUMN_NAME: Final = "DOES_NOT_EXIST" + _PROTECTION_SUFFIX
126
126
 
127
127
  def maybe_raise_stack_warning(
128
128
  stack: bool | ChartStackType | None, command: str | None, docs_link: str
129
- ):
129
+ ) -> None:
130
130
  # Check that the stack parameter is valid, raise more informative error if not
131
131
  if stack not in (None, True, False, "normalize", "center", "layered"):
132
132
  raise StreamlitAPIException(
@@ -373,7 +373,7 @@ def _infer_vegalite_type(
373
373
  ]:
374
374
  return "quantitative"
375
375
 
376
- elif typ == "categorical" and data.cat.ordered:
376
+ if typ == "categorical" and data.cat.ordered:
377
377
  # The original code returns a tuple here:
378
378
  # return ("ordinal", data.cat.categories.tolist()) # noqa: ERA001
379
379
  # But returning the tuple here isn't compatible with our
@@ -381,9 +381,9 @@ def _infer_vegalite_type(
381
381
  # Altair already extracts the correct sort order somewhere else.
382
382
  # More info about the issue here: https://github.com/streamlit/streamlit/issues/7776
383
383
  return "ordinal"
384
- elif typ in ["string", "bytes", "categorical", "boolean", "mixed", "unicode"]:
384
+ if typ in ["string", "bytes", "categorical", "boolean", "mixed", "unicode"]:
385
385
  return "nominal"
386
- elif typ in [
386
+ if typ in [
387
387
  "datetime",
388
388
  "datetime64",
389
389
  "timedelta",
@@ -393,14 +393,13 @@ def _infer_vegalite_type(
393
393
  "period",
394
394
  ]:
395
395
  return "temporal"
396
- else:
397
- # STREAMLIT MOD: I commented this out since Streamlit doesn't use warnings.warn.
398
- # > warnings.warn(
399
- # > "I don't know how to infer vegalite type from '{}'. "
400
- # > "Defaulting to nominal.".format(typ),
401
- # > stacklevel=1,
402
- # > )
403
- return "nominal"
396
+ # STREAMLIT MOD: I commented this out since Streamlit doesn't use warnings.warn.
397
+ # > warnings.warn(
398
+ # > "I don't know how to infer vegalite type from '{}'. "
399
+ # > "Defaulting to nominal.".format(typ),
400
+ # > stacklevel=1,
401
+ # > )
402
+ return "nominal"
404
403
 
405
404
 
406
405
  def _get_pandas_index_attr(
@@ -610,7 +609,9 @@ def _drop_unused_columns(df: pd.DataFrame, *column_names: str | None) -> pd.Data
610
609
  return df[keep]
611
610
 
612
611
 
613
- def _maybe_convert_color_column_in_place(df: pd.DataFrame, color_column: str | None):
612
+ def _maybe_convert_color_column_in_place(
613
+ df: pd.DataFrame, color_column: str | None
614
+ ) -> None:
614
615
  """If needed, convert color column to a format Vega understands."""
615
616
  if color_column is None or len(df[color_column]) == 0:
616
617
  return
@@ -669,18 +670,17 @@ def _parse_x_column(df: pd.DataFrame, x_from_user: str | None) -> str | None:
669
670
  if x_from_user is None:
670
671
  return None
671
672
 
672
- elif isinstance(x_from_user, str):
673
+ if isinstance(x_from_user, str):
673
674
  if x_from_user not in df.columns:
674
675
  raise StreamlitColumnNotFoundError(df, x_from_user)
675
676
 
676
677
  return x_from_user
677
678
 
678
- else:
679
- raise StreamlitAPIException(
680
- "x parameter should be a column name (str) or None to use the "
681
- f" dataframe's index. Value given: {x_from_user} "
682
- f"(type {type(x_from_user)})"
683
- )
679
+ raise StreamlitAPIException(
680
+ "x parameter should be a column name (str) or None to use the "
681
+ f" dataframe's index. Value given: {x_from_user} "
682
+ f"(type {type(x_from_user)})"
683
+ )
684
684
 
685
685
 
686
686
  def _parse_y_columns(
@@ -935,9 +935,9 @@ def _update_encoding_with_stack(
935
935
  encoding: alt.X | alt.Y,
936
936
  ) -> None:
937
937
  if stack is None:
938
- return None
938
+ return
939
939
  # Our layered option maps to vega's stack=False option
940
- elif stack == "layered":
940
+ if stack == "layered":
941
941
  stack = False
942
942
 
943
943
  encoding["stack"] = stack
@@ -964,8 +964,8 @@ def _get_color_encoding(
964
964
 
965
965
  return alt.ColorValue(to_css_color(cast("Any", color_value)))
966
966
 
967
- # If the color value is a list of colors of approriate length, return that.
968
- elif isinstance(color_value, (list, tuple)):
967
+ # If the color value is a list of colors of appropriate length, return that.
968
+ if isinstance(color_value, (list, tuple)):
969
969
  color_values = cast("Collection[Color]", color_value)
970
970
 
971
971
  if len(color_values) != len(y_column_list):
@@ -973,18 +973,17 @@ def _get_color_encoding(
973
973
 
974
974
  if len(color_values) == 1:
975
975
  return alt.ColorValue(to_css_color(cast("Any", color_value[0])))
976
- else:
977
- return alt.Color(
978
- field=color_column if color_column is not None else alt.Undefined,
979
- scale=alt.Scale(range=[to_css_color(c) for c in color_values]),
980
- legend=_COLOR_LEGEND_SETTINGS,
981
- type="nominal",
982
- title=" ",
983
- )
976
+ return alt.Color(
977
+ field=color_column if color_column is not None else alt.Undefined,
978
+ scale=alt.Scale(range=[to_css_color(c) for c in color_values]),
979
+ legend=_COLOR_LEGEND_SETTINGS,
980
+ type="nominal",
981
+ title=" ",
982
+ )
984
983
 
985
984
  raise StreamlitInvalidColorError(df, color_from_user)
986
985
 
987
- elif color_column is not None:
986
+ if color_column is not None:
988
987
  column_type: VegaLiteType
989
988
 
990
989
  if color_column == _MELTED_COLOR_COLUMN_NAME:
@@ -1037,16 +1036,15 @@ def _get_size_encoding(
1037
1036
  legend=_SIZE_LEGEND_SETTINGS,
1038
1037
  )
1039
1038
 
1040
- elif isinstance(size_value, (float, int)):
1039
+ if isinstance(size_value, (float, int)):
1041
1040
  return alt.SizeValue(size_value)
1042
- elif size_value is None:
1041
+ if size_value is None:
1043
1042
  return alt.SizeValue(100)
1044
- else:
1045
- raise StreamlitAPIException(
1046
- f"This does not look like a valid size: {size_value!r}"
1047
- )
1043
+ raise StreamlitAPIException(
1044
+ f"This does not look like a valid size: {size_value!r}"
1045
+ )
1048
1046
 
1049
- elif size_column is not None or size_value is not None:
1047
+ if size_column is not None or size_value is not None:
1050
1048
  raise Error(
1051
1049
  f"Chart type {chart_type.name} does not support size argument. "
1052
1050
  "This should never happen!"
@@ -83,7 +83,7 @@ def to_css_color(color: MaybeColor) -> Color:
83
83
  ctuple = _normalize_tuple(ctuple, _int_formatter, _float_formatter)
84
84
  if len(ctuple) == 3:
85
85
  return f"rgb({ctuple[0]}, {ctuple[1]}, {ctuple[2]})"
86
- elif len(ctuple) == 4:
86
+ if len(ctuple) == 4:
87
87
  c4tuple = cast("MixedRGBAColorTuple", ctuple)
88
88
  return f"rgba({c4tuple[0]}, {c4tuple[1]}, {c4tuple[2]}, {c4tuple[3]})"
89
89
 
@@ -155,7 +155,7 @@ def _to_color_tuple(
155
155
  color: MaybeColor,
156
156
  rgb_formatter: Callable[[float, MaybeColor], float],
157
157
  alpha_formatter: Callable[[float, MaybeColor], float],
158
- ):
158
+ ) -> ColorTuple:
159
159
  """Convert a potential color to a color tuple.
160
160
 
161
161
  The exact type of color tuple this outputs is dictated by the formatter parameters.
@@ -224,7 +224,7 @@ def _normalize_tuple(
224
224
  b = rgb_formatter(color[2], color)
225
225
  return r, g, b
226
226
 
227
- elif len(color) == 4:
227
+ if len(color) == 4:
228
228
  color_4tuple = cast("Color4Tuple", color)
229
229
  r = rgb_formatter(color_4tuple[0], color_4tuple)
230
230
  g = rgb_formatter(color_4tuple[1], color_4tuple)
@@ -432,7 +432,7 @@ def NumberColumn(
432
432
  - ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
433
433
  - printf-style format string: Format the number with a printf
434
434
  specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
435
- ``"%X"`` to show an unsigned hexidecimal integer (e.g. "4D2"). You
435
+ ``"%X"`` to show an unsigned hexadecimal integer (e.g. "4D2"). You
436
436
  can also add prefixes and suffixes. To show British pounds, use
437
437
  ``"£ %.2f"`` (e.g. "£ 1234.57"). For more information, see `sprint-js
438
438
  <https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
@@ -1313,7 +1313,7 @@ def ImageColumn(
1313
1313
  width: ColumnWidth | None = None,
1314
1314
  help: str | None = None,
1315
1315
  pinned: bool | None = None,
1316
- ):
1316
+ ) -> ColumnConfig:
1317
1317
  """Configure an image column in ``st.dataframe`` or ``st.data_editor``.
1318
1318
 
1319
1319
  The cell values need to be one of:
@@ -1403,7 +1403,7 @@ def ListColumn(
1403
1403
  width: ColumnWidth | None = None,
1404
1404
  help: str | None = None,
1405
1405
  pinned: bool | None = None,
1406
- ):
1406
+ ) -> ColumnConfig:
1407
1407
  """Configure a list column in ``st.dataframe`` or ``st.data_editor``.
1408
1408
 
1409
1409
  This is the default column type for list-like values. List columns are not editable
@@ -2007,7 +2007,7 @@ def ProgressColumn(
2007
2007
  - ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
2008
2008
  - printf-style format string: Format the number with a printf
2009
2009
  specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
2010
- ``"%X"`` to show an unsigned hexidecimal integer (e.g. "4D2"). You
2010
+ ``"%X"`` to show an unsigned hexadecimal integer (e.g. "4D2"). You
2011
2011
  can also add prefixes and suffixes. To show British pounds, use
2012
2012
  ``"£ %.2f"`` (e.g. "£ 1234.57"). For more information, see `sprint-js
2013
2013
  <https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
@@ -105,14 +105,14 @@ class Dialog(DeltaGenerator):
105
105
  cursor: Cursor | None,
106
106
  parent: DeltaGenerator | None,
107
107
  block_type: str | None,
108
- ):
108
+ ) -> None:
109
109
  super().__init__(root_container, cursor, parent, block_type)
110
110
 
111
111
  # Initialized in `_create()`:
112
112
  self._current_proto: BlockProto | None = None
113
113
  self._delta_path: list[int] | None = None
114
114
 
115
- def _update(self, should_open: bool):
115
+ def _update(self, should_open: bool) -> None:
116
116
  """Send an updated proto message to indicate the open-status for the dialog."""
117
117
 
118
118
  assert self._current_proto is not None, "Dialog not correctly initialized!"
@@ -26,7 +26,7 @@ class AttributeDictionary(dict[Any, Any]):
26
26
  attribute-style access.
27
27
  """
28
28
 
29
- def __getattr__(self, key):
29
+ def __getattr__(self, key: str) -> Any:
30
30
  try:
31
31
  item = self.__getitem__(key)
32
32
  return AttributeDictionary(item) if isinstance(item, dict) else item
@@ -360,7 +360,7 @@ def marshall_images(
360
360
  Parameters
361
361
  ----------
362
362
  coordinates
363
- A string indentifying the images' location in the frontend.
363
+ A string identifying the images' location in the frontend.
364
364
  image
365
365
  The image or images to include in the ImageListProto.
366
366
  caption
@@ -88,7 +88,7 @@ class StatusContainer(DeltaGenerator):
88
88
  cursor: Cursor | None,
89
89
  parent: DeltaGenerator | None,
90
90
  block_type: str | None,
91
- ):
91
+ ) -> None:
92
92
  super().__init__(root_container, cursor, parent, block_type)
93
93
 
94
94
  # Initialized in `_create()`:
@@ -105,7 +105,7 @@ _ALLOWED_ENUM_COERCION_CONFIG_SETTINGS = ("off", "nameOnly", "nameAndValue")
105
105
  def _coerce_enum(from_enum_value: E1, to_enum_class: type[E2]) -> E1 | E2:
106
106
  """Attempt to coerce an Enum value to another EnumMeta.
107
107
 
108
- An Enum value of EnumMeta E1 is considered coercable to EnumType E2
108
+ An Enum value of EnumMeta E1 is considered coercible to EnumType E2
109
109
  if the EnumMeta __qualname__ match and the names of their members
110
110
  match as well. (This is configurable in streamlist configs)
111
111
  """
@@ -149,7 +149,7 @@ def _coerce_enum(from_enum_value: E1, to_enum_class: type[E2]) -> E1 | E2:
149
149
  _LOGGER.debug("Failed to coerce %s to class %s", from_enum_value, to_enum_class)
150
150
  return from_enum_value # do not attempt to coerce
151
151
 
152
- # At this point we think the Enum is coercable, and we know
152
+ # At this point we think the Enum is coercible, and we know
153
153
  # E1 and E2 have the same member names. We convert from E1 to E2 using _name_
154
154
  # (since user Enum subclasses can override the .name property in 3.11)
155
155
  _LOGGER.debug("Coerced %s to class %s", from_enum_value, to_enum_class)
@@ -126,7 +126,7 @@ def check_cache_replay_rules() -> None:
126
126
  exception(CachedWidgetWarning())
127
127
 
128
128
 
129
- def check_fragment_path_policy(dg: DeltaGenerator):
129
+ def check_fragment_path_policy(dg: DeltaGenerator) -> None:
130
130
  """Ensures that the current widget is not written outside of the
131
131
  fragment's delta path.
132
132
 
@@ -168,7 +168,7 @@ def check_widget_policies(
168
168
  default_value: Sequence[Any] | Any | None = None,
169
169
  writes_allowed: bool = True,
170
170
  enable_check_callback_rules: bool = True,
171
- ):
171
+ ) -> None:
172
172
  """Check all widget policies for the given DeltaGenerator."""
173
173
  check_fragment_path_policy(dg)
174
174
  check_cache_replay_rules()
@@ -179,7 +179,7 @@ def check_widget_policies(
179
179
  )
180
180
 
181
181
 
182
- def maybe_raise_label_warnings(label: str | None, label_visibility: str | None):
182
+ def maybe_raise_label_warnings(label: str | None, label_visibility: str | None) -> None:
183
183
  if not label:
184
184
  _LOGGER.warning(
185
185
  "`label` got an empty value. This is discouraged for accessibility "
@@ -70,9 +70,9 @@ def get_label_visibility_proto_value(
70
70
 
71
71
  if label_visibility_string == "visible":
72
72
  return LabelVisibilityMessage.LabelVisibilityOptions.VISIBLE
73
- elif label_visibility_string == "hidden":
73
+ if label_visibility_string == "hidden":
74
74
  return LabelVisibilityMessage.LabelVisibilityOptions.HIDDEN
75
- elif label_visibility_string == "collapsed":
75
+ if label_visibility_string == "collapsed":
76
76
  return LabelVisibilityMessage.LabelVisibilityOptions.COLLAPSED
77
77
 
78
78
  raise ValueError(f"Unknown label visibility value: {label_visibility_string}")
@@ -85,9 +85,9 @@ def get_chat_input_accept_file_proto_value(
85
85
 
86
86
  if accept_file_value is False:
87
87
  return ChatInput.AcceptFile.NONE
88
- elif accept_file_value is True:
88
+ if accept_file_value is True:
89
89
  return ChatInput.AcceptFile.SINGLE
90
- elif accept_file_value == "multiple":
90
+ if accept_file_value == "multiple":
91
91
  return ChatInput.AcceptFile.MULTIPLE
92
92
 
93
93
  raise ValueError(f"Unknown accept file value: {accept_file_value}")
@@ -240,7 +240,7 @@ def compute_and_register_element_id(
240
240
  return element_id
241
241
 
242
242
 
243
- def save_for_app_testing(ctx: ScriptRunContext, k: str, v: Any):
243
+ def save_for_app_testing(ctx: ScriptRunContext, k: str, v: Any) -> None:
244
244
  if config.get_option("global.appTest"):
245
245
  try:
246
246
  ctx.session_state[TESTING_KEY][k] = v
@@ -114,7 +114,7 @@ class MetricMixin:
114
114
  label_visibility : "visible", "hidden", or "collapsed"
115
115
  The visibility of the label. The default is ``"visible"``. If this
116
116
  is ``"hidden"``, Streamlit displays an empty spacer instead of the
117
- label, which can help keep the widget alligned with other widgets.
117
+ label, which can help keep the widget aligned with other widgets.
118
118
  If this is ``"collapsed"``, Streamlit displays no label or spacer.
119
119
 
120
120
  border : bool
@@ -61,26 +61,23 @@ def _check_float_between(value: float, low: float = 0.0, high: float = 1.0) -> b
61
61
  )
62
62
 
63
63
 
64
- def _get_value(value):
64
+ def _get_value(value: FloatOrInt) -> int:
65
65
  if isinstance(value, int):
66
66
  if 0 <= value <= 100:
67
67
  return value
68
- else:
69
- raise StreamlitAPIException(
70
- "Progress Value has invalid value [0, 100]: %d" % value
71
- )
68
+ raise StreamlitAPIException(
69
+ "Progress Value has invalid value [0, 100]: %d" % value
70
+ )
72
71
 
73
- elif isinstance(value, float):
72
+ if isinstance(value, float):
74
73
  if _check_float_between(value, low=0.0, high=1.0):
75
74
  return int(value * 100)
76
- else:
77
- raise StreamlitAPIException(
78
- "Progress Value has invalid value [0.0, 1.0]: %f" % value
79
- )
80
- else:
81
75
  raise StreamlitAPIException(
82
- "Progress Value has invalid type: %s" % type(value).__name__
76
+ "Progress Value has invalid value [0.0, 1.0]: %f" % value
83
77
  )
78
+ raise StreamlitAPIException(
79
+ "Progress Value has invalid type: %s" % type(value).__name__
80
+ )
84
81
 
85
82
 
86
83
  def _get_text(text: str | None) -> str | None:
@@ -253,7 +253,7 @@ class VegaLiteStateSerde:
253
253
  def _prepare_vega_lite_spec(
254
254
  spec: VegaLiteSpec,
255
255
  use_container_width: bool,
256
- **kwargs,
256
+ **kwargs: Any,
257
257
  ) -> VegaLiteSpec:
258
258
  if kwargs:
259
259
  # Support passing in kwargs.
@@ -345,7 +345,7 @@ def _convert_altair_to_vega_lite_spec(
345
345
 
346
346
  datasets = {}
347
347
 
348
- def id_transform(data) -> dict[str, str]:
348
+ def id_transform(data: Any) -> dict[str, str]:
349
349
  """Altair data transformer that serializes the data,
350
350
  creates a stable name based on the hash of the data,
351
351
  stores the bytes into the datasets mapping and
@@ -1567,7 +1567,7 @@ class VegaChartsMixin:
1567
1567
  as a dictionary.
1568
1568
 
1569
1569
  To use selection events, the object passed to ``altair_chart`` must
1570
- include selection paramters. To learn about defining interactions
1570
+ include selection parameters. To learn about defining interactions
1571
1571
  in Altair and how to declare selection-type parameters, see
1572
1572
  `Interactive Charts \
1573
1573
  <https://altair-viz.github.io/user_guide/interactions.html>`_
@@ -160,7 +160,7 @@ class AudioInputMixin:
160
160
  label_visibility : "visible", "hidden", or "collapsed"
161
161
  The visibility of the label. The default is ``"visible"``. If this
162
162
  is ``"hidden"``, Streamlit displays an empty spacer instead of the
163
- label, which can help keep the widget alligned with other widgets.
163
+ label, which can help keep the widget aligned with other widgets.
164
164
  If this is ``"collapsed"``, Streamlit displays no label or spacer.
165
165
 
166
166
  width : "stretch" or int