streamlit-nightly 1.31.2.dev20240212__py2.py3-none-any.whl → 1.31.2.dev20240214__py2.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 (184) hide show
  1. streamlit/case_converters.py +9 -4
  2. streamlit/cli_util.py +2 -0
  3. streamlit/code_util.py +5 -2
  4. streamlit/color_util.py +2 -0
  5. streamlit/column_config.py +2 -0
  6. streamlit/commands/execution_control.py +4 -2
  7. streamlit/commands/experimental_query_params.py +7 -4
  8. streamlit/commands/page_config.py +11 -9
  9. streamlit/components/v1/components.py +23 -16
  10. streamlit/config.py +3 -5
  11. streamlit/config_option.py +12 -11
  12. streamlit/connections/base_connection.py +4 -2
  13. streamlit/connections/snowflake_connection.py +4 -4
  14. streamlit/connections/snowpark_connection.py +3 -3
  15. streamlit/connections/sql_connection.py +6 -6
  16. streamlit/connections/util.py +8 -5
  17. streamlit/constants.py +2 -0
  18. streamlit/cursor.py +16 -14
  19. streamlit/delta_generator.py +10 -13
  20. streamlit/deprecation_util.py +4 -3
  21. streamlit/echo.py +5 -3
  22. streamlit/elements/alert.py +16 -14
  23. streamlit/elements/altair_utils.py +8 -6
  24. streamlit/elements/arrow.py +4 -4
  25. streamlit/elements/arrow_altair.py +24 -34
  26. streamlit/elements/arrow_vega_lite.py +9 -14
  27. streamlit/elements/balloons.py +4 -2
  28. streamlit/elements/bokeh_chart.py +7 -7
  29. streamlit/elements/code.py +6 -4
  30. streamlit/elements/deck_gl_json_chart.py +8 -8
  31. streamlit/elements/doc_string.py +5 -9
  32. streamlit/elements/empty.py +4 -2
  33. streamlit/elements/exception.py +10 -10
  34. streamlit/elements/form.py +1 -3
  35. streamlit/elements/graphviz_chart.py +5 -6
  36. streamlit/elements/heading.py +16 -14
  37. streamlit/elements/iframe.py +14 -12
  38. streamlit/elements/image.py +8 -8
  39. streamlit/elements/json.py +6 -4
  40. streamlit/elements/layouts.py +12 -10
  41. streamlit/elements/lib/column_config_utils.py +2 -2
  42. streamlit/elements/lib/column_types.py +23 -23
  43. streamlit/elements/lib/dicttools.py +10 -6
  44. streamlit/elements/lib/mutable_status_container.py +7 -7
  45. streamlit/elements/lib/pandas_styler_utils.py +6 -6
  46. streamlit/elements/lib/streamlit_plotly_theme.py +2 -0
  47. streamlit/elements/map.py +11 -22
  48. streamlit/elements/markdown.py +16 -14
  49. streamlit/elements/media.py +16 -16
  50. streamlit/elements/metric.py +9 -7
  51. streamlit/elements/plotly_chart.py +5 -5
  52. streamlit/elements/progress.py +6 -6
  53. streamlit/elements/pyplot.py +10 -13
  54. streamlit/elements/snow.py +4 -2
  55. streamlit/elements/spinner.py +2 -0
  56. streamlit/elements/text.py +7 -5
  57. streamlit/elements/toast.py +6 -4
  58. streamlit/elements/utils.py +15 -28
  59. streamlit/elements/widgets/button.py +39 -39
  60. streamlit/elements/widgets/camera_input.py +21 -17
  61. streamlit/elements/widgets/chat.py +6 -7
  62. streamlit/elements/widgets/checkbox.py +21 -19
  63. streamlit/elements/widgets/color_picker.py +18 -16
  64. streamlit/elements/widgets/data_editor.py +7 -7
  65. streamlit/elements/widgets/file_uploader.py +59 -55
  66. streamlit/elements/widgets/multiselect.py +33 -42
  67. streamlit/elements/widgets/number_input.py +10 -5
  68. streamlit/elements/widgets/radio.py +1 -1
  69. streamlit/elements/widgets/select_slider.py +25 -34
  70. streamlit/elements/widgets/selectbox.py +1 -1
  71. streamlit/elements/widgets/slider.py +28 -36
  72. streamlit/elements/widgets/text_widgets.py +6 -6
  73. streamlit/elements/widgets/time_widgets.py +13 -13
  74. streamlit/elements/write.py +21 -29
  75. streamlit/env_util.py +5 -3
  76. streamlit/error_util.py +7 -3
  77. streamlit/errors.py +3 -1
  78. streamlit/external/langchain/streamlit_callback_handler.py +26 -24
  79. streamlit/file_util.py +18 -14
  80. streamlit/folder_black_list.py +3 -1
  81. streamlit/git_util.py +5 -3
  82. streamlit/js_number.py +10 -13
  83. streamlit/logger.py +5 -5
  84. streamlit/net_util.py +14 -11
  85. streamlit/platform.py +2 -0
  86. streamlit/runtime/__init__.py +2 -0
  87. streamlit/runtime/app_session.py +42 -42
  88. streamlit/runtime/caching/__init__.py +4 -4
  89. streamlit/runtime/caching/cache_data_api.py +3 -3
  90. streamlit/runtime/caching/cache_errors.py +5 -3
  91. streamlit/runtime/caching/cache_type.py +2 -0
  92. streamlit/runtime/caching/cache_utils.py +2 -4
  93. streamlit/runtime/caching/cached_message_replay.py +12 -5
  94. streamlit/runtime/caching/hashing.py +29 -21
  95. streamlit/runtime/caching/storage/cache_storage_protocol.py +1 -2
  96. streamlit/runtime/caching/storage/local_disk_cache_storage.py +6 -5
  97. streamlit/runtime/connection_factory.py +8 -8
  98. streamlit/runtime/forward_msg_cache.py +20 -18
  99. streamlit/runtime/forward_msg_queue.py +8 -9
  100. streamlit/runtime/legacy_caching/caching.py +32 -42
  101. streamlit/runtime/legacy_caching/hashing.py +29 -25
  102. streamlit/runtime/media_file_manager.py +16 -14
  103. streamlit/runtime/media_file_storage.py +8 -8
  104. streamlit/runtime/memory_media_file_storage.py +12 -14
  105. streamlit/runtime/memory_session_storage.py +4 -3
  106. streamlit/runtime/memory_uploaded_file_manager.py +9 -10
  107. streamlit/runtime/metrics_util.py +20 -20
  108. streamlit/runtime/runtime.py +25 -27
  109. streamlit/runtime/runtime_util.py +5 -3
  110. streamlit/runtime/script_data.py +2 -0
  111. streamlit/runtime/scriptrunner/magic.py +17 -11
  112. streamlit/runtime/scriptrunner/magic_funcs.py +2 -0
  113. streamlit/runtime/scriptrunner/script_requests.py +6 -4
  114. streamlit/runtime/scriptrunner/script_run_context.py +17 -17
  115. streamlit/runtime/scriptrunner/script_runner.py +7 -5
  116. streamlit/runtime/secrets.py +4 -6
  117. streamlit/runtime/session_manager.py +14 -14
  118. streamlit/runtime/state/common.py +5 -4
  119. streamlit/runtime/state/query_params.py +8 -6
  120. streamlit/runtime/state/query_params_proxy.py +7 -5
  121. streamlit/runtime/state/safe_session_state.py +7 -5
  122. streamlit/runtime/state/session_state.py +3 -4
  123. streamlit/runtime/state/session_state_proxy.py +5 -5
  124. streamlit/runtime/state/widgets.py +20 -18
  125. streamlit/runtime/stats.py +13 -15
  126. streamlit/runtime/uploaded_file_manager.py +6 -5
  127. streamlit/runtime/websocket_session_manager.py +14 -14
  128. streamlit/source_util.py +13 -11
  129. streamlit/static/asset-manifest.json +13 -13
  130. streamlit/static/index.html +1 -1
  131. streamlit/static/static/css/2411.8b8f33d6.chunk.css +1 -0
  132. streamlit/static/static/css/43.e3b876c5.chunk.css +1 -0
  133. streamlit/static/static/css/6692.65519639.chunk.css +1 -0
  134. streamlit/static/static/js/{3075.76725a14.chunk.js → 2411.714d213e.chunk.js} +2 -2
  135. streamlit/static/static/js/4185.21ca0590.chunk.js +1 -0
  136. streamlit/static/static/js/43.36939bb1.chunk.js +1 -0
  137. streamlit/static/static/js/{5117.6a701db1.chunk.js → 5117.04bfe5d3.chunk.js} +1 -1
  138. streamlit/static/static/js/{5791.30b01ee8.chunk.js → 5791.c5138157.chunk.js} +1 -1
  139. streamlit/static/static/js/656.8c998bc8.chunk.js +2 -0
  140. streamlit/static/static/js/{6692.6ac4ea6f.chunk.js → 6692.6496cbc2.chunk.js} +1 -1
  141. streamlit/static/static/js/7142.400eefdd.chunk.js +1 -0
  142. streamlit/static/static/js/main.2737c0f9.js +2 -0
  143. streamlit/static/static/js/{main.043d802e.js.LICENSE.txt → main.2737c0f9.js.LICENSE.txt} +23 -25
  144. streamlit/string_util.py +13 -9
  145. streamlit/temporary_directory.py +3 -1
  146. streamlit/testing/v1/element_tree.py +1 -2
  147. streamlit/testing/v1/util.py +7 -3
  148. streamlit/type_util.py +30 -25
  149. streamlit/url_util.py +6 -4
  150. streamlit/user_info.py +8 -6
  151. streamlit/util.py +23 -37
  152. streamlit/version.py +16 -9
  153. streamlit/watcher/event_based_path_watcher.py +10 -10
  154. streamlit/watcher/local_sources_watcher.py +15 -13
  155. streamlit/watcher/path_watcher.py +0 -3
  156. streamlit/watcher/polling_path_watcher.py +9 -8
  157. streamlit/watcher/util.py +3 -2
  158. streamlit/web/cache_storage_manager_config.py +2 -0
  159. streamlit/web/server/app_static_file_handler.py +6 -5
  160. streamlit/web/server/browser_websocket_handler.py +10 -8
  161. streamlit/web/server/component_request_handler.py +7 -4
  162. streamlit/web/server/media_file_handler.py +5 -4
  163. streamlit/web/server/routes.py +6 -3
  164. streamlit/web/server/server.py +41 -34
  165. streamlit/web/server/server_util.py +8 -3
  166. streamlit/web/server/stats_request_handler.py +14 -5
  167. streamlit/web/server/upload_file_request_handler.py +7 -8
  168. streamlit/web/server/websocket_headers.py +2 -2
  169. {streamlit_nightly-1.31.2.dev20240212.dist-info → streamlit_nightly-1.31.2.dev20240214.dist-info}/METADATA +1 -1
  170. {streamlit_nightly-1.31.2.dev20240212.dist-info → streamlit_nightly-1.31.2.dev20240214.dist-info}/RECORD +176 -176
  171. streamlit/static/static/css/3075.81b3d18f.chunk.css +0 -1
  172. streamlit/static/static/css/43.c24b25fa.chunk.css +0 -1
  173. streamlit/static/static/css/6692.bb444a79.chunk.css +0 -1
  174. streamlit/static/static/js/1215.baf3721f.chunk.js +0 -2
  175. streamlit/static/static/js/4185.90e929dc.chunk.js +0 -1
  176. streamlit/static/static/js/43.8ca4bc8a.chunk.js +0 -1
  177. streamlit/static/static/js/7142.a359ed63.chunk.js +0 -1
  178. streamlit/static/static/js/main.043d802e.js +0 -2
  179. /streamlit/static/static/js/{3075.76725a14.chunk.js.LICENSE.txt → 2411.714d213e.chunk.js.LICENSE.txt} +0 -0
  180. /streamlit/static/static/js/{1215.baf3721f.chunk.js.LICENSE.txt → 656.8c998bc8.chunk.js.LICENSE.txt} +0 -0
  181. {streamlit_nightly-1.31.2.dev20240212.data → streamlit_nightly-1.31.2.dev20240214.data}/scripts/streamlit.cmd +0 -0
  182. {streamlit_nightly-1.31.2.dev20240212.dist-info → streamlit_nightly-1.31.2.dev20240214.dist-info}/WHEEL +0 -0
  183. {streamlit_nightly-1.31.2.dev20240212.dist-info → streamlit_nightly-1.31.2.dev20240214.dist-info}/entry_points.txt +0 -0
  184. {streamlit_nightly-1.31.2.dev20240212.dist-info → streamlit_nightly-1.31.2.dev20240214.dist-info}/top_level.txt +0 -0
streamlit/cursor.py CHANGED
@@ -12,15 +12,17 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from typing import Any, List, Optional, Tuple
15
+ from __future__ import annotations
16
+
17
+ from typing import Any
16
18
 
17
19
  from streamlit import util
18
20
  from streamlit.runtime.scriptrunner import get_script_run_ctx
19
21
 
20
22
 
21
23
  def make_delta_path(
22
- root_container: int, parent_path: Tuple[int, ...], index: int
23
- ) -> List[int]:
24
+ root_container: int, parent_path: tuple[int, ...], index: int
25
+ ) -> list[int]:
24
26
  delta_path = [root_container]
25
27
  delta_path.extend(parent_path)
26
28
  delta_path.append(index)
@@ -28,8 +30,8 @@ def make_delta_path(
28
30
 
29
31
 
30
32
  def get_container_cursor(
31
- root_container: Optional[int],
32
- ) -> Optional["RunningCursor"]:
33
+ root_container: int | None,
34
+ ) -> RunningCursor | None:
33
35
  """Return the top-level RunningCursor for the given container.
34
36
  This is the cursor that is used when user code calls something like
35
37
  `st.foo` (which uses the main container) or `st.sidebar.foo` (which uses
@@ -69,7 +71,7 @@ class Cursor:
69
71
  raise NotImplementedError()
70
72
 
71
73
  @property
72
- def parent_path(self) -> Tuple[int, ...]:
74
+ def parent_path(self) -> tuple[int, ...]:
73
75
  """The cursor's parent's path within its container."""
74
76
  raise NotImplementedError()
75
77
 
@@ -79,7 +81,7 @@ class Cursor:
79
81
  raise NotImplementedError()
80
82
 
81
83
  @property
82
- def delta_path(self) -> List[int]:
84
+ def delta_path(self) -> list[int]:
83
85
  """The complete path of the delta pointed to by this cursor - its
84
86
  container, parent path, and index.
85
87
  """
@@ -89,7 +91,7 @@ class Cursor:
89
91
  def is_locked(self) -> bool:
90
92
  raise NotImplementedError()
91
93
 
92
- def get_locked_cursor(self, **props) -> "LockedCursor":
94
+ def get_locked_cursor(self, **props) -> LockedCursor:
93
95
  raise NotImplementedError()
94
96
 
95
97
  @property
@@ -103,7 +105,7 @@ class Cursor:
103
105
 
104
106
 
105
107
  class RunningCursor(Cursor):
106
- def __init__(self, root_container: int, parent_path: Tuple[int, ...] = ()):
108
+ def __init__(self, root_container: int, parent_path: tuple[int, ...] = ()):
107
109
  """A moving pointer to a delta location in the app.
108
110
 
109
111
  RunningCursors auto-increment to the next available location when you
@@ -127,7 +129,7 @@ class RunningCursor(Cursor):
127
129
  return self._root_container
128
130
 
129
131
  @property
130
- def parent_path(self) -> Tuple[int, ...]:
132
+ def parent_path(self) -> tuple[int, ...]:
131
133
  return self._parent_path
132
134
 
133
135
  @property
@@ -138,7 +140,7 @@ class RunningCursor(Cursor):
138
140
  def is_locked(self) -> bool:
139
141
  return False
140
142
 
141
- def get_locked_cursor(self, **props) -> "LockedCursor":
143
+ def get_locked_cursor(self, **props) -> LockedCursor:
142
144
  locked_cursor = LockedCursor(
143
145
  root_container=self._root_container,
144
146
  parent_path=self._parent_path,
@@ -155,7 +157,7 @@ class LockedCursor(Cursor):
155
157
  def __init__(
156
158
  self,
157
159
  root_container: int,
158
- parent_path: Tuple[int, ...] = (),
160
+ parent_path: tuple[int, ...] = (),
159
161
  index: int = 0,
160
162
  **props,
161
163
  ):
@@ -188,7 +190,7 @@ class LockedCursor(Cursor):
188
190
  return self._root_container
189
191
 
190
192
  @property
191
- def parent_path(self) -> Tuple[int, ...]:
193
+ def parent_path(self) -> tuple[int, ...]:
192
194
  return self._parent_path
193
195
 
194
196
  @property
@@ -199,7 +201,7 @@ class LockedCursor(Cursor):
199
201
  def is_locked(self) -> bool:
200
202
  return True
201
203
 
202
- def get_locked_cursor(self, **props) -> "LockedCursor":
204
+ def get_locked_cursor(self, **props) -> LockedCursor:
203
205
  self._props = props
204
206
  return self
205
207
 
@@ -27,7 +27,6 @@ from typing import (
27
27
  Iterable,
28
28
  Literal,
29
29
  NoReturn,
30
- Type,
31
30
  TypeVar,
32
31
  cast,
33
32
  overload,
@@ -340,19 +339,17 @@ class DeltaGenerator(
340
339
  if name in streamlit_methods:
341
340
  if self._root_container == RootContainer.SIDEBAR:
342
341
  message = (
343
- "Method `%(name)s()` does not exist for "
344
- "`st.sidebar`. Did you mean `st.%(name)s()`?" % {"name": name}
342
+ f"Method `{name}()` does not exist for "
343
+ f"`st.sidebar`. Did you mean `st.{name}()`?"
345
344
  )
346
345
  else:
347
346
  message = (
348
- "Method `%(name)s()` does not exist for "
347
+ f"Method `{name}()` does not exist for "
349
348
  "`DeltaGenerator` objects. Did you mean "
350
- "`st.%(name)s()`?" % {"name": name}
349
+ "`st.{name}()`?"
351
350
  )
352
351
  else:
353
- message = "`%(name)s()` is not a valid Streamlit command." % {
354
- "name": name
355
- }
352
+ message = f"`{name}()` is not a valid Streamlit command."
356
353
 
357
354
  raise StreamlitAPIException(message)
358
355
 
@@ -432,7 +429,7 @@ class DeltaGenerator(
432
429
  self,
433
430
  delta_type: str,
434
431
  element_proto: Message,
435
- return_value: Type[NoValue],
432
+ return_value: type[NoValue],
436
433
  add_rows_metadata: AddRowsMetadata | None = None,
437
434
  element_width: int | None = None,
438
435
  element_height: int | None = None,
@@ -468,7 +465,7 @@ class DeltaGenerator(
468
465
  self,
469
466
  delta_type: str,
470
467
  element_proto: Message,
471
- return_value: Type[NoValue] | Value | None = None,
468
+ return_value: type[NoValue] | Value | None = None,
472
469
  add_rows_metadata: AddRowsMetadata | None = None,
473
470
  element_width: int | None = None,
474
471
  element_height: int | None = None,
@@ -479,7 +476,7 @@ class DeltaGenerator(
479
476
  self,
480
477
  delta_type: str,
481
478
  element_proto: Message,
482
- return_value: Type[NoValue] | Value | None = None,
479
+ return_value: type[NoValue] | Value | None = None,
483
480
  add_rows_metadata: AddRowsMetadata | None = None,
484
481
  element_width: int | None = None,
485
482
  element_height: int | None = None,
@@ -837,7 +834,7 @@ def _value_or_dg(value: None, dg: DG) -> DG:
837
834
 
838
835
 
839
836
  @overload
840
- def _value_or_dg(value: Type[NoValue], dg: DG) -> None: # type: ignore[misc]
837
+ def _value_or_dg(value: type[NoValue], dg: DG) -> None: # type: ignore[misc]
841
838
  ...
842
839
 
843
840
 
@@ -855,7 +852,7 @@ def _value_or_dg(value: Value, dg: DG) -> Value:
855
852
 
856
853
 
857
854
  def _value_or_dg(
858
- value: Type[NoValue] | Value | None,
855
+ value: type[NoValue] | Value | None,
859
856
  dg: DG,
860
857
  ) -> DG | Value | None:
861
858
  """Return either value, or None, or dg.
@@ -11,16 +11,17 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
14
15
  from __future__ import annotations
15
16
 
16
17
  import functools
17
- from typing import Any, Callable, List, TypeVar, cast
18
+ from typing import Any, Callable, Final, TypeVar, cast
18
19
 
19
20
  import streamlit
20
21
  from streamlit import config
21
22
  from streamlit.logger import get_logger
22
23
 
23
- _LOGGER = get_logger(__name__)
24
+ _LOGGER: Final = get_logger(__name__)
24
25
 
25
26
  TFunc = TypeVar("TFunc", bound=Callable[..., Any])
26
27
  TObj = TypeVar("TObj", bound=object)
@@ -187,7 +188,7 @@ def _create_deprecated_obj_wrapper(obj: TObj, show_warning: Callable[[], Any]) -
187
188
  return getattr(obj, attr)
188
189
 
189
190
  @staticmethod
190
- def _get_magic_functions(cls) -> List[str]:
191
+ def _get_magic_functions(cls) -> list[str]:
191
192
  # ignore the handful of magic functions we cannot override without
192
193
  # breaking the Wrapper.
193
194
  ignore = ("__class__", "__dict__", "__getattribute__", "__getattr__")
streamlit/echo.py CHANGED
@@ -12,12 +12,14 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import ast
16
18
  import contextlib
17
19
  import re
18
20
  import textwrap
19
21
  import traceback
20
- from typing import Any, Dict, Iterable, Optional
22
+ from typing import Any, Iterable
21
23
 
22
24
  from streamlit.runtime.metrics_util import gather_metrics
23
25
 
@@ -66,7 +68,7 @@ def echo(code_location="above"):
66
68
 
67
69
  # Use ast to parse the Python file and find the code block to display
68
70
  root_node = ast.parse("".join(source_lines))
69
- line_to_node_map: Dict[int, Any] = {}
71
+ line_to_node_map: dict[int, Any] = {}
70
72
 
71
73
  def collect_body_statements(node: ast.AST) -> None:
72
74
  if not hasattr(node, "body"):
@@ -109,7 +111,7 @@ def _get_initial_indent(lines: Iterable[str]) -> int:
109
111
  return 0
110
112
 
111
113
 
112
- def _get_indent(line: str) -> Optional[int]:
114
+ def _get_indent(line: str) -> int | None:
113
115
  """Get the number of whitespaces at the beginning of the given line.
114
116
  If the line is empty, or if it contains just whitespace and a newline,
115
117
  return None.
@@ -12,7 +12,9 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from typing import TYPE_CHECKING, Optional, cast
15
+ from __future__ import annotations
16
+
17
+ from typing import TYPE_CHECKING, cast
16
18
 
17
19
  from streamlit.proto.Alert_pb2 import Alert as AlertProto
18
20
  from streamlit.runtime.metrics_util import gather_metrics
@@ -27,10 +29,10 @@ class AlertMixin:
27
29
  @gather_metrics("error")
28
30
  def error(
29
31
  self,
30
- body: "SupportsStr",
32
+ body: SupportsStr,
31
33
  *, # keyword-only args:
32
- icon: Optional[str] = None,
33
- ) -> "DeltaGenerator":
34
+ icon: str | None = None,
35
+ ) -> DeltaGenerator:
34
36
  """Display error message.
35
37
 
36
38
  Parameters
@@ -59,10 +61,10 @@ class AlertMixin:
59
61
  @gather_metrics("warning")
60
62
  def warning(
61
63
  self,
62
- body: "SupportsStr",
64
+ body: SupportsStr,
63
65
  *, # keyword-only args:
64
- icon: Optional[str] = None,
65
- ) -> "DeltaGenerator":
66
+ icon: str | None = None,
67
+ ) -> DeltaGenerator:
66
68
  """Display warning message.
67
69
 
68
70
  Parameters
@@ -91,10 +93,10 @@ class AlertMixin:
91
93
  @gather_metrics("info")
92
94
  def info(
93
95
  self,
94
- body: "SupportsStr",
96
+ body: SupportsStr,
95
97
  *, # keyword-only args:
96
- icon: Optional[str] = None,
97
- ) -> "DeltaGenerator":
98
+ icon: str | None = None,
99
+ ) -> DeltaGenerator:
98
100
  """Display an informational message.
99
101
 
100
102
  Parameters
@@ -124,10 +126,10 @@ class AlertMixin:
124
126
  @gather_metrics("success")
125
127
  def success(
126
128
  self,
127
- body: "SupportsStr",
129
+ body: SupportsStr,
128
130
  *, # keyword-only args:
129
- icon: Optional[str] = None,
130
- ) -> "DeltaGenerator":
131
+ icon: str | None = None,
132
+ ) -> DeltaGenerator:
131
133
  """Display a success message.
132
134
 
133
135
  Parameters
@@ -154,6 +156,6 @@ class AlertMixin:
154
156
  return self.dg._enqueue("alert", alert_proto)
155
157
 
156
158
  @property
157
- def dg(self) -> "DeltaGenerator":
159
+ def dg(self) -> DeltaGenerator:
158
160
  """Get our DeltaGenerator."""
159
161
  return cast("DeltaGenerator", self)
@@ -17,22 +17,24 @@
17
17
  These classes are used to pass some important info to add_rows.
18
18
  """
19
19
 
20
+ from __future__ import annotations
21
+
20
22
  from dataclasses import dataclass
21
- from typing import Hashable, List, Optional, TypedDict
23
+ from typing import Hashable, TypedDict
22
24
 
23
25
 
24
26
  class PrepDataColumns(TypedDict):
25
27
  """Columns used for the prep_data step in Altair Arrow charts."""
26
28
 
27
- x_column: Optional[str]
28
- y_column_list: List[str]
29
- color_column: Optional[str]
30
- size_column: Optional[str]
29
+ x_column: str | None
30
+ y_column_list: list[str]
31
+ color_column: str | None
32
+ size_column: str | None
31
33
 
32
34
 
33
35
  @dataclass
34
36
  class AddRowsMetadata:
35
37
  """Metadata needed by add_rows on native charts."""
36
38
 
37
- last_index: Optional[Hashable]
39
+ last_index: Hashable | None
38
40
  columns: PrepDataColumns
@@ -64,7 +64,7 @@ class ArrowMixin:
64
64
  hide_index: bool | None = None,
65
65
  column_order: Iterable[str] | None = None,
66
66
  column_config: ColumnConfigMappingInput | None = None,
67
- ) -> "DeltaGenerator":
67
+ ) -> DeltaGenerator:
68
68
  """Display a dataframe as an interactive table.
69
69
 
70
70
  This command works with dataframes from Pandas, PyArrow, Snowpark, and PySpark.
@@ -239,7 +239,7 @@ class ArrowMixin:
239
239
  return self.dg._enqueue("arrow_data_frame", proto)
240
240
 
241
241
  @gather_metrics("table")
242
- def table(self, data: Data = None) -> "DeltaGenerator":
242
+ def table(self, data: Data = None) -> DeltaGenerator:
243
243
  """Display a static table.
244
244
 
245
245
  This differs from ``st.dataframe`` in that the table in this case is
@@ -284,7 +284,7 @@ class ArrowMixin:
284
284
  return self.dg._enqueue("arrow_table", proto)
285
285
 
286
286
  @gather_metrics("add_rows")
287
- def add_rows(self, data: "Data" = None, **kwargs) -> "DeltaGenerator" | None:
287
+ def add_rows(self, data: Data = None, **kwargs) -> DeltaGenerator | None:
288
288
  """Concatenate a dataframe to the bottom of the current one.
289
289
 
290
290
  Parameters
@@ -338,7 +338,7 @@ class ArrowMixin:
338
338
  return self.dg._arrow_add_rows(data, **kwargs)
339
339
 
340
340
  @property
341
- def dg(self) -> "DeltaGenerator":
341
+ def dg(self) -> DeltaGenerator:
342
342
  """Get our DeltaGenerator."""
343
343
  return cast("DeltaGenerator", self)
344
344
 
@@ -21,17 +21,7 @@ from __future__ import annotations
21
21
  from contextlib import nullcontext
22
22
  from datetime import date
23
23
  from enum import Enum
24
- from typing import (
25
- TYPE_CHECKING,
26
- Any,
27
- Collection,
28
- Dict,
29
- List,
30
- Literal,
31
- Sequence,
32
- Tuple,
33
- cast,
34
- )
24
+ from typing import TYPE_CHECKING, Any, Collection, Literal, Sequence, cast
35
25
 
36
26
  import streamlit.elements.arrow_vega_lite as arrow_vega_lite
37
27
  from streamlit import type_util
@@ -108,7 +98,7 @@ class ArrowAltairMixin:
108
98
  *,
109
99
  x: str | None = None,
110
100
  y: str | Sequence[str] | None = None,
111
- color: str | Color | List[Color] | None = None,
101
+ color: str | Color | list[Color] | None = None,
112
102
  width: int = 0,
113
103
  height: int = 0,
114
104
  use_container_width: bool = True,
@@ -266,7 +256,7 @@ class ArrowAltairMixin:
266
256
  *,
267
257
  x: str | None = None,
268
258
  y: str | Sequence[str] | None = None,
269
- color: str | Color | List[Color] | None = None,
259
+ color: str | Color | list[Color] | None = None,
270
260
  width: int = 0,
271
261
  height: int = 0,
272
262
  use_container_width: bool = True,
@@ -425,7 +415,7 @@ class ArrowAltairMixin:
425
415
  *,
426
416
  x: str | None = None,
427
417
  y: str | Sequence[str] | None = None,
428
- color: str | Color | List[Color] | None = None,
418
+ color: str | Color | list[Color] | None = None,
429
419
  width: int = 0,
430
420
  height: int = 0,
431
421
  use_container_width: bool = True,
@@ -586,12 +576,12 @@ class ArrowAltairMixin:
586
576
  *,
587
577
  x: str | None = None,
588
578
  y: str | Sequence[str] | None = None,
589
- color: str | Color | List[Color] | None = None,
579
+ color: str | Color | list[Color] | None = None,
590
580
  size: str | float | int | None = None,
591
581
  width: int = 0,
592
582
  height: int = 0,
593
583
  use_container_width: bool = True,
594
- ) -> "DeltaGenerator":
584
+ ) -> DeltaGenerator:
595
585
  """Display a scatterplot chart.
596
586
 
597
587
  This is syntax-sugar around ``st.altair_chart``. The main difference
@@ -849,8 +839,8 @@ def _is_date_column(df: pd.DataFrame, name: str | None) -> bool:
849
839
 
850
840
  def _melt_data(
851
841
  df: pd.DataFrame,
852
- columns_to_leave_alone: List[str],
853
- columns_to_melt: List[str] | None,
842
+ columns_to_leave_alone: list[str],
843
+ columns_to_melt: list[str] | None,
854
844
  new_y_column_name: str,
855
845
  new_color_column_name: str,
856
846
  ) -> pd.DataFrame:
@@ -893,10 +883,10 @@ def _melt_data(
893
883
  def prep_data(
894
884
  df: pd.DataFrame,
895
885
  x_column: str | None,
896
- y_column_list: List[str],
886
+ y_column_list: list[str],
897
887
  color_column: str | None,
898
888
  size_column: str | None,
899
- ) -> Tuple[pd.DataFrame, str | None, str | None, str | None, str | None]:
889
+ ) -> tuple[pd.DataFrame, str | None, str | None, str | None, str | None]:
900
890
  """Prepares the data for charting. This is also used in add_rows.
901
891
 
902
892
  Returns the prepared dataframe and the new names of the x column (taking the index reset into
@@ -939,11 +929,11 @@ def _generate_chart(
939
929
  data: Data | None,
940
930
  x_from_user: str | None = None,
941
931
  y_from_user: str | Sequence[str] | None = None,
942
- color_from_user: str | Color | List[Color] | None = None,
932
+ color_from_user: str | Color | list[Color] | None = None,
943
933
  size_from_user: str | float | None = None,
944
934
  width: int = 0,
945
935
  height: int = 0,
946
- ) -> Tuple[alt.Chart, AddRowsMetadata]:
936
+ ) -> tuple[alt.Chart, AddRowsMetadata]:
947
937
  """Function to use the chart's type, data columns and indices to figure out the chart's spec."""
948
938
  import altair as alt
949
939
 
@@ -1028,7 +1018,7 @@ def _generate_chart(
1028
1018
 
1029
1019
 
1030
1020
  def _maybe_reset_index_in_place(
1031
- df: pd.DataFrame, x_column: str | None, y_column_list: List[str]
1021
+ df: pd.DataFrame, x_column: str | None, y_column_list: list[str]
1032
1022
  ) -> str | None:
1033
1023
  if x_column is None and len(y_column_list) > 0:
1034
1024
  if df.index.name is None:
@@ -1087,10 +1077,10 @@ def _maybe_convert_color_column_in_place(df: pd.DataFrame, color_column: str | N
1087
1077
  def _convert_col_names_to_str_in_place(
1088
1078
  df: pd.DataFrame,
1089
1079
  x_column: str | None,
1090
- y_column_list: List[str],
1080
+ y_column_list: list[str],
1091
1081
  color_column: str | None,
1092
1082
  size_column: str | None,
1093
- ) -> Tuple[str | None, List[str], str | None, str | None]:
1083
+ ) -> tuple[str | None, list[str], str | None, str | None]:
1094
1084
  """Converts column names to strings, since Vega-Lite does not accept ints, etc."""
1095
1085
  import pandas as pd
1096
1086
 
@@ -1108,7 +1098,7 @@ def _convert_col_names_to_str_in_place(
1108
1098
 
1109
1099
  def _parse_generic_column(
1110
1100
  df: pd.DataFrame, column_or_value: Any
1111
- ) -> Tuple[str | None, Any]:
1101
+ ) -> tuple[str | None, Any]:
1112
1102
  if isinstance(column_or_value, str) and column_or_value in df.columns:
1113
1103
  column_name = column_or_value
1114
1104
  value = None
@@ -1141,8 +1131,8 @@ def _parse_y_columns(
1141
1131
  df: pd.DataFrame,
1142
1132
  y_from_user: str | Sequence[str] | None,
1143
1133
  x_column: str | None,
1144
- ) -> List[str]:
1145
- y_column_list: List[str] = []
1134
+ ) -> list[str]:
1135
+ y_column_list: list[str] = []
1146
1136
 
1147
1137
  if y_from_user is None:
1148
1138
  y_column_list = list(df.columns)
@@ -1210,10 +1200,10 @@ def _get_axis_config(df: pd.DataFrame, column_name: str | None, grid: bool) -> a
1210
1200
  def _maybe_melt(
1211
1201
  df: pd.DataFrame,
1212
1202
  x_column: str | None,
1213
- y_column_list: List[str],
1203
+ y_column_list: list[str],
1214
1204
  color_column: str | None,
1215
1205
  size_column: str | None,
1216
- ) -> Tuple[pd.DataFrame, str | None, str | None]:
1206
+ ) -> tuple[pd.DataFrame, str | None, str | None]:
1217
1207
  """If multiple columns are set for y, melt the dataframe into long format."""
1218
1208
  y_column: str | None
1219
1209
 
@@ -1324,8 +1314,8 @@ def _get_color_encoding(
1324
1314
  df: pd.DataFrame,
1325
1315
  color_value: Color | None,
1326
1316
  color_column: str | None,
1327
- y_column_list: List[str],
1328
- color_from_user: str | Color | List[Color] | None,
1317
+ y_column_list: list[str],
1318
+ color_from_user: str | Color | list[Color] | None,
1329
1319
  ) -> alt.Color | alt.ColorValue | None:
1330
1320
  import altair as alt
1331
1321
 
@@ -1362,7 +1352,7 @@ def _get_color_encoding(
1362
1352
  raise StreamlitInvalidColorError(df, color_from_user)
1363
1353
 
1364
1354
  elif color_column is not None:
1365
- column_type: str | Tuple[str, List[Any]]
1355
+ column_type: str | tuple[str, list[Any]]
1366
1356
 
1367
1357
  if color_column == MELTED_COLOR_COLUMN_NAME:
1368
1358
  column_type = "nominal"
@@ -1525,7 +1515,7 @@ def marshall(
1525
1515
 
1526
1516
  datasets = {}
1527
1517
 
1528
- def id_transform(data) -> Dict[str, str]:
1518
+ def id_transform(data) -> dict[str, str]:
1529
1519
  """Altair data transformer that returns a fake named dataset with the
1530
1520
  object id.
1531
1521
  """
@@ -13,18 +13,16 @@
13
13
  # limitations under the License.
14
14
 
15
15
  """A Python wrapper around Vega-Lite."""
16
+
16
17
  from __future__ import annotations
17
18
 
18
19
  import json
19
- from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast
20
-
21
- from typing_extensions import Final, Literal
20
+ from typing import TYPE_CHECKING, Any, Literal, cast
22
21
 
23
22
  import streamlit.elements.lib.dicttools as dicttools
24
23
  from streamlit.elements import arrow
25
24
  from streamlit.elements.arrow import Data
26
25
  from streamlit.errors import StreamlitAPIException
27
- from streamlit.logger import get_logger
28
26
  from streamlit.proto.ArrowVegaLiteChart_pb2 import (
29
27
  ArrowVegaLiteChart as ArrowVegaLiteChartProto,
30
28
  )
@@ -34,19 +32,16 @@ if TYPE_CHECKING:
34
32
  from streamlit.delta_generator import DeltaGenerator
35
33
 
36
34
 
37
- LOGGER: Final = get_logger(__name__)
38
-
39
-
40
35
  class ArrowVegaLiteMixin:
41
36
  @gather_metrics("vega_lite_chart")
42
37
  def vega_lite_chart(
43
38
  self,
44
39
  data: Data = None,
45
- spec: Dict[str, Any] | None = None,
40
+ spec: dict[str, Any] | None = None,
46
41
  use_container_width: bool = False,
47
42
  theme: Literal["streamlit"] | None = "streamlit",
48
43
  **kwargs: Any,
49
- ) -> "DeltaGenerator":
44
+ ) -> DeltaGenerator:
50
45
  """Display a chart using the Vega-Lite library.
51
46
 
52
47
  Parameters
@@ -117,7 +112,7 @@ class ArrowVegaLiteMixin:
117
112
  return self.dg._enqueue("arrow_vega_lite_chart", proto)
118
113
 
119
114
  @property
120
- def dg(self) -> "DeltaGenerator":
115
+ def dg(self) -> DeltaGenerator:
121
116
  """Get our DeltaGenerator."""
122
117
  return cast("DeltaGenerator", self)
123
118
 
@@ -125,9 +120,9 @@ class ArrowVegaLiteMixin:
125
120
  def marshall(
126
121
  proto: ArrowVegaLiteChartProto,
127
122
  data: Data = None,
128
- spec: Optional[Dict[str, Any]] = None,
123
+ spec: dict[str, Any] | None = None,
129
124
  use_container_width: bool = False,
130
- theme: Union[None, Literal["streamlit"]] = "streamlit",
125
+ theme: None | Literal["streamlit"] = "streamlit",
131
126
  **kwargs,
132
127
  ):
133
128
  """Construct a Vega-Lite chart object.
@@ -203,8 +198,8 @@ _CHANNELS = {
203
198
  "x2",
204
199
  "y2",
205
200
  "xError",
206
- "yError2",
207
- "xError",
201
+ "xError2",
202
+ "yError",
208
203
  "yError2",
209
204
  "longitude",
210
205
  "latitude",
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  from typing import TYPE_CHECKING, cast
16
18
 
17
19
  from streamlit.proto.Balloons_pb2 import Balloons as BalloonsProto
@@ -23,7 +25,7 @@ if TYPE_CHECKING:
23
25
 
24
26
  class BalloonsMixin:
25
27
  @gather_metrics("balloons")
26
- def balloons(self) -> "DeltaGenerator":
28
+ def balloons(self) -> DeltaGenerator:
27
29
  """Draw celebratory balloons.
28
30
 
29
31
  Example
@@ -40,6 +42,6 @@ class BalloonsMixin:
40
42
  return self.dg._enqueue("balloons", balloons_proto)
41
43
 
42
44
  @property
43
- def dg(self) -> "DeltaGenerator":
45
+ def dg(self) -> DeltaGenerator:
44
46
  """Get our DeltaGenerator."""
45
47
  return cast("DeltaGenerator", self)