streamlit 1.47.1__py3-none-any.whl → 1.48.0__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 (189) hide show
  1. streamlit/cli_util.py +1 -1
  2. streamlit/commands/echo.py +2 -2
  3. streamlit/commands/execution_control.py +1 -1
  4. streamlit/commands/page_config.py +16 -16
  5. streamlit/components/v1/component_arrow.py +4 -4
  6. streamlit/config.py +23 -5
  7. streamlit/connections/base_connection.py +2 -2
  8. streamlit/connections/snowflake_connection.py +2 -2
  9. streamlit/connections/sql_connection.py +4 -3
  10. streamlit/dataframe_util.py +1 -1
  11. streamlit/deprecation_util.py +20 -5
  12. streamlit/elements/arrow.py +105 -79
  13. streamlit/elements/deck_gl_json_chart.py +6 -6
  14. streamlit/elements/dialog_decorator.py +72 -17
  15. streamlit/elements/form.py +36 -7
  16. streamlit/elements/graphviz_chart.py +7 -0
  17. streamlit/elements/json.py +3 -3
  18. streamlit/elements/layouts.py +241 -75
  19. streamlit/elements/lib/built_in_chart_utils.py +11 -3
  20. streamlit/elements/lib/dialog.py +43 -0
  21. streamlit/elements/lib/file_uploader_utils.py +21 -2
  22. streamlit/elements/lib/layout_utils.py +88 -2
  23. streamlit/elements/lib/options_selector_utils.py +1 -1
  24. streamlit/elements/lib/utils.py +23 -3
  25. streamlit/elements/map.py +12 -11
  26. streamlit/elements/plotly_chart.py +21 -21
  27. streamlit/elements/pyplot.py +8 -4
  28. streamlit/elements/vega_charts.py +237 -143
  29. streamlit/elements/widgets/audio_input.py +2 -2
  30. streamlit/elements/widgets/button.py +147 -35
  31. streamlit/elements/widgets/button_group.py +9 -8
  32. streamlit/elements/widgets/camera_input.py +2 -2
  33. streamlit/elements/widgets/chat.py +8 -2
  34. streamlit/elements/widgets/checkbox.py +4 -4
  35. streamlit/elements/widgets/color_picker.py +2 -2
  36. streamlit/elements/widgets/data_editor.py +22 -15
  37. streamlit/elements/widgets/file_uploader.py +8 -2
  38. streamlit/elements/widgets/multiselect.py +27 -17
  39. streamlit/elements/widgets/number_input.py +2 -2
  40. streamlit/elements/widgets/radio.py +5 -4
  41. streamlit/elements/widgets/select_slider.py +8 -5
  42. streamlit/elements/widgets/selectbox.py +14 -4
  43. streamlit/elements/widgets/slider.py +59 -33
  44. streamlit/elements/widgets/text_widgets.py +4 -4
  45. streamlit/elements/widgets/time_widgets.py +4 -4
  46. streamlit/elements/write.py +9 -8
  47. streamlit/env_util.py +1 -1
  48. streamlit/errors.py +20 -4
  49. streamlit/file_util.py +1 -1
  50. streamlit/git_util.py +1 -1
  51. streamlit/logger.py +2 -2
  52. streamlit/proto/Block_pb2.py +39 -31
  53. streamlit/proto/Block_pb2.pyi +54 -3
  54. streamlit/proto/Button_pb2.py +4 -2
  55. streamlit/proto/Button_pb2.pyi +1 -0
  56. streamlit/runtime/caching/cache_data_api.py +15 -2
  57. streamlit/runtime/caching/cache_errors.py +1 -1
  58. streamlit/runtime/caching/cache_resource_api.py +24 -2
  59. streamlit/runtime/caching/cache_utils.py +6 -3
  60. streamlit/runtime/caching/hashing.py +6 -9
  61. streamlit/runtime/fragment.py +3 -2
  62. streamlit/runtime/runtime.py +19 -2
  63. streamlit/runtime/scriptrunner/script_runner.py +3 -3
  64. streamlit/runtime/state/common.py +2 -1
  65. streamlit/runtime/state/query_params.py +2 -1
  66. streamlit/runtime/state/session_state.py +1 -1
  67. streamlit/static/index.html +1 -1
  68. streamlit/static/manifest.json +231 -231
  69. streamlit/static/static/css/index.CQt5TjGB.css +1 -0
  70. streamlit/static/static/js/{ErrorOutline.esm.BEZPMjuG.js → ErrorOutline.esm.D_4oFNKB.js} +1 -1
  71. streamlit/static/static/js/{FileDownload.esm.Dy1V9a2E.js → FileDownload.esm.NPgaLlUE.js} +1 -1
  72. streamlit/static/static/js/{FileHelper.D0K06YBq.js → FileHelper.B2t9ikoS.js} +1 -1
  73. streamlit/static/static/js/{FormClearHelper.Cdw5Y7_m.js → FormClearHelper.BLEIUk6L.js} +1 -1
  74. streamlit/static/static/js/{Hooks.C_qx1sSw.js → Hooks.BGm9sd4U.js} +1 -1
  75. streamlit/static/static/js/{InputInstructions.D3IDU-eY.js → InputInstructions.DtUxCBS8.js} +1 -1
  76. streamlit/static/static/js/Particles.BDRPO7r3.js +1 -0
  77. streamlit/static/static/js/ProgressBar.B64DUUqp.js +2 -0
  78. streamlit/static/static/js/Toolbar.B3FquPk5.js +1 -0
  79. streamlit/static/static/js/{base-input.DMlw5p7n.js → base-input.DeBqm5mN.js} +4 -4
  80. streamlit/static/static/js/{checkbox.C7QR6llE.js → checkbox.C0odQfKb.js} +2 -2
  81. streamlit/static/static/js/createDownloadLinkElement.ZaXNnPK4.js +1 -0
  82. streamlit/static/static/js/{createSuper.C5k_2vfB.js → createSuper.DqQ5L3XG.js} +1 -1
  83. streamlit/static/static/js/data-grid-overlay-editor.DbNsQa8Y.js +1 -0
  84. streamlit/static/static/js/{downloader.Nj6v3ioB.js → downloader.Bx1D0jhz.js} +1 -1
  85. streamlit/static/static/js/{es6.CVz13CSz.js → es6.CbPK4m0H.js} +2 -2
  86. streamlit/static/static/js/{iframeResizer.contentWindow.gZ8zjT0K.js → iframeResizer.contentWindow.CfLKrptA.js} +1 -1
  87. streamlit/static/static/js/{index.D3wOJJsg.js → index.0XDwe9RV.js} +12 -12
  88. streamlit/static/static/js/{index.BscWuWHL.js → index.4lI9TuZm.js} +3 -3
  89. streamlit/static/static/js/index.6s0nVIis.js +3855 -0
  90. streamlit/static/static/js/index.9E7bRUBU.js +1 -0
  91. streamlit/static/static/js/index.B9PgeLrZ.js +1 -0
  92. streamlit/static/static/js/index.B9vzGbOt.js +1 -0
  93. streamlit/static/static/js/index.BDrQKMCm.js +1 -0
  94. streamlit/static/static/js/index.BPsoiGgP.js +1 -0
  95. streamlit/static/static/js/index.CJzdLAun.js +1 -0
  96. streamlit/static/static/js/index.CNNlC1NL.js +1 -0
  97. streamlit/static/static/js/index.CO1sClzJ.js +2 -0
  98. streamlit/static/static/js/index.CZnagxXD.js +1 -0
  99. streamlit/static/static/js/{index.MbqsiUV4.js → index.Cb0xSF7V.js} +289 -289
  100. streamlit/static/static/js/index.CgUt3tz_.js +1 -0
  101. streamlit/static/static/js/index.CjImmcsV.js +1 -0
  102. streamlit/static/static/js/index.ClRTsv8m.js +2 -0
  103. streamlit/static/static/js/{index.CTT2YqEU.js → index.CnfWsQzS.js} +1 -1
  104. streamlit/static/static/js/index.CrJ1XD_V.js +1 -0
  105. streamlit/static/static/js/index.CtiKsjSC.js +1 -0
  106. streamlit/static/static/js/index.CwAuytgV.js +1 -0
  107. streamlit/static/static/js/index.D7GB-kly.js +1 -0
  108. streamlit/static/static/js/index.DA5wU0mQ.js +1 -0
  109. streamlit/static/static/js/{index.xfcNJBLM.js → index.DCpyIFTV.js} +1 -1
  110. streamlit/static/static/js/index.DE9wNOje.js +1 -0
  111. streamlit/static/static/js/{index.mihWZKb1.js → index.DHnB-C8A.js} +1 -1
  112. streamlit/static/static/js/{index.BSFzxMXi.js → index.DRTn9zvD.js} +1 -1
  113. streamlit/static/static/js/index.DjMjyJl9.js +7 -0
  114. streamlit/static/static/js/{index.CbQtRkVt.js → index.DvRPFfw6.js} +162 -188
  115. streamlit/static/static/js/{index.B2L574n6.js → index.DwaoC4Zp.js} +3 -3
  116. streamlit/static/static/js/index.F9tSej94.js +1 -0
  117. streamlit/static/static/js/index.HeVbRh9H.js +73 -0
  118. streamlit/static/static/js/index.J2D_m7LY.js +197 -0
  119. streamlit/static/static/js/index.PyIqRRSR.js +1 -0
  120. streamlit/static/static/js/index.dfivzJNz.js +1 -0
  121. streamlit/static/static/js/index.mRztGO69.js +3 -0
  122. streamlit/static/static/js/index.tB1kn_7z.js +1 -0
  123. streamlit/static/static/js/index.wDYef4mQ.js +12 -0
  124. streamlit/static/static/js/{input.D_45B0P-.js → input.BL2buuce.js} +2 -2
  125. streamlit/static/static/js/{memory.BmhrRyO2.js → memory.CUxjUWS7.js} +1 -1
  126. streamlit/static/static/js/{mergeWith.DvOME7eH.js → mergeWith.C1kp1zIi.js} +1 -1
  127. streamlit/static/static/js/{number-overlay-editor.BRNxOzEZ.js → number-overlay-editor.WpheGpmR.js} +1 -1
  128. streamlit/static/static/js/{possibleConstructorReturn.C5GiK_Ob.js → possibleConstructorReturn.DbvQboK3.js} +1 -1
  129. streamlit/static/static/js/{sandbox.B-Q9S7vW.js → sandbox.6lnFVWhX.js} +1 -1
  130. streamlit/static/static/js/{timepicker.DOMbfm_a.js → timepicker.Bg4xAK95.js} +1 -1
  131. streamlit/static/static/js/{toConsumableArray.CbNz0Ciu.js → toConsumableArray.D9x7Ktv4.js} +1 -1
  132. streamlit/static/static/js/{uniqueId.-ygIU7IL.js → uniqueId.Bm8FHN92.js} +1 -1
  133. streamlit/static/static/js/{useBasicWidgetState.Bx3VaRHk.js → useBasicWidgetState.CUSYQZpm.js} +1 -1
  134. streamlit/static/static/js/{useTextInputAutoExpand.BuE9l5TG.js → useTextInputAutoExpand.Bf2egQOG.js} +2 -2
  135. streamlit/static/static/js/useUpdateUiValue.lE5xnYWF.js +1 -0
  136. streamlit/static/static/js/withFullScreenWrapper.CCOXR7N6.js +1 -0
  137. streamlit/temporary_directory.py +5 -3
  138. streamlit/testing/v1/app_test.py +4 -1
  139. streamlit/testing/v1/element_tree.py +4 -5
  140. streamlit/type_util.py +10 -3
  141. streamlit/user_info.py +18 -14
  142. streamlit/util.py +11 -1
  143. streamlit/watcher/local_sources_watcher.py +4 -3
  144. streamlit/web/bootstrap.py +18 -12
  145. streamlit/web/cli.py +2 -1
  146. streamlit/web/server/oauth_authlib_routes.py +59 -3
  147. streamlit/web/server/server.py +72 -21
  148. {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/METADATA +14 -2
  149. {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/RECORD +153 -153
  150. streamlit/static/static/css/index.CsLB_Bnz.css +0 -1
  151. streamlit/static/static/js/ProgressBar.EhJ_lCOf.js +0 -2
  152. streamlit/static/static/js/RenderInPortalIfExists.D6a0mMll.js +0 -1
  153. streamlit/static/static/js/Toolbar.D6yqQ65-.js +0 -1
  154. streamlit/static/static/js/createDownloadLinkElement.DZMwyjvU.js +0 -1
  155. streamlit/static/static/js/data-grid-overlay-editor.CoquyZNK.js +0 -1
  156. streamlit/static/static/js/index.B3n-pURl.js +0 -2
  157. streamlit/static/static/js/index.B9jJp9aE.js +0 -1
  158. streamlit/static/static/js/index.BBVtld-D.js +0 -1
  159. streamlit/static/static/js/index.BKHPnvYd.js +0 -1
  160. streamlit/static/static/js/index.B_1CXynz.js +0 -1
  161. streamlit/static/static/js/index.Bm1LklYO.js +0 -1
  162. streamlit/static/static/js/index.Byi6__iF.js +0 -1
  163. streamlit/static/static/js/index.BzJeMpQ-.js +0 -197
  164. streamlit/static/static/js/index.C4tw7-Cl.js +0 -2
  165. streamlit/static/static/js/index.CG0C49ex.js +0 -1
  166. streamlit/static/static/js/index.CMuSJPv-.js +0 -1
  167. streamlit/static/static/js/index.COPFcr_K.js +0 -3855
  168. streamlit/static/static/js/index.CU3TLDlu.js +0 -1
  169. streamlit/static/static/js/index.CVKKDwaf.js +0 -1
  170. streamlit/static/static/js/index.CWZeK3mV.js +0 -12
  171. streamlit/static/static/js/index.CWbiNJQl.js +0 -1
  172. streamlit/static/static/js/index.CWxefYP6.js +0 -73
  173. streamlit/static/static/js/index.DOdWa88b.js +0 -1
  174. streamlit/static/static/js/index.DXtnaPua.js +0 -1
  175. streamlit/static/static/js/index.DatDwFl3.js +0 -3
  176. streamlit/static/static/js/index.DeWYPvQR.js +0 -1
  177. streamlit/static/static/js/index.Do4vzIvK.js +0 -1
  178. streamlit/static/static/js/index.Dvrstlh8.js +0 -1
  179. streamlit/static/static/js/index.DvznfdF_.js +0 -1
  180. streamlit/static/static/js/index.U1vvXeGn.js +0 -1
  181. streamlit/static/static/js/index._WAuWRkp.js +0 -7
  182. streamlit/static/static/js/index.bwA9_eWC.js +0 -1
  183. streamlit/static/static/js/index.m1njXuKl.js +0 -1
  184. streamlit/static/static/js/useOnInputChange.CDZx-L6q.js +0 -1
  185. streamlit/static/static/js/withFullScreenWrapper.DWXejOhQ.js +0 -1
  186. {streamlit-1.47.1.data → streamlit-1.48.0.data}/scripts/streamlit.cmd +0 -0
  187. {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/WHEEL +0 -0
  188. {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/entry_points.txt +0 -0
  189. {streamlit-1.47.1.dist-info → streamlit-1.48.0.dist-info}/top_level.txt +0 -0
streamlit/cli_util.py CHANGED
@@ -103,4 +103,4 @@ def open_browser(url: str) -> None:
103
103
 
104
104
  import platform
105
105
 
106
- raise errors.Error(f'Cannot open browser in platform "{platform.system()}"')
106
+ raise errors.Error(f'Cannot open browser in platform "{platform.system()}"') # ty: ignore[unresolved-attribute]
@@ -19,7 +19,7 @@ import contextlib
19
19
  import re
20
20
  import textwrap
21
21
  import traceback
22
- from typing import TYPE_CHECKING, Any, Literal
22
+ from typing import TYPE_CHECKING, Any, Literal, cast
23
23
 
24
24
  from streamlit.runtime.metrics_util import gather_metrics
25
25
 
@@ -81,7 +81,7 @@ def echo(
81
81
  for child in ast.iter_child_nodes(node):
82
82
  # If child doesn't have "lineno", it is not something we could display
83
83
  if hasattr(child, "lineno"):
84
- line_to_node_map[child.lineno] = child
84
+ line_to_node_map[cast("int", child.lineno)] = child
85
85
  collect_body_statements(child)
86
86
 
87
87
  collect_body_statements(root_node)
@@ -103,7 +103,7 @@ def _new_fragment_id_queue(
103
103
  def rerun( # type: ignore[misc]
104
104
  *, # The scope argument can only be passed via keyword.
105
105
  scope: Literal["app", "fragment"] = "app",
106
- ) -> NoReturn:
106
+ ) -> NoReturn: # ty: ignore[invalid-return-type]
107
107
  """Rerun the script immediately.
108
108
 
109
109
  When ``st.rerun()`` is called, Streamlit halts the current script run and
@@ -194,21 +194,19 @@ def set_page_config(
194
194
 
195
195
  menu_items: dict
196
196
  Configure the menu that appears on the top-right side of this app.
197
- The keys in this dict denote the menu item you'd like to configure:
198
-
199
- - "Get help": str or None
200
- The URL this menu item should point to.
201
- If None, hides this menu item.
202
- - "Report a Bug": str or None
203
- The URL this menu item should point to.
204
- If None, hides this menu item.
205
- - "About": str or None
206
- A markdown string to show in the About dialog.
207
- If None, only shows Streamlit's default About text.
208
-
209
- The URL may also refer to an email address e.g. ``mailto:john@example.com``.
210
- To remove an item that was specified in a previous call to
211
- ``st.set_page_config``, set its value to ``None`` in the dictionary.
197
+ The keys in this dict denote the menu item to configure. The following
198
+ keys can have string or ``None`` values:
199
+
200
+ - "Get help": The URL this menu item should point to.
201
+ - "Report a Bug": The URL this menu item should point to.
202
+ - "About": A markdown string to show in the About dialog.
203
+
204
+ A URL may also refer to an email address e.g. ``mailto:john@example.com``.
205
+
206
+ If you do not include a key, its menu item will be hidden (unless it
207
+ was set by a previous call to ``st.set_page_config``). To remove an
208
+ item that was specified in a previous call to ``st.set_page_config``,
209
+ set its value to ``None`` in the dictionary.
212
210
 
213
211
  Example
214
212
  -------
@@ -301,7 +299,9 @@ def set_menu_items_proto(
301
299
 
302
300
  if ABOUT_KEY in lowercase_menu_items:
303
301
  if lowercase_menu_items[ABOUT_KEY] is not None:
304
- menu_items_proto.about_section_md = dedent(lowercase_menu_items[ABOUT_KEY])
302
+ menu_items_proto.about_section_md = dedent(
303
+ lowercase_menu_items[ABOUT_KEY] or ""
304
+ )
305
305
  else:
306
306
  # For multiple calls to set_page_config, clears previously set about markdown
307
307
  menu_items_proto.clear_about_md = True
@@ -72,8 +72,8 @@ def _marshall_index(proto: ArrowTableProto, index: Index) -> None:
72
72
  """
73
73
  import pandas as pd
74
74
 
75
- index = map(_maybe_tuple_to_list, index.values)
76
- index_df = pd.DataFrame(index)
75
+ index_values = map(_maybe_tuple_to_list, index.values)
76
+ index_df = pd.DataFrame(index_values)
77
77
  proto.index = dataframe_util.convert_pandas_df_to_arrow_bytes(index_df)
78
78
 
79
79
 
@@ -92,8 +92,8 @@ def _marshall_columns(proto: ArrowTableProto, columns: Series) -> None:
92
92
  """
93
93
  import pandas as pd
94
94
 
95
- columns = map(_maybe_tuple_to_list, columns.values)
96
- columns_df = pd.DataFrame(columns)
95
+ values = map(_maybe_tuple_to_list, columns.values)
96
+ columns_df = pd.DataFrame(values)
97
97
  proto.columns = dataframe_util.convert_pandas_df_to_arrow_bytes(columns_df)
98
98
 
99
99
 
streamlit/config.py CHANGED
@@ -36,8 +36,8 @@ from streamlit.errors import StreamlitAPIException
36
36
  # Descriptions of each of the possible config sections.
37
37
  # (We use OrderedDict to make the order in which sections are declared in this
38
38
  # file be the same order as the sections appear with `streamlit config show`)
39
- _section_descriptions: dict[str, str] = OrderedDict(
40
- _test="Special test section just used for unit tests."
39
+ _section_descriptions: OrderedDict[str, str] = OrderedDict( # ty: ignore
40
+ _test="Special test section just used for unit tests." # ty: ignore
41
41
  )
42
42
 
43
43
  # Ensures that we don't try to get or set config options when config.toml files
@@ -925,6 +925,24 @@ _create_option(
925
925
  type_=bool,
926
926
  )
927
927
 
928
+ _create_option(
929
+ "server.websocketPingInterval",
930
+ description="""
931
+ The interval (in seconds) at which the server pings the client to keep
932
+ the websocket connection alive.
933
+
934
+ The default value should work for most deployments. However, if you're
935
+ experiencing frequent disconnections in certain proxy setups (e.g.,
936
+ "Connection error" messages), you may want to try adjusting this value.
937
+
938
+ Note: When you set this option, Streamlit automatically sets the ping
939
+ timeout to match this interval. For Tornado >=6.5, a value less than 30
940
+ may cause connection issues.
941
+ """,
942
+ default_val=None,
943
+ type_=int,
944
+ )
945
+
928
946
  _create_option(
929
947
  "server.enableStaticServing",
930
948
  description="""
@@ -1364,13 +1382,13 @@ _create_theme_options(
1364
1382
 
1365
1383
  _create_theme_options(
1366
1384
  "codeFontWeight",
1367
- categories=["theme"],
1385
+ categories=["theme", CustomThemeCategories.SIDEBAR],
1368
1386
  description="""
1369
1387
  The font weight for code blocks and code text.
1370
1388
 
1371
1389
  This applies to font in inline code, code blocks, `st.json`, and
1372
1390
  `st.help`. This is an integer multiple of 100. Values can be between
1373
- 100 and 900, inclusive.
1391
+ 100 and 600, inclusive.
1374
1392
 
1375
1393
  If this isn't set, the code font weight will be 400 (normal weight).
1376
1394
  """,
@@ -1884,7 +1902,7 @@ def get_config_options(
1884
1902
  # Short-circuit if config files were parsed while we were waiting on
1885
1903
  # the lock.
1886
1904
  if _config_options and not force_reparse:
1887
- return _config_options
1905
+ return _config_options # ty: ignore[invalid-return-type]
1888
1906
 
1889
1907
  old_options = _config_options
1890
1908
  _config_options = copy.deepcopy(_config_options_template)
@@ -109,11 +109,11 @@ class BaseConnection(ABC, Generic[RawConnectionT]):
109
109
  are implementing their class' ``_connect`` method. User scripts should, for the
110
110
  most part, have no reason to use this property.
111
111
  """
112
- connections_section = None
112
+ connections_section: AttrDict | None = None
113
113
  if secrets_singleton.load_if_toml_exists():
114
114
  connections_section = secrets_singleton.get("connections")
115
115
 
116
- if type(connections_section) is not AttrDict:
116
+ if connections_section is None or type(connections_section) is not AttrDict:
117
117
  return AttrDict({})
118
118
 
119
119
  return connections_section.get(self._connection_name, AttrDict({}))
@@ -68,10 +68,10 @@ class SnowflakeConnection(BaseConnection["InternalSnowflakeConnection"]):
68
68
  .. |snowflake.connector.connect()| replace:: ``snowflake.connector.connect()``
69
69
  .. _snowflake.connector.connect(): https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect
70
70
 
71
- .. Tip::
71
+ .. Important::
72
72
  `snowflake-snowpark-python <https://pypi.org/project/snowflake-snowpark-python/>`_
73
73
  must be installed in your environment to use this connection. You can
74
- install Snowflake extras along with Streamlit:
74
+ install it as an extra with Streamlit:
75
75
 
76
76
  >>> pip install streamlit[snowflake]
77
77
 
@@ -178,6 +178,7 @@ class SQLConnection(BaseConnection["Engine"]):
178
178
 
179
179
  def _connect(self, autocommit: bool = False, **kwargs: Any) -> Engine:
180
180
  import sqlalchemy
181
+ from sqlalchemy.engine import URL, make_url
181
182
 
182
183
  kwargs = deepcopy(kwargs)
183
184
  conn_param_kwargs = extract_from_dict(_ALL_CONNECTION_PARAMS, kwargs)
@@ -190,7 +191,7 @@ class SQLConnection(BaseConnection["Engine"]):
190
191
  )
191
192
 
192
193
  if "url" in conn_params:
193
- url = sqlalchemy.engine.make_url(conn_params["url"])
194
+ url = make_url(conn_params["url"])
194
195
  else:
195
196
  for p in _REQUIRED_CONNECTION_PARAMS:
196
197
  if p not in conn_params:
@@ -200,7 +201,7 @@ class SQLConnection(BaseConnection["Engine"]):
200
201
  f"+{conn_params['driver']}" if "driver" in conn_params else ""
201
202
  )
202
203
 
203
- url = sqlalchemy.engine.URL.create(
204
+ url = URL.create(
204
205
  drivername=drivername,
205
206
  username=conn_params["username"],
206
207
  password=conn_params.get("password"),
@@ -217,7 +218,7 @@ class SQLConnection(BaseConnection["Engine"]):
217
218
 
218
219
  if autocommit:
219
220
  return cast("Engine", eng.execution_options(isolation_level="AUTOCOMMIT"))
220
- return cast("Engine", eng)
221
+ return cast("Engine", eng) # ty: ignore[redundant-cast]
221
222
 
222
223
  def query(
223
224
  self,
@@ -1076,7 +1076,7 @@ def is_colum_type_arrow_incompatible(column: Series[Any] | Index) -> bool:
1076
1076
  return True
1077
1077
 
1078
1078
  # Get the first value to check if it is a supported list-like type.
1079
- first_value = column.iloc[0]
1079
+ first_value = cast("DataFrameGenericAlias[Any]", column).iloc[0]
1080
1080
 
1081
1081
  if ( # noqa: SIM103
1082
1082
  not is_list_like(first_value)
@@ -27,14 +27,25 @@ TFunc = TypeVar("TFunc", bound=Callable[..., Any])
27
27
  TObj = TypeVar("TObj", bound=object)
28
28
 
29
29
 
30
- def _should_show_deprecation_warning_in_browser() -> bool:
30
+ def _error_details_in_browser_enabled() -> bool:
31
31
  """True if we should print deprecation warnings to the browser."""
32
32
  return bool(config.get_option("client.showErrorDetails"))
33
33
 
34
34
 
35
- def show_deprecation_warning(message: str) -> None:
36
- """Show a deprecation warning message."""
37
- if _should_show_deprecation_warning_in_browser():
35
+ def show_deprecation_warning(message: str, show_in_browser: bool = True) -> None:
36
+ """Show a deprecation warning message.
37
+
38
+ Parameters
39
+ ----------
40
+ message : str
41
+ The deprecation warning message.
42
+ show_in_browser : bool, default=True
43
+ Whether to show the deprecation warning in the browser. When this is True,
44
+ we will show the deprecation warning in the browser unless the user has
45
+ disabled error details in the browser by setting the `client.showErrorDetails`
46
+ config option to "none".
47
+ """
48
+ if _error_details_in_browser_enabled() and show_in_browser:
38
49
  streamlit.warning(message)
39
50
 
40
51
  # We always log deprecation warnings
@@ -97,7 +108,11 @@ def deprecate_func_name(
97
108
  result = func(*args, **kwargs)
98
109
  show_deprecation_warning(
99
110
  make_deprecated_name_warning(
100
- old_name, name_override or func.__name__, removal_date, extra_message
111
+ old_name,
112
+ name_override
113
+ or (str(func.__name__) if hasattr(func, "__name__") else "unknown"),
114
+ removal_date,
115
+ extra_message,
101
116
  )
102
117
  )
103
118
  return result
@@ -38,6 +38,9 @@ from streamlit.elements.lib.column_config_utils import (
38
38
  update_column_config,
39
39
  )
40
40
  from streamlit.elements.lib.form_utils import current_form_id
41
+ from streamlit.elements.lib.layout_utils import (
42
+ LayoutConfig,
43
+ )
41
44
  from streamlit.elements.lib.pandas_styler_utils import marshall_styler
42
45
  from streamlit.elements.lib.policies import check_widget_policies
43
46
  from streamlit.elements.lib.utils import Key, compute_and_register_element_id, to_key
@@ -104,17 +107,16 @@ class DataframeSelectionState(TypedDict, total=False):
104
107
  Try selecting some rows. To select multiple columns, hold ``Ctrl`` while
105
108
  selecting columns. Hold ``Shift`` to select a range of columns.
106
109
 
107
- >>> import streamlit as st
108
110
  >>> import pandas as pd
109
- >>> import numpy as np
111
+ >>> import streamlit as st
112
+ >>> from numpy.random import default_rng as rng
110
113
  >>>
111
- >>> if "df" not in st.session_state:
112
- >>> st.session_state.df = pd.DataFrame(
113
- ... np.random.randn(12, 5), columns=["a", "b", "c", "d", "e"]
114
- ... )
114
+ >>> df = pd.DataFrame(
115
+ ... rng(0).standard_normal((12, 5)), columns=["a", "b", "c", "d", "e"]
116
+ ... )
115
117
  >>>
116
118
  >>> event = st.dataframe(
117
- ... st.session_state.df,
119
+ ... df,
118
120
  ... key="data",
119
121
  ... on_select="rerun",
120
122
  ... selection_mode=["multi-row", "multi-column"],
@@ -438,13 +440,15 @@ class ArrowMixin:
438
440
  --------
439
441
  **Example 1: Display a dataframe**
440
442
 
441
- >>> import streamlit as st
442
443
  >>> import pandas as pd
443
- >>> import numpy as np
444
+ >>> import streamlit as st
445
+ >>> from numpy.random import default_rng as rng
444
446
  >>>
445
- >>> df = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
447
+ >>> df = pd.DataFrame(
448
+ ... rng(0).standard_normal((50, 20)), columns=("col %d" % i for i in range(20))
449
+ ... )
446
450
  >>>
447
- >>> st.dataframe(df) # Same as st.write(df)
451
+ >>> st.dataframe(df)
448
452
 
449
453
  .. output::
450
454
  https://doc-dataframe.streamlit.app/
@@ -455,11 +459,13 @@ class ArrowMixin:
455
459
  You can also pass a Pandas Styler object to change the style of
456
460
  the rendered DataFrame:
457
461
 
458
- >>> import streamlit as st
459
462
  >>> import pandas as pd
460
- >>> import numpy as np
463
+ >>> import streamlit as st
464
+ >>> from numpy.random import default_rng as rng
461
465
  >>>
462
- >>> df = pd.DataFrame(np.random.randn(10, 20), columns=("col %d" % i for i in range(20)))
466
+ >>> df = pd.DataFrame(
467
+ ... rng(0).standard_normal((10, 20)), columns=("col %d" % i for i in range(20))
468
+ ... )
463
469
  >>>
464
470
  >>> st.dataframe(df.style.highlight_max(axis=0))
465
471
 
@@ -471,34 +477,39 @@ class ArrowMixin:
471
477
 
472
478
  You can customize a dataframe via ``column_config``, ``hide_index``, or ``column_order``.
473
479
 
474
- >>> import random
475
480
  >>> import pandas as pd
476
481
  >>> import streamlit as st
482
+ >>> from numpy.random import default_rng as rng
477
483
  >>>
478
484
  >>> df = pd.DataFrame(
479
- >>> {
480
- >>> "name": ["Roadmap", "Extras", "Issues"],
481
- >>> "url": ["https://roadmap.streamlit.app", "https://extras.streamlit.app", "https://issues.streamlit.app"],
482
- >>> "stars": [random.randint(0, 1000) for _ in range(3)],
483
- >>> "views_history": [[random.randint(0, 5000) for _ in range(30)] for _ in range(3)],
484
- >>> }
485
- >>> )
485
+ ... {
486
+ ... "name": ["Roadmap", "Extras", "Issues"],
487
+ ... "url": [
488
+ ... "https://roadmap.streamlit.app",
489
+ ... "https://extras.streamlit.app",
490
+ ... "https://issues.streamlit.app",
491
+ ... ],
492
+ ... "stars": rng(0).integers(0, 1000, size=3),
493
+ ... "views_history": rng(0).integers(0, 5000, size=(3, 30)).tolist(),
494
+ ... }
495
+ ... )
496
+ >>>
486
497
  >>> st.dataframe(
487
- >>> df,
488
- >>> column_config={
489
- >>> "name": "App name",
490
- >>> "stars": st.column_config.NumberColumn(
491
- >>> "Github Stars",
492
- >>> help="Number of stars on GitHub",
493
- >>> format="%d ⭐",
494
- >>> ),
495
- >>> "url": st.column_config.LinkColumn("App URL"),
496
- >>> "views_history": st.column_config.LineChartColumn(
497
- >>> "Views (past 30 days)", y_min=0, y_max=5000
498
- >>> ),
499
- >>> },
500
- >>> hide_index=True,
501
- >>> )
498
+ ... df,
499
+ ... column_config={
500
+ ... "name": "App name",
501
+ ... "stars": st.column_config.NumberColumn(
502
+ ... "Github Stars",
503
+ ... help="Number of stars on GitHub",
504
+ ... format="%d ⭐",
505
+ ... ),
506
+ ... "url": st.column_config.LinkColumn("App URL"),
507
+ ... "views_history": st.column_config.LineChartColumn(
508
+ ... "Views (past 30 days)", y_min=0, y_max=5000
509
+ ... ),
510
+ ... },
511
+ ... hide_index=True,
512
+ ... )
502
513
 
503
514
  .. output::
504
515
  https://doc-dataframe-config.streamlit.app/
@@ -508,22 +519,28 @@ class ArrowMixin:
508
519
 
509
520
  You can use column configuration to format your index.
510
521
 
511
- >>> import streamlit as st
522
+ >>> from datetime import datetime, date
523
+ >>> import numpy as np
512
524
  >>> import pandas as pd
513
- >>> from datetime import date
525
+ >>> import streamlit as st
514
526
  >>>
515
- >>> df = pd.DataFrame(
516
- >>> {
517
- >>> "Date": [date(2024, 1, 1), date(2024, 2, 1), date(2024, 3, 1)],
518
- >>> "Total": [13429, 23564, 23452],
519
- >>> }
520
- >>> )
521
- >>> df.set_index("Date", inplace=True)
527
+ >>> @st.cache_data
528
+ >>> def load_data():
529
+ >>> year = datetime.now().year
530
+ >>> df = pd.DataFrame(
531
+ ... {
532
+ ... "Date": [date(year, month, 1) for month in range(1, 4)],
533
+ ... "Total": np.random.randint(1000, 5000, size=3),
534
+ ... }
535
+ ... )
536
+ >>> df.set_index("Date", inplace=True)
537
+ >>> return df
522
538
  >>>
539
+ >>> df = load_data()
523
540
  >>> config = {
524
- >>> "_index": st.column_config.DateColumn("Month", format="MMM YYYY"),
525
- >>> "Total": st.column_config.NumberColumn("Total ($)"),
526
- >>> }
541
+ ... "_index": st.column_config.DateColumn("Month", format="MMM YYYY"),
542
+ ... "Total": st.column_config.NumberColumn("Total ($)"),
543
+ ... }
527
544
  >>>
528
545
  >>> st.dataframe(df, column_config=config)
529
546
 
@@ -677,12 +694,13 @@ class ArrowMixin:
677
694
  --------
678
695
  **Example 1: Display a simple dataframe as a static table**
679
696
 
680
- >>> import streamlit as st
681
697
  >>> import pandas as pd
682
- >>> import numpy as np
698
+ >>> import streamlit as st
699
+ >>> from numpy.random import default_rng as rng
683
700
  >>>
684
701
  >>> df = pd.DataFrame(
685
- ... np.random.randn(10, 5), columns=("col %d" % i for i in range(5))
702
+ ... rng(0).standard_normal(size=(10, 5)),
703
+ ... columns=("col %d" % i for i in range(5)),
686
704
  ... )
687
705
  >>>
688
706
  >>> st.table(df)
@@ -693,19 +711,22 @@ class ArrowMixin:
693
711
 
694
712
  **Example 2: Display a table of Markdown strings**
695
713
 
696
- >>> import streamlit as st
697
714
  >>> import pandas as pd
715
+ >>> import streamlit as st
698
716
  >>>
699
717
  >>> df = pd.DataFrame(
700
718
  ... {
701
719
  ... "Command": ["**st.table**", "*st.dataframe*"],
702
720
  ... "Type": ["`static`", "`interactive`"],
703
721
  ... "Docs": [
704
- ... "[:rainbow[docs]](https://docs.streamlit.io/develop/api-reference/data/st.dataframe)",
705
- ... "[:book:](https://docs.streamlit.io/develop/api-reference/data/st.table)",
722
+ ... "[:rainbow[docs]](https://docs.streamlit.io"
723
+ ... "/develop/api-reference/data/st.dataframe)",
724
+ ... "[:open_book:](https://docs.streamlit.io"
725
+ ... "/develop/api-reference/data/st.table)",
706
726
  ... ],
707
727
  ... }
708
728
  ... )
729
+ >>>
709
730
  >>> st.table(df)
710
731
 
711
732
  .. output::
@@ -728,9 +749,16 @@ class ArrowMixin:
728
749
  delta_path = self.dg._get_delta_path_str()
729
750
  default_uuid = str(hash(delta_path))
730
751
 
752
+ # Tables dimensions are not configurable, this ensures that
753
+ # styles are applied correctly on the element container in the frontend.
754
+ layout_config = LayoutConfig(
755
+ width="stretch",
756
+ height="content",
757
+ )
758
+
731
759
  proto = ArrowProto()
732
760
  marshall(proto, data, default_uuid)
733
- return self.dg._enqueue("arrow_table", proto)
761
+ return self.dg._enqueue("arrow_table", proto, layout_config=layout_config)
734
762
 
735
763
  @gather_metrics("add_rows")
736
764
  def add_rows(self, data: Data = None, **kwargs: Any) -> DeltaGenerator | None:
@@ -747,32 +775,30 @@ class ArrowMixin:
747
775
 
748
776
  Example
749
777
  -------
750
- >>> import streamlit as st
778
+ >>> import time
751
779
  >>> import pandas as pd
752
- >>> import numpy as np
780
+ >>> import streamlit as st
781
+ >>> from numpy.random import default_rng as rng
753
782
  >>>
754
783
  >>> df1 = pd.DataFrame(
755
- ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
756
- ... )
757
- >>>
758
- >>> my_table = st.table(df1)
784
+ >>> rng(0).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
785
+ >>> )
759
786
  >>>
760
787
  >>> df2 = pd.DataFrame(
761
- ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
762
- ... )
788
+ >>> rng(1).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
789
+ >>> )
763
790
  >>>
791
+ >>> my_table = st.table(df1)
792
+ >>> time.sleep(1)
764
793
  >>> my_table.add_rows(df2)
765
- >>> # Now the table shown in the Streamlit app contains the data for
766
- >>> # df1 followed by the data for df2.
767
794
 
768
795
  You can do the same thing with plots. For example, if you want to add
769
796
  more data to a line chart:
770
797
 
771
798
  >>> # Assuming df1 and df2 from the example above still exist...
772
799
  >>> my_chart = st.line_chart(df1)
800
+ >>> time.sleep(1)
773
801
  >>> my_chart.add_rows(df2)
774
- >>> # Now the chart shown in the Streamlit app contains the data for
775
- >>> # df1 followed by the data for df2.
776
802
 
777
803
  And for plots whose datasets are named, you can pass the data with a
778
804
  keyword argument where the key is the name:
@@ -838,30 +864,30 @@ def _arrow_add_rows(
838
864
 
839
865
  Example
840
866
  -------
841
- >>> import streamlit as st
867
+ >>> import time
842
868
  >>> import pandas as pd
843
- >>> import numpy as np
869
+ >>> import streamlit as st
870
+ >>> from numpy.random import default_rng as rng
844
871
  >>>
845
872
  >>> df1 = pd.DataFrame(
846
- ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
847
- ... )
848
- >>> my_table = st.table(df1)
873
+ >>> rng(0).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
874
+ >>> )
849
875
  >>>
850
876
  >>> df2 = pd.DataFrame(
851
- ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
852
- ... )
877
+ >>> rng(1).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
878
+ >>> )
879
+ >>>
880
+ >>> my_table = st.table(df1)
881
+ >>> time.sleep(1)
853
882
  >>> my_table.add_rows(df2)
854
- >>> # Now the table shown in the Streamlit app contains the data for
855
- >>> # df1 followed by the data for df2.
856
883
 
857
884
  You can do the same thing with plots. For example, if you want to add
858
885
  more data to a line chart:
859
886
 
860
887
  >>> # Assuming df1 and df2 from the example above still exist...
861
888
  >>> my_chart = st.line_chart(df1)
889
+ >>> time.sleep(1)
862
890
  >>> my_chart.add_rows(df2)
863
- >>> # Now the chart shown in the Streamlit app contains the data for
864
- >>> # df1 followed by the data for df2.
865
891
 
866
892
  And for plots whose datasets are named, you can pass the data with a
867
893
  keyword argument where the key is the name:
@@ -410,13 +410,13 @@ class PydeckMixin:
410
410
  Here's a chart using a HexagonLayer and a ScatterplotLayer. It uses either the
411
411
  light or dark map style, based on which Streamlit theme is currently active:
412
412
 
413
- >>> import streamlit as st
414
413
  >>> import pandas as pd
415
- >>> import numpy as np
416
414
  >>> import pydeck as pdk
415
+ >>> import streamlit as st
416
+ >>> from numpy.random import default_rng as rng
417
417
  >>>
418
- >>> chart_data = pd.DataFrame(
419
- ... np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
418
+ >>> df = pd.DataFrame(
419
+ ... rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
420
420
  ... columns=["lat", "lon"],
421
421
  ... )
422
422
  >>>
@@ -432,7 +432,7 @@ class PydeckMixin:
432
432
  ... layers=[
433
433
  ... pdk.Layer(
434
434
  ... "HexagonLayer",
435
- ... data=chart_data,
435
+ ... data=df,
436
436
  ... get_position="[lon, lat]",
437
437
  ... radius=200,
438
438
  ... elevation_scale=4,
@@ -442,7 +442,7 @@ class PydeckMixin:
442
442
  ... ),
443
443
  ... pdk.Layer(
444
444
  ... "ScatterplotLayer",
445
- ... data=chart_data,
445
+ ... data=df,
446
446
  ... get_position="[lon, lat]",
447
447
  ... get_color="[200, 30, 0, 160]",
448
448
  ... get_radius=200,