streamlit-nightly 1.45.1.dev20250508__py3-none-any.whl → 1.45.1.dev20250509__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.
- streamlit/auth_util.py +3 -3
- streamlit/cli_util.py +3 -2
- streamlit/commands/logo.py +2 -2
- streamlit/commands/navigation.py +5 -4
- streamlit/commands/page_config.py +3 -1
- streamlit/components/types/base_custom_component.py +7 -7
- streamlit/components/v1/custom_component.py +6 -6
- streamlit/config.py +9 -9
- streamlit/config_option.py +2 -2
- streamlit/connections/base_connection.py +3 -3
- streamlit/connections/snowflake_connection.py +5 -5
- streamlit/connections/snowpark_connection.py +3 -3
- streamlit/connections/sql_connection.py +9 -10
- streamlit/cursor.py +6 -6
- streamlit/delta_generator.py +7 -6
- streamlit/delta_generator_singletons.py +2 -2
- streamlit/deprecation_util.py +1 -1
- streamlit/elements/arrow.py +2 -3
- streamlit/elements/dialog_decorator.py +3 -3
- streamlit/elements/doc_string.py +20 -20
- streamlit/elements/layouts.py +26 -7
- streamlit/elements/lib/built_in_chart_utils.py +37 -39
- streamlit/elements/lib/color_util.py +3 -3
- streamlit/elements/lib/column_types.py +2 -2
- streamlit/elements/lib/dialog.py +2 -2
- streamlit/elements/lib/event_utils.py +1 -1
- streamlit/elements/lib/mutable_status_container.py +1 -1
- streamlit/elements/lib/policies.py +3 -3
- streamlit/elements/lib/utils.py +5 -5
- streamlit/elements/progress.py +9 -12
- streamlit/elements/vega_charts.py +2 -2
- streamlit/elements/widgets/button_group.py +2 -2
- streamlit/elements/widgets/data_editor.py +2 -2
- streamlit/elements/widgets/multiselect.py +2 -2
- streamlit/elements/widgets/selectbox.py +1 -1
- streamlit/elements/widgets/slider.py +16 -14
- streamlit/elements/write.py +3 -6
- streamlit/errors.py +34 -21
- streamlit/external/langchain/streamlit_callback_handler.py +2 -2
- streamlit/file_util.py +8 -8
- streamlit/git_util.py +1 -1
- streamlit/hello/dataframe_demo.py +1 -1
- streamlit/hello/mapping_demo.py +1 -1
- streamlit/navigation/page.py +1 -1
- streamlit/proto/Block_pb2.py +38 -29
- streamlit/proto/Block_pb2.pyi +68 -4
- streamlit/proto/GapSize_pb2.py +29 -0
- streamlit/proto/GapSize_pb2.pyi +70 -0
- streamlit/proto/HeightConfig_pb2.py +27 -0
- streamlit/proto/HeightConfig_pb2.pyi +48 -0
- streamlit/proto/WidthConfig_pb2.py +2 -2
- streamlit/proto/WidthConfig_pb2.pyi +15 -1
- streamlit/runtime/app_session.py +2 -2
- streamlit/runtime/caching/cache_data_api.py +9 -5
- streamlit/runtime/caching/cache_errors.py +3 -3
- streamlit/runtime/caching/cache_resource_api.py +7 -7
- streamlit/runtime/caching/cache_utils.py +9 -9
- streamlit/runtime/caching/cached_message_replay.py +1 -1
- streamlit/runtime/caching/hashing.py +70 -74
- streamlit/runtime/caching/legacy_cache_api.py +1 -1
- streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +3 -1
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +1 -1
- streamlit/runtime/connection_factory.py +12 -12
- streamlit/runtime/context.py +2 -2
- streamlit/runtime/credentials.py +3 -3
- streamlit/runtime/fragment.py +3 -4
- streamlit/runtime/media_file_manager.py +2 -2
- streamlit/runtime/memory_media_file_storage.py +1 -1
- streamlit/runtime/memory_uploaded_file_manager.py +1 -1
- streamlit/runtime/metrics_util.py +5 -6
- streamlit/runtime/pages_manager.py +3 -3
- streamlit/runtime/runtime.py +1 -1
- streamlit/runtime/runtime_util.py +2 -2
- streamlit/runtime/scriptrunner/exec_code.py +10 -3
- streamlit/runtime/scriptrunner/magic.py +13 -8
- streamlit/runtime/scriptrunner/script_runner.py +2 -2
- streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
- streamlit/runtime/scriptrunner_utils/script_run_context.py +6 -5
- streamlit/runtime/secrets.py +8 -11
- streamlit/runtime/state/query_params.py +2 -2
- streamlit/runtime/state/safe_session_state.py +2 -2
- streamlit/runtime/state/session_state.py +17 -15
- streamlit/runtime/stats.py +1 -1
- streamlit/runtime/uploaded_file_manager.py +1 -1
- streamlit/source_util.py +3 -4
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.C9UoaGEN.js → ErrorOutline.esm.C-0hf1-k.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.DoToR9q0.js → FileDownload.esm.B-fFGI-X.js} +1 -1
- streamlit/static/static/js/{FileHelper.Bt4VJ--Q.js → FileHelper.ACYo0OZo.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.D5PbW8FI.js → FormClearHelper.CVNTT-bJ.js} +1 -1
- streamlit/static/static/js/{Hooks.DgkQ2Xp9.js → Hooks.C3thlpd2.js} +1 -1
- streamlit/static/static/js/{InputInstructions.DLnLhwHI.js → InputInstructions.CwAxousX.js} +1 -1
- streamlit/static/static/js/{ProgressBar.BtSgh_K-.js → ProgressBar.xh599Rum.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.CjdyBvQX.js → RenderInPortalIfExists.CQLIsNPE.js} +1 -1
- streamlit/static/static/js/{Toolbar.CAYIzVZk.js → Toolbar.LKdyvP0u.js} +1 -1
- streamlit/static/static/js/{base-input.CD4xW4_9.js → base-input.D8OdS4WW.js} +1 -1
- streamlit/static/static/js/{checkbox.Ba4jj5dR.js → checkbox.DSdYKlOI.js} +1 -1
- streamlit/static/static/js/{createSuper.BBGT9Ijd.js → createSuper.B2pyCfWw.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CYuk1Aj7.js → data-grid-overlay-editor.DhO2r0ne.js} +1 -1
- streamlit/static/static/js/{downloader.DM9KEOCw.js → downloader.C24skoDM.js} +1 -1
- streamlit/static/static/js/{es6.FqM62T4b.js → es6.DHkvCKPh.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.s2B09mw2.js → iframeResizer.contentWindow.2ckQaC2c.js} +1 -1
- streamlit/static/static/js/index.0dGwl8CJ.js +1 -0
- streamlit/static/static/js/index.B5A28NpR.js +1 -0
- streamlit/static/static/js/{index.B9FiDQ3U.js → index.B5EFweZ4.js} +1 -1
- streamlit/static/static/js/{index.DkGCnTMe.js → index.BAafqHfB.js} +1 -1
- streamlit/static/static/js/{index.BMXmhMlZ.js → index.BHTbGZPQ.js} +1 -1
- streamlit/static/static/js/{index.CpDFZQ4Y.js → index.BNXtQAj4.js} +1 -1
- streamlit/static/static/js/index.BRhKaVdO.js +1 -0
- streamlit/static/static/js/index.BSOiJVQd.js +2 -0
- streamlit/static/static/js/{index.BoMRR3tN.js → index.BVgTQbOJ.js} +1 -1
- streamlit/static/static/js/{index.Cwtbhfaf.js → index.BflIniLm.js} +1 -1
- streamlit/static/static/js/{index.DMrO9G6A.js → index.BjeNtZIz.js} +1 -1
- streamlit/static/static/js/{index.C2qCX1Lh.js → index.By-NmdnB.js} +151 -151
- streamlit/static/static/js/{index.b9kK7Vzl.js → index.CIoOEhZ2.js} +1 -1
- streamlit/static/static/js/{index.CEKMSkSh.js → index.CRCdonis.js} +36 -36
- streamlit/static/static/js/{index.T5LKPcND.js → index.CRxaBCJ7.js} +1 -1
- streamlit/static/static/js/{index.CeiCniCg.js → index.CU-pbYVN.js} +1 -1
- streamlit/static/static/js/{index.BVA8TXNT.js → index.CUsk52t2.js} +1 -1
- streamlit/static/static/js/{index.CH9XN_-G.js → index.CVO14oQG.js} +2 -2
- streamlit/static/static/js/index.CXFuA6J-.js +1 -0
- streamlit/static/static/js/{index.DQi04JYE.js → index.C_dd5q7u.js} +1 -1
- streamlit/static/static/js/{index.DTi8Lw0k.js → index.CjWUnKIN.js} +1 -1
- streamlit/static/static/js/{index.DG8IxVeM.js → index.CkTL9bAR.js} +2 -2
- streamlit/static/static/js/{index.D9FvPPrI.js → index.CsbhsAPy.js} +1 -1
- streamlit/static/static/js/{index.R0peMEpV.js → index.CtCnBUtk.js} +1 -1
- streamlit/static/static/js/{index.CP2PmB93.js → index.CwuKadAX.js} +1 -1
- streamlit/static/static/js/{index.BFqpCk2P.js → index.D0R7Xh4Z.js} +1 -1
- streamlit/static/static/js/{index.DSDkXosb.js → index.D2D75EDw.js} +2 -2
- streamlit/static/static/js/{index.BsjuUMyW.js → index.D4eMiZ1F.js} +1 -1
- streamlit/static/static/js/{index.BDTYk2an.js → index.D7SCC3z9.js} +1 -1
- streamlit/static/static/js/{index.JTeVe9GQ.js → index.DZiilxEt.js} +1 -1
- streamlit/static/static/js/{index.BY7-qCf5.js → index.Dvr1cEJS.js} +1 -1
- streamlit/static/static/js/index.JtIlC6Uq.js +1 -0
- streamlit/static/static/js/index.fz_c3Xh_.js +1 -0
- streamlit/static/static/js/{index.CqaahZPf.js → index.gFjPlsMT.js} +1 -1
- streamlit/static/static/js/{index.0pkoyBcb.js → index.jCJYMVED.js} +1 -1
- streamlit/static/static/js/{index.DWaB7Scf.js → index.xldt56AE.js} +1 -1
- streamlit/static/static/js/{index.CyE1OdOj.js → index.yzoj_DuM.js} +1 -1
- streamlit/static/static/js/{input.DMOGBelK.js → input.BP6LX_Bg.js} +1 -1
- streamlit/static/static/js/{memory.DmCktBGW.js → memory.E9x2ZYJv.js} +1 -1
- streamlit/static/static/js/{mergeWith.DeWTsJ5h.js → mergeWith.CZP2AaVS.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.DDFelcUP.js → number-overlay-editor.D-Kl79U_.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.CYJtAqB-.js → possibleConstructorReturn.P2ILVC_6.js} +1 -1
- streamlit/static/static/js/{sandbox.CfaU9Ih9.js → sandbox.DfzJIGMV.js} +1 -1
- streamlit/static/static/js/{textarea.7hWYKDw2.js → textarea.4PjzfDWF.js} +1 -1
- streamlit/static/static/js/{timepicker.DZsgZ9oE.js → timepicker.DMQdaNzO.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CqWB4Jry.js → toConsumableArray.BEdkbHYx.js} +1 -1
- streamlit/static/static/js/{uniqueId.DQ533D9O.js → uniqueId.CAs7ftHC.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.-99xbU_o.js → useBasicWidgetState.Cedp0V76.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.B4G2Q7Bu.js → useOnInputChange.CvRKHHKx.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.BJQZ2aNc.js → withFullScreenWrapper.BbmjZAzW.js} +1 -1
- streamlit/string_util.py +6 -7
- streamlit/temporary_directory.py +12 -3
- streamlit/testing/v1/app_test.py +11 -6
- streamlit/testing/v1/element_tree.py +134 -158
- streamlit/testing/v1/local_script_runner.py +5 -5
- streamlit/testing/v1/util.py +11 -4
- streamlit/type_util.py +3 -4
- streamlit/user_info.py +3 -2
- streamlit/util.py +1 -1
- streamlit/watcher/event_based_path_watcher.py +1 -1
- streamlit/watcher/folder_black_list.py +1 -1
- streamlit/watcher/local_sources_watcher.py +5 -5
- streamlit/watcher/path_watcher.py +1 -1
- streamlit/web/cli.py +12 -11
- streamlit/web/server/browser_websocket_handler.py +1 -1
- streamlit/web/server/component_request_handler.py +1 -1
- streamlit/web/server/media_file_handler.py +2 -1
- streamlit/web/server/oauth_authlib_routes.py +2 -2
- streamlit/web/server/oidc_mixin.py +13 -6
- streamlit/web/server/routes.py +3 -3
- streamlit/web/server/server.py +1 -1
- streamlit/web/server/server_util.py +7 -6
- streamlit/web/server/upload_file_request_handler.py +5 -5
- {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/RECORD +181 -177
- {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/index.CCD4LJ9Q.js +0 -1
- streamlit/static/static/js/index.CbLZDRQu.js +0 -1
- streamlit/static/static/js/index.D9qEk5xd.js +0 -1
- streamlit/static/static/js/index.DTXSsTgK.js +0 -1
- streamlit/static/static/js/index.DqVjOqxm.js +0 -1
- streamlit/static/static/js/index.RHbaxsqm.js +0 -1
- streamlit/static/static/js/index.hT9gkW3a.js +0 -2
- {streamlit_nightly-1.45.1.dev20250508.data → streamlit_nightly-1.45.1.dev20250509.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.45.1.dev20250508.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/top_level.txt +0 -0
@@ -29,7 +29,7 @@ from typing import (
|
|
29
29
|
overload,
|
30
30
|
)
|
31
31
|
|
32
|
-
from typing_extensions import TypeAlias
|
32
|
+
from typing_extensions import Self, TypeAlias
|
33
33
|
|
34
34
|
from streamlit import dataframe_util, util
|
35
35
|
from streamlit.elements.heading import HeadingProtoTag
|
@@ -124,7 +124,7 @@ class Element(ABC):
|
|
124
124
|
key: str | None
|
125
125
|
|
126
126
|
@abstractmethod
|
127
|
-
def __init__(self, proto: ElementProto, root: ElementTree): ...
|
127
|
+
def __init__(self, proto: ElementProto, root: ElementTree) -> None: ...
|
128
128
|
|
129
129
|
def __iter__(self):
|
130
130
|
yield self
|
@@ -150,13 +150,13 @@ class Element(ABC):
|
|
150
150
|
"""
|
151
151
|
return self.root.run(timeout=timeout)
|
152
152
|
|
153
|
-
def __repr__(self):
|
153
|
+
def __repr__(self) -> str:
|
154
154
|
return util.repr_(self)
|
155
155
|
|
156
156
|
|
157
157
|
@dataclass(repr=False)
|
158
158
|
class UnknownElement(Element):
|
159
|
-
def __init__(self, proto: ElementProto, root: ElementTree):
|
159
|
+
def __init__(self, proto: ElementProto, root: ElementTree) -> None:
|
160
160
|
ty = proto.WhichOneof("type")
|
161
161
|
assert ty is not None
|
162
162
|
self.proto = getattr(proto, ty)
|
@@ -184,13 +184,13 @@ class Widget(Element, ABC):
|
|
184
184
|
key: str | None
|
185
185
|
_value: Any
|
186
186
|
|
187
|
-
def __init__(self, proto: Any, root: ElementTree):
|
187
|
+
def __init__(self, proto: Any, root: ElementTree) -> None:
|
188
188
|
self.proto = proto
|
189
189
|
self.root = root
|
190
190
|
self.key = user_key_from_element_id(self.id)
|
191
191
|
self._value = None
|
192
192
|
|
193
|
-
def set_value(self, v: Any):
|
193
|
+
def set_value(self, v: Any) -> Self:
|
194
194
|
"""Set the value of the widget."""
|
195
195
|
self._value = v
|
196
196
|
return self
|
@@ -204,7 +204,7 @@ El_co = TypeVar("El_co", bound=Element, covariant=True)
|
|
204
204
|
|
205
205
|
|
206
206
|
class ElementList(Generic[El_co]):
|
207
|
-
def __init__(self, els: Sequence[El_co]):
|
207
|
+
def __init__(self, els: Sequence[El_co]) -> None:
|
208
208
|
self._list: Sequence[El_co] = els
|
209
209
|
|
210
210
|
def __len__(self) -> int:
|
@@ -223,20 +223,18 @@ class ElementList(Generic[El_co]):
|
|
223
223
|
def __getitem__(self, idx: int | slice) -> El_co | ElementList[El_co]:
|
224
224
|
if isinstance(idx, slice):
|
225
225
|
return ElementList(self._list[idx])
|
226
|
-
|
227
|
-
return self._list[idx]
|
226
|
+
return self._list[idx]
|
228
227
|
|
229
228
|
def __iter__(self):
|
230
229
|
yield from self._list
|
231
230
|
|
232
|
-
def __repr__(self):
|
231
|
+
def __repr__(self) -> str:
|
233
232
|
return util.repr_(self)
|
234
233
|
|
235
234
|
def __eq__(self, other: ElementList[El_co] | object) -> bool:
|
236
235
|
if isinstance(other, ElementList):
|
237
236
|
return self._list == other._list
|
238
|
-
|
239
|
-
return self._list == other
|
237
|
+
return self._list == other
|
240
238
|
|
241
239
|
@property
|
242
240
|
def values(self) -> Sequence[Any]:
|
@@ -260,7 +258,7 @@ class AlertBase(Element):
|
|
260
258
|
proto: AlertProto = field(repr=False)
|
261
259
|
icon: str
|
262
260
|
|
263
|
-
def __init__(self, proto: AlertProto, root: ElementTree):
|
261
|
+
def __init__(self, proto: AlertProto, root: ElementTree) -> None:
|
264
262
|
self.proto = proto
|
265
263
|
self.key = None
|
266
264
|
self.root = root
|
@@ -272,28 +270,28 @@ class AlertBase(Element):
|
|
272
270
|
|
273
271
|
@dataclass(repr=False)
|
274
272
|
class Error(AlertBase):
|
275
|
-
def __init__(self, proto: AlertProto, root: ElementTree):
|
273
|
+
def __init__(self, proto: AlertProto, root: ElementTree) -> None:
|
276
274
|
super().__init__(proto, root)
|
277
275
|
self.type = "error"
|
278
276
|
|
279
277
|
|
280
278
|
@dataclass(repr=False)
|
281
279
|
class Warning(AlertBase): # noqa: A001
|
282
|
-
def __init__(self, proto: AlertProto, root: ElementTree):
|
280
|
+
def __init__(self, proto: AlertProto, root: ElementTree) -> None:
|
283
281
|
super().__init__(proto, root)
|
284
282
|
self.type = "warning"
|
285
283
|
|
286
284
|
|
287
285
|
@dataclass(repr=False)
|
288
286
|
class Info(AlertBase):
|
289
|
-
def __init__(self, proto: AlertProto, root: ElementTree):
|
287
|
+
def __init__(self, proto: AlertProto, root: ElementTree) -> None:
|
290
288
|
super().__init__(proto, root)
|
291
289
|
self.type = "info"
|
292
290
|
|
293
291
|
|
294
292
|
@dataclass(repr=False)
|
295
293
|
class Success(AlertBase):
|
296
|
-
def __init__(self, proto: AlertProto, root: ElementTree):
|
294
|
+
def __init__(self, proto: AlertProto, root: ElementTree) -> None:
|
297
295
|
super().__init__(proto, root)
|
298
296
|
self.type = "success"
|
299
297
|
|
@@ -309,7 +307,7 @@ class Button(Widget):
|
|
309
307
|
help: str
|
310
308
|
form_id: str
|
311
309
|
|
312
|
-
def __init__(self, proto: ButtonProto, root: ElementTree):
|
310
|
+
def __init__(self, proto: ButtonProto, root: ElementTree) -> None:
|
313
311
|
super().__init__(proto, root)
|
314
312
|
self._value = False
|
315
313
|
self.type = "button"
|
@@ -326,10 +324,9 @@ class Button(Widget):
|
|
326
324
|
"""The value of the button. (bool)""" # noqa: D400
|
327
325
|
if self._value:
|
328
326
|
return self._value
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
return cast("bool", state[TESTING_KEY][self.id])
|
327
|
+
state = self.root.session_state
|
328
|
+
assert state
|
329
|
+
return cast("bool", state[TESTING_KEY][self.id])
|
333
330
|
|
334
331
|
def set_value(self, v: bool) -> Button:
|
335
332
|
"""Set the value of the button."""
|
@@ -349,7 +346,7 @@ class ChatInput(Widget):
|
|
349
346
|
proto: ChatInputProto = field(repr=False)
|
350
347
|
placeholder: str
|
351
348
|
|
352
|
-
def __init__(self, proto: ChatInputProto, root: ElementTree):
|
349
|
+
def __init__(self, proto: ChatInputProto, root: ElementTree) -> None:
|
353
350
|
super().__init__(proto, root)
|
354
351
|
self.type = "chat_input"
|
355
352
|
|
@@ -371,10 +368,9 @@ class ChatInput(Widget):
|
|
371
368
|
"""The value of the widget. (str)""" # noqa: D400
|
372
369
|
if self._value:
|
373
370
|
return self._value
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
return state[TESTING_KEY][self.id] # type: ignore
|
371
|
+
state = self.root.session_state
|
372
|
+
assert state
|
373
|
+
return state[TESTING_KEY][self.id] # type: ignore
|
378
374
|
|
379
375
|
|
380
376
|
@dataclass(repr=False)
|
@@ -388,7 +384,7 @@ class Checkbox(Widget):
|
|
388
384
|
help: str
|
389
385
|
form_id: str
|
390
386
|
|
391
|
-
def __init__(self, proto: CheckboxProto, root: ElementTree):
|
387
|
+
def __init__(self, proto: CheckboxProto, root: ElementTree) -> None:
|
392
388
|
super().__init__(proto, root)
|
393
389
|
self.type = "checkbox"
|
394
390
|
|
@@ -404,10 +400,9 @@ class Checkbox(Widget):
|
|
404
400
|
"""The value of the widget. (bool)""" # noqa: D400
|
405
401
|
if self._value is not None:
|
406
402
|
return self._value
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
return cast("bool", state[self.id])
|
403
|
+
state = self.root.session_state
|
404
|
+
assert state
|
405
|
+
return cast("bool", state[self.id])
|
411
406
|
|
412
407
|
def set_value(self, v: bool) -> Checkbox:
|
413
408
|
"""Set the value of the widget."""
|
@@ -433,7 +428,7 @@ class Code(Element):
|
|
433
428
|
show_line_numbers: bool
|
434
429
|
key: None
|
435
430
|
|
436
|
-
def __init__(self, proto: CodeProto, root: ElementTree):
|
431
|
+
def __init__(self, proto: CodeProto, root: ElementTree) -> None:
|
437
432
|
self.proto = proto
|
438
433
|
self.key = None
|
439
434
|
self.root = root
|
@@ -456,7 +451,7 @@ class ColorPicker(Widget):
|
|
456
451
|
|
457
452
|
proto: ColorPickerProto = field(repr=False)
|
458
453
|
|
459
|
-
def __init__(self, proto: ColorPickerProto, root: ElementTree):
|
454
|
+
def __init__(self, proto: ColorPickerProto, root: ElementTree) -> None:
|
460
455
|
super().__init__(proto, root)
|
461
456
|
self.type = "color_picker"
|
462
457
|
|
@@ -465,10 +460,9 @@ class ColorPicker(Widget):
|
|
465
460
|
"""The currently selected value as a hex string. (str)""" # noqa: D400
|
466
461
|
if self._value is not None:
|
467
462
|
return self._value
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
return cast("str", state[self.id])
|
463
|
+
state = self.root.session_state
|
464
|
+
assert state
|
465
|
+
return cast("str", state[self.id])
|
472
466
|
|
473
467
|
@property
|
474
468
|
def _widget_state(self) -> WidgetState:
|
@@ -497,7 +491,7 @@ class ColorPicker(Widget):
|
|
497
491
|
class Dataframe(Element):
|
498
492
|
proto: ArrowProto = field(repr=False)
|
499
493
|
|
500
|
-
def __init__(self, proto: ArrowProto, root: ElementTree):
|
494
|
+
def __init__(self, proto: ArrowProto, root: ElementTree) -> None:
|
501
495
|
self.key = None
|
502
496
|
self.proto = proto
|
503
497
|
self.root = root
|
@@ -525,7 +519,7 @@ class DateInput(Widget):
|
|
525
519
|
help: str
|
526
520
|
form_id: str
|
527
521
|
|
528
|
-
def __init__(self, proto: DateInputProto, root: ElementTree):
|
522
|
+
def __init__(self, proto: DateInputProto, root: ElementTree) -> None:
|
529
523
|
super().__init__(proto, root)
|
530
524
|
self._value = InitialValue()
|
531
525
|
self.type = "date_input"
|
@@ -552,10 +546,9 @@ class DateInput(Widget):
|
|
552
546
|
if not isinstance(self._value, InitialValue):
|
553
547
|
parsed, _ = _parse_date_value(self._value)
|
554
548
|
return tuple(parsed) if parsed is not None else None # type: ignore
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
return state[self.id] # type: ignore
|
549
|
+
state = self.root.session_state
|
550
|
+
assert state
|
551
|
+
return state[self.id] # type: ignore
|
559
552
|
|
560
553
|
|
561
554
|
@dataclass(repr=False)
|
@@ -565,7 +558,7 @@ class Exception(Element): # noqa: A001
|
|
565
558
|
stack_trace: list[str]
|
566
559
|
is_warning: bool
|
567
560
|
|
568
|
-
def __init__(self, proto: ExceptionProto, root: ElementTree):
|
561
|
+
def __init__(self, proto: ExceptionProto, root: ElementTree) -> None:
|
569
562
|
self.key = None
|
570
563
|
self.root = root
|
571
564
|
self.proto = proto
|
@@ -588,7 +581,7 @@ class HeadingBase(Element, ABC):
|
|
588
581
|
hide_anchor: bool
|
589
582
|
key: None
|
590
583
|
|
591
|
-
def __init__(self, proto: HeadingProto, root: ElementTree, type_: str):
|
584
|
+
def __init__(self, proto: HeadingProto, root: ElementTree, type_: str) -> None:
|
592
585
|
self.proto = proto
|
593
586
|
self.key = None
|
594
587
|
self.root = root
|
@@ -601,19 +594,19 @@ class HeadingBase(Element, ABC):
|
|
601
594
|
|
602
595
|
@dataclass(repr=False)
|
603
596
|
class Header(HeadingBase):
|
604
|
-
def __init__(self, proto: HeadingProto, root: ElementTree):
|
597
|
+
def __init__(self, proto: HeadingProto, root: ElementTree) -> None:
|
605
598
|
super().__init__(proto, root, "header")
|
606
599
|
|
607
600
|
|
608
601
|
@dataclass(repr=False)
|
609
602
|
class Subheader(HeadingBase):
|
610
|
-
def __init__(self, proto: HeadingProto, root: ElementTree):
|
603
|
+
def __init__(self, proto: HeadingProto, root: ElementTree) -> None:
|
611
604
|
super().__init__(proto, root, "subheader")
|
612
605
|
|
613
606
|
|
614
607
|
@dataclass(repr=False)
|
615
608
|
class Title(HeadingBase):
|
616
|
-
def __init__(self, proto: HeadingProto, root: ElementTree):
|
609
|
+
def __init__(self, proto: HeadingProto, root: ElementTree) -> None:
|
617
610
|
super().__init__(proto, root, "title")
|
618
611
|
|
619
612
|
|
@@ -623,7 +616,7 @@ class Json(Element):
|
|
623
616
|
|
624
617
|
expanded: bool
|
625
618
|
|
626
|
-
def __init__(self, proto: JsonProto, root: ElementTree):
|
619
|
+
def __init__(self, proto: JsonProto, root: ElementTree) -> None:
|
627
620
|
self.proto = proto
|
628
621
|
self.key = None
|
629
622
|
self.root = root
|
@@ -642,7 +635,7 @@ class Markdown(Element):
|
|
642
635
|
allow_html: bool
|
643
636
|
key: None
|
644
637
|
|
645
|
-
def __init__(self, proto: MarkdownProto, root: ElementTree):
|
638
|
+
def __init__(self, proto: MarkdownProto, root: ElementTree) -> None:
|
646
639
|
self.proto = proto
|
647
640
|
self.key = None
|
648
641
|
self.root = root
|
@@ -655,21 +648,21 @@ class Markdown(Element):
|
|
655
648
|
|
656
649
|
@dataclass(repr=False)
|
657
650
|
class Caption(Markdown):
|
658
|
-
def __init__(self, proto: MarkdownProto, root: ElementTree):
|
651
|
+
def __init__(self, proto: MarkdownProto, root: ElementTree) -> None:
|
659
652
|
super().__init__(proto, root)
|
660
653
|
self.type = "caption"
|
661
654
|
|
662
655
|
|
663
656
|
@dataclass(repr=False)
|
664
657
|
class Divider(Markdown):
|
665
|
-
def __init__(self, proto: MarkdownProto, root: ElementTree):
|
658
|
+
def __init__(self, proto: MarkdownProto, root: ElementTree) -> None:
|
666
659
|
super().__init__(proto, root)
|
667
660
|
self.type = "divider"
|
668
661
|
|
669
662
|
|
670
663
|
@dataclass(repr=False)
|
671
664
|
class Latex(Markdown):
|
672
|
-
def __init__(self, proto: MarkdownProto, root: ElementTree):
|
665
|
+
def __init__(self, proto: MarkdownProto, root: ElementTree) -> None:
|
673
666
|
super().__init__(proto, root)
|
674
667
|
self.type = "latex"
|
675
668
|
|
@@ -682,7 +675,7 @@ class Metric(Element):
|
|
682
675
|
color: str
|
683
676
|
help: str
|
684
677
|
|
685
|
-
def __init__(self, proto: MetricProto, root: ElementTree):
|
678
|
+
def __init__(self, proto: MetricProto, root: ElementTree) -> None:
|
686
679
|
self.proto = proto
|
687
680
|
self.key = None
|
688
681
|
self.root = root
|
@@ -703,7 +696,7 @@ class ButtonGroup(Widget, Generic[T]):
|
|
703
696
|
options: list[ButtonGroupProto.Option]
|
704
697
|
form_id: str
|
705
698
|
|
706
|
-
def __init__(self, proto: ButtonGroupProto, root: ElementTree):
|
699
|
+
def __init__(self, proto: ButtonGroupProto, root: ElementTree) -> None:
|
707
700
|
super().__init__(proto, root)
|
708
701
|
self.type = "button_group"
|
709
702
|
self.options = list(proto.options)
|
@@ -724,10 +717,9 @@ class ButtonGroup(Widget, Generic[T]):
|
|
724
717
|
"""The currently selected values from the options. (list)""" # noqa: D400
|
725
718
|
if self._value is not None:
|
726
719
|
return self._value
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
return cast("list[T]", state[self.id])
|
720
|
+
state = self.root.session_state
|
721
|
+
assert state
|
722
|
+
return cast("list[T]", state[self.id])
|
731
723
|
|
732
724
|
@property
|
733
725
|
def indices(self) -> Sequence[int]:
|
@@ -755,11 +747,10 @@ class ButtonGroup(Widget, Generic[T]):
|
|
755
747
|
current = self.value
|
756
748
|
if v in current:
|
757
749
|
return self
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
return self
|
750
|
+
new = current.copy()
|
751
|
+
new.append(v)
|
752
|
+
self.set_value(new)
|
753
|
+
return self
|
763
754
|
|
764
755
|
def unselect(self, v: T) -> ButtonGroup[T]:
|
765
756
|
"""
|
@@ -770,12 +761,11 @@ class ButtonGroup(Widget, Generic[T]):
|
|
770
761
|
current = self.value
|
771
762
|
if v not in current:
|
772
763
|
return self
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
return self
|
764
|
+
new = current.copy()
|
765
|
+
while v in new:
|
766
|
+
new.remove(v)
|
767
|
+
self.set_value(new)
|
768
|
+
return self
|
779
769
|
|
780
770
|
|
781
771
|
@dataclass(repr=False)
|
@@ -791,7 +781,7 @@ class Multiselect(Widget, Generic[T]):
|
|
791
781
|
help: str
|
792
782
|
form_id: str
|
793
783
|
|
794
|
-
def __init__(self, proto: MultiSelectProto, root: ElementTree):
|
784
|
+
def __init__(self, proto: MultiSelectProto, root: ElementTree) -> None:
|
795
785
|
super().__init__(proto, root)
|
796
786
|
self.type = "multiselect"
|
797
787
|
self.options = list(proto.options)
|
@@ -812,10 +802,9 @@ class Multiselect(Widget, Generic[T]):
|
|
812
802
|
"""The currently selected values from the options. (list)""" # noqa: D400
|
813
803
|
if self._value is not None:
|
814
804
|
return self._value
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
return cast("list[T]", state[self.id])
|
805
|
+
state = self.root.session_state
|
806
|
+
assert state
|
807
|
+
return cast("list[T]", state[self.id])
|
819
808
|
|
820
809
|
@property
|
821
810
|
def indices(self) -> Sequence[int]:
|
@@ -848,11 +837,10 @@ class Multiselect(Widget, Generic[T]):
|
|
848
837
|
current = self.value
|
849
838
|
if v in current:
|
850
839
|
return self
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
return self
|
840
|
+
new = current.copy()
|
841
|
+
new.append(v)
|
842
|
+
self.set_value(new)
|
843
|
+
return self
|
856
844
|
|
857
845
|
def unselect(self, v: T) -> Multiselect[T]:
|
858
846
|
"""
|
@@ -863,12 +851,11 @@ class Multiselect(Widget, Generic[T]):
|
|
863
851
|
current = self.value
|
864
852
|
if v not in current:
|
865
853
|
return self
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
return self
|
854
|
+
new = current.copy()
|
855
|
+
while v in new:
|
856
|
+
new.remove(v)
|
857
|
+
self.set_value(new)
|
858
|
+
return self
|
872
859
|
|
873
860
|
|
874
861
|
Number = Union[int, float]
|
@@ -887,7 +874,7 @@ class NumberInput(Widget):
|
|
887
874
|
help: str
|
888
875
|
form_id: str
|
889
876
|
|
890
|
-
def __init__(self, proto: NumberInputProto, root: ElementTree):
|
877
|
+
def __init__(self, proto: NumberInputProto, root: ElementTree) -> None:
|
891
878
|
super().__init__(proto, root)
|
892
879
|
self._value = InitialValue()
|
893
880
|
self.type = "number_input"
|
@@ -912,12 +899,11 @@ class NumberInput(Widget):
|
|
912
899
|
"""Get the current value of the ``st.number_input`` widget."""
|
913
900
|
if not isinstance(self._value, InitialValue):
|
914
901
|
return self._value
|
915
|
-
|
916
|
-
|
917
|
-
assert state
|
902
|
+
state = self.root.session_state
|
903
|
+
assert state
|
918
904
|
|
919
|
-
|
920
|
-
|
905
|
+
# Awkward to do this with `cast`
|
906
|
+
return state[self.id] # type: ignore
|
921
907
|
|
922
908
|
def increment(self) -> NumberInput:
|
923
909
|
"""Increment the ``st.number_input`` widget as if the user clicked "+"."""
|
@@ -949,7 +935,7 @@ class Radio(Widget, Generic[T]):
|
|
949
935
|
help: str
|
950
936
|
form_id: str
|
951
937
|
|
952
|
-
def __init__(self, proto: RadioProto, root: ElementTree):
|
938
|
+
def __init__(self, proto: RadioProto, root: ElementTree) -> None:
|
953
939
|
super().__init__(proto, root)
|
954
940
|
self._value = InitialValue()
|
955
941
|
self.type = "radio"
|
@@ -967,10 +953,9 @@ class Radio(Widget, Generic[T]):
|
|
967
953
|
"""The currently selected value from the options. (Any)""" # noqa: D400
|
968
954
|
if not isinstance(self._value, InitialValue):
|
969
955
|
return self._value
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
return cast("T", state[self.id])
|
956
|
+
state = self.root.session_state
|
957
|
+
assert state
|
958
|
+
return cast("T", state[self.id])
|
974
959
|
|
975
960
|
@property
|
976
961
|
def format_func(self) -> Callable[[Any], Any]:
|
@@ -1008,7 +993,7 @@ class Selectbox(Widget, Generic[T]):
|
|
1008
993
|
help: str
|
1009
994
|
form_id: str
|
1010
995
|
|
1011
|
-
def __init__(self, proto: SelectboxProto, root: ElementTree):
|
996
|
+
def __init__(self, proto: SelectboxProto, root: ElementTree) -> None:
|
1012
997
|
super().__init__(proto, root)
|
1013
998
|
self._value = InitialValue()
|
1014
999
|
self.type = "selectbox"
|
@@ -1029,10 +1014,9 @@ class Selectbox(Widget, Generic[T]):
|
|
1029
1014
|
"""The currently selected value from the options. (Any)""" # noqa: D400
|
1030
1015
|
if not isinstance(self._value, InitialValue):
|
1031
1016
|
return self._value
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
return cast("T", state[self.id])
|
1017
|
+
state = self.root.session_state
|
1018
|
+
assert state
|
1019
|
+
return cast("T", state[self.id])
|
1036
1020
|
|
1037
1021
|
@property
|
1038
1022
|
def format_func(self) -> Callable[[Any], Any]:
|
@@ -1081,7 +1065,7 @@ class SelectSlider(Widget, Generic[T]):
|
|
1081
1065
|
help: str
|
1082
1066
|
form_id: str
|
1083
1067
|
|
1084
|
-
def __init__(self, proto: SliderProto, root: ElementTree):
|
1068
|
+
def __init__(self, proto: SliderProto, root: ElementTree) -> None:
|
1085
1069
|
super().__init__(proto, root)
|
1086
1070
|
self.type = "select_slider"
|
1087
1071
|
self.options = list(proto.options)
|
@@ -1112,11 +1096,10 @@ class SelectSlider(Widget, Generic[T]):
|
|
1112
1096
|
"""The currently selected value or range. (Any or Sequence of Any)""" # noqa: D400
|
1113
1097
|
if self._value is not None:
|
1114
1098
|
return self._value
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
return state[self.id] # type: ignore
|
1099
|
+
state = self.root.session_state
|
1100
|
+
assert state
|
1101
|
+
# Awkward to do this with `cast`
|
1102
|
+
return state[self.id] # type: ignore
|
1120
1103
|
|
1121
1104
|
@property
|
1122
1105
|
def format_func(self) -> Callable[[Any], Any]:
|
@@ -1144,7 +1127,7 @@ class Slider(Widget, Generic[SliderValueT]):
|
|
1144
1127
|
help: str
|
1145
1128
|
form_id: str
|
1146
1129
|
|
1147
|
-
def __init__(self, proto: SliderProto, root: ElementTree):
|
1130
|
+
def __init__(self, proto: SliderProto, root: ElementTree) -> None:
|
1148
1131
|
super().__init__(proto, root)
|
1149
1132
|
self.type = "slider"
|
1150
1133
|
|
@@ -1171,11 +1154,10 @@ class Slider(Widget, Generic[SliderValueT]):
|
|
1171
1154
|
"""The currently selected value or range. (Any or Sequence of Any)""" # noqa: D400
|
1172
1155
|
if self._value is not None:
|
1173
1156
|
return self._value
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
return state[self.id] # type: ignore
|
1157
|
+
state = self.root.session_state
|
1158
|
+
assert state
|
1159
|
+
# Awkward to do this with `cast`
|
1160
|
+
return state[self.id] # type: ignore
|
1179
1161
|
|
1180
1162
|
def set_range(
|
1181
1163
|
self, lower: SliderValueT, upper: SliderValueT
|
@@ -1188,7 +1170,7 @@ class Slider(Widget, Generic[SliderValueT]):
|
|
1188
1170
|
class Table(Element):
|
1189
1171
|
proto: ArrowProto = field(repr=False)
|
1190
1172
|
|
1191
|
-
def __init__(self, proto: ArrowProto, root: ElementTree):
|
1173
|
+
def __init__(self, proto: ArrowProto, root: ElementTree) -> None:
|
1192
1174
|
self.key = None
|
1193
1175
|
self.proto = proto
|
1194
1176
|
self.root = root
|
@@ -1205,7 +1187,7 @@ class Text(Element):
|
|
1205
1187
|
|
1206
1188
|
key: None = None
|
1207
1189
|
|
1208
|
-
def __init__(self, proto: TextProto, root: ElementTree):
|
1190
|
+
def __init__(self, proto: TextProto, root: ElementTree) -> None:
|
1209
1191
|
self.proto = proto
|
1210
1192
|
self.root = root
|
1211
1193
|
self.type = "text"
|
@@ -1229,7 +1211,7 @@ class TextArea(Widget):
|
|
1229
1211
|
help: str
|
1230
1212
|
form_id: str
|
1231
1213
|
|
1232
|
-
def __init__(self, proto: TextAreaProto, root: ElementTree):
|
1214
|
+
def __init__(self, proto: TextAreaProto, root: ElementTree) -> None:
|
1233
1215
|
super().__init__(proto, root)
|
1234
1216
|
self._value = InitialValue()
|
1235
1217
|
self.type = "text_area"
|
@@ -1252,11 +1234,10 @@ class TextArea(Widget):
|
|
1252
1234
|
"""The current value of the widget. (str)""" # noqa: D400
|
1253
1235
|
if not isinstance(self._value, InitialValue):
|
1254
1236
|
return self._value
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
return state[self.id] # type: ignore
|
1237
|
+
state = self.root.session_state
|
1238
|
+
assert state
|
1239
|
+
# Awkward to do this with `cast`
|
1240
|
+
return state[self.id] # type: ignore
|
1260
1241
|
|
1261
1242
|
def input(self, v: str) -> TextArea:
|
1262
1243
|
"""
|
@@ -1282,7 +1263,7 @@ class TextInput(Widget):
|
|
1282
1263
|
help: str
|
1283
1264
|
form_id: str
|
1284
1265
|
|
1285
|
-
def __init__(self, proto: TextInputProto, root: ElementTree):
|
1266
|
+
def __init__(self, proto: TextInputProto, root: ElementTree) -> None:
|
1286
1267
|
super().__init__(proto, root)
|
1287
1268
|
self._value = InitialValue()
|
1288
1269
|
self.type = "text_input"
|
@@ -1305,11 +1286,10 @@ class TextInput(Widget):
|
|
1305
1286
|
"""The current value of the widget. (str)""" # noqa: D400
|
1306
1287
|
if not isinstance(self._value, InitialValue):
|
1307
1288
|
return self._value
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
return state[self.id] # type: ignore
|
1289
|
+
state = self.root.session_state
|
1290
|
+
assert state
|
1291
|
+
# Awkward to do this with `cast`
|
1292
|
+
return state[self.id] # type: ignore
|
1313
1293
|
|
1314
1294
|
def input(self, v: str) -> TextInput:
|
1315
1295
|
"""
|
@@ -1336,7 +1316,7 @@ class TimeInput(Widget):
|
|
1336
1316
|
help: str
|
1337
1317
|
form_id: str
|
1338
1318
|
|
1339
|
-
def __init__(self, proto: TimeInputProto, root: ElementTree):
|
1319
|
+
def __init__(self, proto: TimeInputProto, root: ElementTree) -> None:
|
1340
1320
|
super().__init__(proto, root)
|
1341
1321
|
self._value = InitialValue()
|
1342
1322
|
self.type = "time_input"
|
@@ -1364,10 +1344,9 @@ class TimeInput(Widget):
|
|
1364
1344
|
v = self._value
|
1365
1345
|
v = v.time() if isinstance(v, datetime) else v
|
1366
1346
|
return v
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
return state[self.id] # type: ignore
|
1347
|
+
state = self.root.session_state
|
1348
|
+
assert state
|
1349
|
+
return state[self.id] # type: ignore
|
1371
1350
|
|
1372
1351
|
def increment(self) -> TimeInput:
|
1373
1352
|
"""Select the next available time."""
|
@@ -1389,7 +1368,7 @@ class Toast(Element):
|
|
1389
1368
|
proto: ToastProto = field(repr=False)
|
1390
1369
|
icon: str
|
1391
1370
|
|
1392
|
-
def __init__(self, proto: ToastProto, root: ElementTree):
|
1371
|
+
def __init__(self, proto: ToastProto, root: ElementTree) -> None:
|
1393
1372
|
self.proto = proto
|
1394
1373
|
self.key = None
|
1395
1374
|
self.root = root
|
@@ -1411,7 +1390,7 @@ class Toggle(Widget):
|
|
1411
1390
|
help: str
|
1412
1391
|
form_id: str
|
1413
1392
|
|
1414
|
-
def __init__(self, proto: CheckboxProto, root: ElementTree):
|
1393
|
+
def __init__(self, proto: CheckboxProto, root: ElementTree) -> None:
|
1415
1394
|
super().__init__(proto, root)
|
1416
1395
|
self._value = None
|
1417
1396
|
self.type = "toggle"
|
@@ -1428,10 +1407,9 @@ class Toggle(Widget):
|
|
1428
1407
|
"""The current value of the widget. (bool)""" # noqa: D400
|
1429
1408
|
if self._value is not None:
|
1430
1409
|
return self._value
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
return cast("bool", state[self.id])
|
1410
|
+
state = self.root.session_state
|
1411
|
+
assert state
|
1412
|
+
return cast("bool", state[self.id])
|
1435
1413
|
|
1436
1414
|
def set_value(self, v: bool) -> Toggle:
|
1437
1415
|
"""Set the value of the widget."""
|
@@ -1460,7 +1438,7 @@ class Block:
|
|
1460
1438
|
self,
|
1461
1439
|
proto: BlockProto | None,
|
1462
1440
|
root: ElementTree,
|
1463
|
-
):
|
1441
|
+
) -> None:
|
1464
1442
|
self.children = {}
|
1465
1443
|
self.proto = proto
|
1466
1444
|
if proto:
|
@@ -1665,11 +1643,11 @@ class Block:
|
|
1665
1643
|
"""
|
1666
1644
|
return self.root.run(timeout=timeout)
|
1667
1645
|
|
1668
|
-
def __repr__(self):
|
1646
|
+
def __repr__(self) -> str:
|
1669
1647
|
return repr_(self)
|
1670
1648
|
|
1671
1649
|
|
1672
|
-
def repr_(self) -> str:
|
1650
|
+
def repr_(self: object) -> str:
|
1673
1651
|
"""A custom repr similar to `streamlit.util.repr_` but that shows tree
|
1674
1652
|
structure using indentation.
|
1675
1653
|
"""
|
@@ -1703,7 +1681,7 @@ def repr_(self) -> str:
|
|
1703
1681
|
return f"{classname}({field_reprs}\n)"
|
1704
1682
|
|
1705
1683
|
|
1706
|
-
def format_dict(d: dict[Any, Any]):
|
1684
|
+
def format_dict(d: dict[Any, Any]) -> str:
|
1707
1685
|
lines = []
|
1708
1686
|
for k, v in d.items():
|
1709
1687
|
line = f"{k}: {v!r}"
|
@@ -1723,7 +1701,7 @@ class SpecialBlock(Block):
|
|
1723
1701
|
proto: BlockProto | None,
|
1724
1702
|
root: ElementTree,
|
1725
1703
|
type: str | None = None,
|
1726
|
-
):
|
1704
|
+
) -> None:
|
1727
1705
|
self.children = {}
|
1728
1706
|
self.proto = proto
|
1729
1707
|
if type:
|
@@ -1750,7 +1728,7 @@ class ChatMessage(Block):
|
|
1750
1728
|
self,
|
1751
1729
|
proto: BlockProto.ChatMessage,
|
1752
1730
|
root: ElementTree,
|
1753
|
-
):
|
1731
|
+
) -> None:
|
1754
1732
|
self.children = {}
|
1755
1733
|
self.proto = proto
|
1756
1734
|
self.root = root
|
@@ -1772,7 +1750,7 @@ class Column(Block):
|
|
1772
1750
|
self,
|
1773
1751
|
proto: BlockProto.Column,
|
1774
1752
|
root: ElementTree,
|
1775
|
-
):
|
1753
|
+
) -> None:
|
1776
1754
|
self.children = {}
|
1777
1755
|
self.proto = proto
|
1778
1756
|
self.root = root
|
@@ -1788,7 +1766,7 @@ class Expander(Block):
|
|
1788
1766
|
icon: str
|
1789
1767
|
label: str
|
1790
1768
|
|
1791
|
-
def __init__(self, proto: BlockProto.Expandable, root: ElementTree):
|
1769
|
+
def __init__(self, proto: BlockProto.Expandable, root: ElementTree) -> None:
|
1792
1770
|
self.children = {}
|
1793
1771
|
self.proto = proto
|
1794
1772
|
self.root = root
|
@@ -1806,7 +1784,7 @@ class Status(Block):
|
|
1806
1784
|
icon: str
|
1807
1785
|
label: str
|
1808
1786
|
|
1809
|
-
def __init__(self, proto: BlockProto.Expandable, root: ElementTree):
|
1787
|
+
def __init__(self, proto: BlockProto.Expandable, root: ElementTree) -> None:
|
1810
1788
|
self.children = {}
|
1811
1789
|
self.proto = proto
|
1812
1790
|
self.root = root
|
@@ -1815,15 +1793,14 @@ class Status(Block):
|
|
1815
1793
|
self.label = proto.label
|
1816
1794
|
|
1817
1795
|
@property
|
1818
|
-
def state(self):
|
1796
|
+
def state(self) -> str:
|
1819
1797
|
if self.icon == "spinner":
|
1820
1798
|
return "running"
|
1821
|
-
|
1799
|
+
if self.icon == ":material/check:":
|
1822
1800
|
return "complete"
|
1823
|
-
|
1801
|
+
if self.icon == ":material/error:":
|
1824
1802
|
return "error"
|
1825
|
-
|
1826
|
-
raise ValueError("Unknown Status state")
|
1803
|
+
raise ValueError("Unknown Status state")
|
1827
1804
|
|
1828
1805
|
|
1829
1806
|
@dataclass(repr=False)
|
@@ -1838,7 +1815,7 @@ class Tab(Block):
|
|
1838
1815
|
self,
|
1839
1816
|
proto: BlockProto.Tab,
|
1840
1817
|
root: ElementTree,
|
1841
|
-
):
|
1818
|
+
) -> None:
|
1842
1819
|
self.children = {}
|
1843
1820
|
self.proto = proto
|
1844
1821
|
self.root = root
|
@@ -1852,8 +1829,7 @@ Node: TypeAlias = Union[Element, Block]
|
|
1852
1829
|
def get_widget_state(node: Node) -> WidgetState | None:
|
1853
1830
|
if isinstance(node, Widget):
|
1854
1831
|
return node._widget_state
|
1855
|
-
|
1856
|
-
return None
|
1832
|
+
return None
|
1857
1833
|
|
1858
1834
|
|
1859
1835
|
@dataclass(repr=False)
|
@@ -1928,7 +1904,7 @@ class ElementTree(Block):
|
|
1928
1904
|
widget_states = self.get_widget_states()
|
1929
1905
|
return self._runner._run(widget_states, timeout=timeout)
|
1930
1906
|
|
1931
|
-
def __repr__(self):
|
1907
|
+
def __repr__(self) -> str:
|
1932
1908
|
return format_dict(self.children)
|
1933
1909
|
|
1934
1910
|
|