streamlit-nightly 1.45.1.dev20250507__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 +84 -48
- streamlit/config_option.py +2 -2
- streamlit/config_util.py +20 -12
- 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/deck_gl_json_chart.py +30 -17
- 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/map.py +20 -15
- 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/DeckGlJsonChart_pb2.pyi +1 -1
- 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.BgsGCsV4.js → ErrorOutline.esm.C-0hf1-k.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.CCKezPn5.js → FileDownload.esm.B-fFGI-X.js} +1 -1
- streamlit/static/static/js/{FileHelper.CprSF_kT.js → FileHelper.ACYo0OZo.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.DiwQ0EtT.js → FormClearHelper.CVNTT-bJ.js} +1 -1
- streamlit/static/static/js/{Hooks.DDqhyZ1_.js → Hooks.C3thlpd2.js} +1 -1
- streamlit/static/static/js/{InputInstructions.BCEZxme4.js → InputInstructions.CwAxousX.js} +1 -1
- streamlit/static/static/js/{ProgressBar.CGdY94g_.js → ProgressBar.xh599Rum.js} +2 -2
- streamlit/static/static/js/{RenderInPortalIfExists.uGJp_Q0v.js → RenderInPortalIfExists.CQLIsNPE.js} +1 -1
- streamlit/static/static/js/{Toolbar.hTlw0-K1.js → Toolbar.LKdyvP0u.js} +1 -1
- streamlit/static/static/js/{index.xsH4HHeE.js → UploadFileInfo.0DCkpDDf.js} +5 -5
- streamlit/static/static/js/{base-input.mGTY3-qU.js → base-input.D8OdS4WW.js} +4 -4
- streamlit/static/static/js/{checkbox.Cg-5cKAh.js → checkbox.DSdYKlOI.js} +2 -2
- streamlit/static/static/js/{createSuper.-HPb1oYT.js → createSuper.B2pyCfWw.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.BpNYxiTp.js → data-grid-overlay-editor.DhO2r0ne.js} +1 -1
- streamlit/static/static/js/{downloader.DS9891pS.js → downloader.C24skoDM.js} +1 -1
- streamlit/static/static/js/{es6.CU1PEL2w.js → es6.DHkvCKPh.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.CgJE2bJN.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.BC0ueJ8H.js → index.B5EFweZ4.js} +1 -1
- streamlit/static/static/js/{index.CyGuL4If.js → index.BAafqHfB.js} +2 -2
- streamlit/static/static/js/{index.DWV80Vyw.js → index.BHTbGZPQ.js} +1 -1
- streamlit/static/static/js/index.BNXtQAj4.js +1 -0
- streamlit/static/static/js/index.BRhKaVdO.js +1 -0
- streamlit/static/static/js/index.BSOiJVQd.js +2 -0
- streamlit/static/static/js/{index.GSYBrzVp.js → index.BVgTQbOJ.js} +1 -1
- streamlit/static/static/js/{index.BTTj6ld4.js → index.BflIniLm.js} +1 -1
- streamlit/static/static/js/{index.DLTqo4pp.js → index.BjeNtZIz.js} +3 -3
- streamlit/static/static/js/{index.DZ6oX-v9.js → index.By-NmdnB.js} +161 -161
- streamlit/static/static/js/{index.DVpzZJNg.js → index.CIoOEhZ2.js} +1 -1
- streamlit/static/static/js/{index.CN91oQMB.js → index.CRCdonis.js} +36 -36
- streamlit/static/static/js/index.CRxaBCJ7.js +1 -0
- streamlit/static/static/js/index.CU-pbYVN.js +1 -0
- streamlit/static/static/js/{index.CzGUd4IN.js → index.CUsk52t2.js} +1 -1
- streamlit/static/static/js/{index.BHVQ94t4.js → index.CVO14oQG.js} +2 -2
- streamlit/static/static/js/index.CXFuA6J-.js +1 -0
- streamlit/static/static/js/{index.DJHUlWgy.js → index.C_dd5q7u.js} +1 -1
- streamlit/static/static/js/{index.Bph6ZoI5.js → index.CjWUnKIN.js} +1 -1
- streamlit/static/static/js/{index.B209tswL.js → index.CkTL9bAR.js} +256 -256
- streamlit/static/static/js/{index.ErkF0SoX.js → index.CsbhsAPy.js} +2 -2
- streamlit/static/static/js/{index.hPjr68pz.js → index.CtCnBUtk.js} +1 -1
- streamlit/static/static/js/{index.BT0p7gAu.js → index.CwuKadAX.js} +1 -1
- streamlit/static/static/js/{index.CtoDsUtq.js → index.D0R7Xh4Z.js} +1 -1
- streamlit/static/static/js/index.D2D75EDw.js +73 -0
- streamlit/static/static/js/index.D4eMiZ1F.js +1 -0
- streamlit/static/static/js/{index.Dh4RKl-F.js → index.D7SCC3z9.js} +1 -1
- streamlit/static/static/js/index.DZiilxEt.js +1 -0
- streamlit/static/static/js/{index.DtqvdV-p.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.CvFsF3FD.js → index.gFjPlsMT.js} +1 -1
- streamlit/static/static/js/{index.DPJBu2uZ.js → index.jCJYMVED.js} +1 -1
- streamlit/static/static/js/index.xldt56AE.js +1 -0
- streamlit/static/static/js/{index.Bb-Ukg41.js → index.yzoj_DuM.js} +1 -1
- streamlit/static/static/js/{input.DY17i94N.js → input.BP6LX_Bg.js} +2 -2
- streamlit/static/static/js/{memory.DsIIcbSd.js → memory.E9x2ZYJv.js} +1 -1
- streamlit/static/static/js/{mergeWith.cRgGdgvI.js → mergeWith.CZP2AaVS.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.B8Xi2dYq.js → number-overlay-editor.D-Kl79U_.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.BgDi5nUm.js → possibleConstructorReturn.P2ILVC_6.js} +1 -1
- streamlit/static/static/js/{sandbox.BH9emp13.js → sandbox.DfzJIGMV.js} +1 -1
- streamlit/static/static/js/{textarea.DAyShsGG.js → textarea.4PjzfDWF.js} +2 -2
- streamlit/static/static/js/{timepicker.CCH2R2Y0.js → timepicker.DMQdaNzO.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CNffSDCu.js → toConsumableArray.BEdkbHYx.js} +1 -1
- streamlit/static/static/js/{uniqueId.B49CstkV.js → uniqueId.CAs7ftHC.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.CkThOkF9.js → useBasicWidgetState.Cedp0V76.js} +1 -1
- streamlit/static/static/js/useOnInputChange.CvRKHHKx.js +1 -0
- streamlit/static/static/js/{withFullScreenWrapper.UsvF_Jwr.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/bootstrap.py +2 -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 +9 -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.dev20250507.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.45.1.dev20250507.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/RECORD +187 -184
- {streamlit_nightly-1.45.1.dev20250507.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/UploadFileInfo.C-jY39rj.js +0 -1
- streamlit/static/static/js/index.BVjgrQ4R.js +0 -1
- streamlit/static/static/js/index.BXYstdPh.js +0 -2
- streamlit/static/static/js/index.BZ9mqzEJ.js +0 -1
- streamlit/static/static/js/index.BhTok8vt.js +0 -1
- streamlit/static/static/js/index.CJPcdxPe.js +0 -1
- streamlit/static/static/js/index.CMOA-8Q2.js +0 -1
- streamlit/static/static/js/index.DAxf3_iz.js +0 -1
- streamlit/static/static/js/index.Dn76KVNf.js +0 -1
- streamlit/static/static/js/index.OngWTN39.js +0 -1
- streamlit/static/static/js/index.PSwG8ayC.js +0 -1
- streamlit/static/static/js/index.UTlCdasa.js +0 -73
- streamlit/static/static/js/index.eR_vQpeg.js +0 -1
- streamlit/static/static/js/index.fLsU9uCJ.js +0 -1
- streamlit/static/static/js/index.kXOZCC_6.js +0 -1
- streamlit/static/static/js/useOnInputChange.BqEq0xFZ.js +0 -1
- {streamlit_nightly-1.45.1.dev20250507.data → streamlit_nightly-1.45.1.dev20250509.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.45.1.dev20250507.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.45.1.dev20250507.dist-info → streamlit_nightly-1.45.1.dev20250509.dist-info}/top_level.txt +0 -0
@@ -15,7 +15,7 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import sys
|
18
|
-
from typing import TYPE_CHECKING, Any, Callable
|
18
|
+
from typing import TYPE_CHECKING, Any, Callable, Literal
|
19
19
|
|
20
20
|
from streamlit import util
|
21
21
|
from streamlit.delta_generator_singletons import (
|
@@ -30,6 +30,8 @@ from streamlit.runtime.scriptrunner_utils.exceptions import (
|
|
30
30
|
)
|
31
31
|
|
32
32
|
if TYPE_CHECKING:
|
33
|
+
from types import TracebackType
|
34
|
+
|
33
35
|
from streamlit.runtime.scriptrunner_utils.script_requests import RerunData
|
34
36
|
from streamlit.runtime.scriptrunner_utils.script_run_context import ScriptRunContext
|
35
37
|
|
@@ -41,7 +43,7 @@ class modified_sys_path: # noqa: N801
|
|
41
43
|
Source: https://github.com/ipython/ipython/blob/master/IPython/utils/syspathcontext.py#L42
|
42
44
|
"""
|
43
45
|
|
44
|
-
def __init__(self, main_script_path: str):
|
46
|
+
def __init__(self, main_script_path: str) -> None:
|
45
47
|
self._main_script_path = main_script_path
|
46
48
|
self._added_path = False
|
47
49
|
|
@@ -53,7 +55,12 @@ class modified_sys_path: # noqa: N801
|
|
53
55
|
sys.path.insert(0, self._main_script_path)
|
54
56
|
self._added_path = True
|
55
57
|
|
56
|
-
def __exit__(
|
58
|
+
def __exit__(
|
59
|
+
self,
|
60
|
+
typ: type[BaseException] | None,
|
61
|
+
exc: BaseException | None,
|
62
|
+
tb: TracebackType | None,
|
63
|
+
) -> Literal[False]:
|
57
64
|
if self._added_path:
|
58
65
|
try:
|
59
66
|
sys.path.remove(self._main_script_path)
|
@@ -58,7 +58,7 @@ def _modify_ast_subtree(
|
|
58
58
|
body_attr: str = "body",
|
59
59
|
is_root: bool = False,
|
60
60
|
file_ends_in_semicolon: bool = False,
|
61
|
-
):
|
61
|
+
) -> None:
|
62
62
|
"""Parses magic commands and modifies the given AST (sub)tree."""
|
63
63
|
|
64
64
|
body = getattr(tree, body_attr)
|
@@ -161,7 +161,7 @@ def _insert_import_statement(tree: Any) -> None:
|
|
161
161
|
tree.body.insert(0, st_import)
|
162
162
|
|
163
163
|
|
164
|
-
def _build_st_import_statement():
|
164
|
+
def _build_st_import_statement() -> ast.Import:
|
165
165
|
"""Build AST node for `import magic_funcs as __streamlitmagic__`."""
|
166
166
|
return ast.Import(
|
167
167
|
names=[
|
@@ -173,7 +173,7 @@ def _build_st_import_statement():
|
|
173
173
|
)
|
174
174
|
|
175
175
|
|
176
|
-
def _build_st_write_call(nodes):
|
176
|
+
def _build_st_write_call(nodes: list[Any]) -> ast.Call:
|
177
177
|
"""Build AST node for `__streamlitmagic__.transparent_write(*nodes)`."""
|
178
178
|
return ast.Call(
|
179
179
|
func=ast.Attribute(
|
@@ -187,8 +187,13 @@ def _build_st_write_call(nodes):
|
|
187
187
|
|
188
188
|
|
189
189
|
def _get_st_write_from_expr(
|
190
|
-
node
|
191
|
-
|
190
|
+
node: Any,
|
191
|
+
i: int,
|
192
|
+
parent_type: Any,
|
193
|
+
is_root: bool,
|
194
|
+
is_last_expr: bool,
|
195
|
+
file_ends_in_semicolon: bool,
|
196
|
+
) -> ast.Call | None:
|
192
197
|
# Don't wrap function calls
|
193
198
|
# (Unless the function call happened at the end of the root node, AND
|
194
199
|
# magic.displayLastExprIfNoSemicolon is True. This allows us to support notebook-like
|
@@ -222,11 +227,11 @@ def _get_st_write_from_expr(
|
|
222
227
|
return _build_st_write_call(args)
|
223
228
|
|
224
229
|
|
225
|
-
def _is_string_constant_node(node) -> bool:
|
230
|
+
def _is_string_constant_node(node: Any) -> bool:
|
226
231
|
return isinstance(node, ast.Constant) and isinstance(node.value, str)
|
227
232
|
|
228
233
|
|
229
|
-
def _is_docstring_node(node, node_index, parent_type) -> bool:
|
234
|
+
def _is_docstring_node(node: Any, node_index: int, parent_type: Any) -> bool:
|
230
235
|
return (
|
231
236
|
node_index == 0
|
232
237
|
and _is_string_constant_node(node)
|
@@ -234,7 +239,7 @@ def _is_docstring_node(node, node_index, parent_type) -> bool:
|
|
234
239
|
)
|
235
240
|
|
236
241
|
|
237
|
-
def _does_file_end_in_semicolon(tree, code: str) -> bool:
|
242
|
+
def _does_file_end_in_semicolon(tree: Any, code: str) -> bool:
|
238
243
|
file_ends_in_semicolon = False
|
239
244
|
|
240
245
|
# Avoid spending time with this operation if magic.displayLastExprIfNoSemicolon is
|
@@ -121,7 +121,7 @@ it in the future.
|
|
121
121
|
# is designed to leverage our original v1 version of multi-page apps. This
|
122
122
|
# function will be called to run the script in lieu of the main script. This
|
123
123
|
# function simulates the v1 setup using the modern v2 commands (st.navigation)
|
124
|
-
def _mpa_v1(main_script_path: str):
|
124
|
+
def _mpa_v1(main_script_path: str) -> None:
|
125
125
|
from pathlib import Path
|
126
126
|
|
127
127
|
from streamlit.commands.navigation import PageType, _navigation
|
@@ -176,7 +176,7 @@ class ScriptRunner:
|
|
176
176
|
user_info: dict[str, str | bool | None],
|
177
177
|
fragment_storage: FragmentStorage,
|
178
178
|
pages_manager: PagesManager,
|
179
|
-
):
|
179
|
+
) -> None:
|
180
180
|
"""Initialize the ScriptRunner.
|
181
181
|
|
182
182
|
(The ScriptRunner won't start executing until start() is called.)
|
@@ -34,7 +34,7 @@ class StopException(ScriptControlException):
|
|
34
34
|
class RerunException(ScriptControlException):
|
35
35
|
"""Silently stop and rerun the user's script."""
|
36
36
|
|
37
|
-
def __init__(self, rerun_data: RerunData):
|
37
|
+
def __init__(self, rerun_data: RerunData) -> None:
|
38
38
|
"""Construct a RerunException.
|
39
39
|
|
40
40
|
Parameters
|
@@ -42,6 +42,7 @@ from streamlit.runtime.forward_msg_cache import (
|
|
42
42
|
)
|
43
43
|
|
44
44
|
if TYPE_CHECKING:
|
45
|
+
from collections.abc import Generator
|
45
46
|
from pathlib import Path
|
46
47
|
|
47
48
|
from streamlit.cursor import RunningCursor
|
@@ -117,11 +118,11 @@ class ScriptRunContext:
|
|
117
118
|
_production_query_params_used = False
|
118
119
|
|
119
120
|
@property
|
120
|
-
def page_script_hash(self):
|
121
|
+
def page_script_hash(self) -> str:
|
121
122
|
return self.pages_manager.current_page_script_hash
|
122
123
|
|
123
124
|
@property
|
124
|
-
def active_script_hash(self):
|
125
|
+
def active_script_hash(self) -> str:
|
125
126
|
return self._active_script_hash
|
126
127
|
|
127
128
|
@property
|
@@ -129,7 +130,7 @@ class ScriptRunContext:
|
|
129
130
|
return self.pages_manager.main_script_parent
|
130
131
|
|
131
132
|
@contextlib.contextmanager
|
132
|
-
def run_with_active_hash(self, page_hash: str):
|
133
|
+
def run_with_active_hash(self, page_hash: str) -> Generator[None, None, None]:
|
133
134
|
original_page_hash = self._active_script_hash
|
134
135
|
self._active_script_hash = page_hash
|
135
136
|
try:
|
@@ -138,7 +139,7 @@ class ScriptRunContext:
|
|
138
139
|
# in the event of any exception, ensure we set the active hash back
|
139
140
|
self._active_script_hash = original_page_hash
|
140
141
|
|
141
|
-
def set_mpa_v2_page(self, page_script_hash: str):
|
142
|
+
def set_mpa_v2_page(self, page_script_hash: str) -> None:
|
142
143
|
self._active_script_hash = self.pages_manager.main_script_hash
|
143
144
|
self.pages_manager.set_current_page_script_hash(page_script_hash)
|
144
145
|
|
@@ -240,7 +241,7 @@ SCRIPT_RUN_CONTEXT_ATTR_NAME: Final = "streamlit_script_run_ctx"
|
|
240
241
|
|
241
242
|
def add_script_run_ctx(
|
242
243
|
thread: threading.Thread | None = None, ctx: ScriptRunContext | None = None
|
243
|
-
):
|
244
|
+
) -> threading.Thread:
|
244
245
|
"""Adds the current ScriptRunContext to a newly-created thread.
|
245
246
|
|
246
247
|
This should be called from this thread's parent thread,
|
streamlit/runtime/secrets.py
CHANGED
@@ -152,11 +152,10 @@ class AttrDict(Mapping[str, Any]):
|
|
152
152
|
self.__dict__["__nested_secrets__"] = dict(value)
|
153
153
|
|
154
154
|
@staticmethod
|
155
|
-
def _maybe_wrap_in_attr_dict(value) -> Any:
|
155
|
+
def _maybe_wrap_in_attr_dict(value: Any) -> Any:
|
156
156
|
if not isinstance(value, Mapping):
|
157
157
|
return value
|
158
|
-
|
159
|
-
return AttrDict(value)
|
158
|
+
return AttrDict(value)
|
160
159
|
|
161
160
|
def __len__(self) -> int:
|
162
161
|
return len(self.__nested_secrets__)
|
@@ -178,13 +177,13 @@ class AttrDict(Mapping[str, Any]):
|
|
178
177
|
except KeyError:
|
179
178
|
raise AttributeError(_missing_attr_error_message(attr_name))
|
180
179
|
|
181
|
-
def __repr__(self):
|
180
|
+
def __repr__(self) -> str:
|
182
181
|
return repr(self.__nested_secrets__)
|
183
182
|
|
184
|
-
def __setitem__(self, key, value) -> NoReturn:
|
183
|
+
def __setitem__(self, key: str, value: Any) -> NoReturn:
|
185
184
|
raise TypeError("Secrets does not support item assignment.")
|
186
185
|
|
187
|
-
def __setattr__(self, key, value) -> NoReturn:
|
186
|
+
def __setattr__(self, key: str, value: Any) -> NoReturn:
|
188
187
|
raise TypeError("Secrets does not support attribute assignment.")
|
189
188
|
|
190
189
|
def to_dict(self) -> dict[str, Any]:
|
@@ -439,7 +438,7 @@ class Secrets(Mapping[str, Any]):
|
|
439
438
|
# failed to avoid repeatedly trying to install it.
|
440
439
|
self._file_watchers_installed = True
|
441
440
|
|
442
|
-
def _on_secrets_changed(self, changed_file_path) -> None:
|
441
|
+
def _on_secrets_changed(self, changed_file_path: str) -> None:
|
443
442
|
with self._lock:
|
444
443
|
_LOGGER.debug("Secret path %s changed, reloading", changed_file_path)
|
445
444
|
self._reset()
|
@@ -459,8 +458,7 @@ class Secrets(Mapping[str, Any]):
|
|
459
458
|
value = self._parse()[key]
|
460
459
|
if not isinstance(value, Mapping):
|
461
460
|
return value
|
462
|
-
|
463
|
-
return AttrDict(value)
|
461
|
+
return AttrDict(value)
|
464
462
|
# We add FileNotFoundError since __getattr__ is expected to only raise
|
465
463
|
# AttributeError. Without handling FileNotFoundError, unittests.mocks
|
466
464
|
# fails during mock creation on Python3.9
|
@@ -477,8 +475,7 @@ class Secrets(Mapping[str, Any]):
|
|
477
475
|
value = self._parse()[key]
|
478
476
|
if not isinstance(value, Mapping):
|
479
477
|
return value
|
480
|
-
|
481
|
-
return AttrDict(value)
|
478
|
+
return AttrDict(value)
|
482
479
|
except KeyError:
|
483
480
|
raise KeyError(_missing_key_error_message(key))
|
484
481
|
|
@@ -111,7 +111,7 @@ class QueryParams(MutableMapping[str, str]):
|
|
111
111
|
| SupportsKeysAndGetItem[str, str | Iterable[str]] = (),
|
112
112
|
/,
|
113
113
|
**kwds: str,
|
114
|
-
):
|
114
|
+
) -> None:
|
115
115
|
# This overrides the `update` provided by MutableMapping
|
116
116
|
# to ensure only one one ForwardMsg is sent.
|
117
117
|
self._ensure_single_query_api_used()
|
@@ -173,7 +173,7 @@ class QueryParams(MutableMapping[str, str]):
|
|
173
173
|
self,
|
174
174
|
_dict: Iterable[tuple[str, str | Iterable[str]]]
|
175
175
|
| SupportsKeysAndGetItem[str, str | Iterable[str]],
|
176
|
-
):
|
176
|
+
) -> None:
|
177
177
|
self._ensure_single_query_api_used()
|
178
178
|
old_value = self._query_params.copy()
|
179
179
|
self.clear_with_no_forward_msg(preserve_embed=True)
|
@@ -42,7 +42,7 @@ class SafeSessionState:
|
|
42
42
|
_lock: threading.RLock
|
43
43
|
_yield_callback: Callable[[], None]
|
44
44
|
|
45
|
-
def __init__(self, state: SessionState, yield_callback: Callable[[], None]):
|
45
|
+
def __init__(self, state: SessionState, yield_callback: Callable[[], None]) -> None:
|
46
46
|
# Fields must be set using the object's setattr method to avoid
|
47
47
|
# infinite recursion from trying to look up the fields we're setting.
|
48
48
|
object.__setattr__(self, "_state", state)
|
@@ -125,7 +125,7 @@ class SafeSessionState:
|
|
125
125
|
except KeyError:
|
126
126
|
raise AttributeError(f"{key} not found in session_state.")
|
127
127
|
|
128
|
-
def __repr__(self):
|
128
|
+
def __repr__(self) -> str:
|
129
129
|
"""Presents itself as a simple dict of the underlying SessionState instance."""
|
130
130
|
kv = ((k, self._state[k]) for k in self._state._keys())
|
131
131
|
s = ", ".join(f"{k}: {v!r}" for k, v in kv)
|
@@ -84,7 +84,7 @@ class WStates(MutableMapping[str, Any]):
|
|
84
84
|
states: dict[str, WState] = field(default_factory=dict)
|
85
85
|
widget_metadata: dict[str, WidgetMetadata[Any]] = field(default_factory=dict)
|
86
86
|
|
87
|
-
def __repr__(self):
|
87
|
+
def __repr__(self) -> str:
|
88
88
|
return util.repr_(self)
|
89
89
|
|
90
90
|
def __getitem__(self, k: str) -> Any:
|
@@ -123,7 +123,7 @@ class WStates(MutableMapping[str, Any]):
|
|
123
123
|
# Array types are messages with data in a `data` field
|
124
124
|
value = value.data
|
125
125
|
elif value_field_name == "json_value":
|
126
|
-
value = json.loads(value)
|
126
|
+
value = json.loads(cast("str", value))
|
127
127
|
|
128
128
|
deserialized = metadata.deserializer(value)
|
129
129
|
|
@@ -330,7 +330,7 @@ class KeyIdMapper:
|
|
330
330
|
self._key_id_mapping.clear()
|
331
331
|
self._id_key_mapping.clear()
|
332
332
|
|
333
|
-
def delete(self, key: str):
|
333
|
+
def delete(self, key: str) -> None:
|
334
334
|
widget_id = self._key_id_mapping[key]
|
335
335
|
del self._key_id_mapping[key]
|
336
336
|
del self._id_key_mapping[widget_id]
|
@@ -371,7 +371,7 @@ class SessionState:
|
|
371
371
|
# widget state at one point.
|
372
372
|
query_params: QueryParams = field(default_factory=QueryParams)
|
373
373
|
|
374
|
-
def __repr__(self):
|
374
|
+
def __repr__(self) -> str:
|
375
375
|
return util.repr_(self)
|
376
376
|
|
377
377
|
# is it possible for a value to get through this without being deserialized?
|
@@ -609,9 +609,10 @@ class SessionState:
|
|
609
609
|
if metadata is not None:
|
610
610
|
if metadata.value_type == "trigger_value":
|
611
611
|
self._new_widget_state[state_id] = Value(False)
|
612
|
-
elif metadata.value_type
|
613
|
-
|
614
|
-
|
612
|
+
elif metadata.value_type in {
|
613
|
+
"string_trigger_value",
|
614
|
+
"chat_input_value",
|
615
|
+
}:
|
615
616
|
self._new_widget_state[state_id] = Value(None)
|
616
617
|
|
617
618
|
for state_id in self._old_state:
|
@@ -619,9 +620,10 @@ class SessionState:
|
|
619
620
|
if metadata is not None:
|
620
621
|
if metadata.value_type == "trigger_value":
|
621
622
|
self._old_state[state_id] = False
|
622
|
-
elif metadata.value_type
|
623
|
-
|
624
|
-
|
623
|
+
elif metadata.value_type in {
|
624
|
+
"string_trigger_value",
|
625
|
+
"chat_input_value",
|
626
|
+
}:
|
625
627
|
self._old_state[state_id] = None
|
626
628
|
|
627
629
|
def _remove_stale_widgets(self, active_widget_ids: set[str]) -> None:
|
@@ -762,14 +764,14 @@ def _is_stale_widget(
|
|
762
764
|
) -> bool:
|
763
765
|
if not metadata:
|
764
766
|
return True
|
765
|
-
|
766
|
-
return False
|
767
|
+
|
767
768
|
# If we're running 1 or more fragments, but this widget is unrelated to any of the
|
768
769
|
# fragments that we're running, then it should not be marked as stale as its value
|
769
770
|
# may still be needed for a future fragment run or full script run.
|
770
|
-
|
771
|
-
|
772
|
-
|
771
|
+
return not (
|
772
|
+
metadata.id in active_widget_ids
|
773
|
+
or (fragment_ids_this_run and metadata.fragment_id not in fragment_ids_this_run)
|
774
|
+
)
|
773
775
|
|
774
776
|
|
775
777
|
@dataclass
|
streamlit/runtime/stats.py
CHANGED
@@ -63,7 +63,7 @@ class CacheStat(NamedTuple):
|
|
63
63
|
def group_stats(stats: list[CacheStat]) -> list[CacheStat]:
|
64
64
|
"""Group a list of CacheStats by category_name and cache_name and sum byte_length."""
|
65
65
|
|
66
|
-
def key_function(individual_stat):
|
66
|
+
def key_function(individual_stat: CacheStat) -> tuple[str, str]:
|
67
67
|
return individual_stat.category_name, individual_stat.cache_name
|
68
68
|
|
69
69
|
result: list[CacheStat] = []
|
@@ -65,7 +65,7 @@ class UploadedFile(io.BytesIO):
|
|
65
65
|
initialized with `bytes`.
|
66
66
|
"""
|
67
67
|
|
68
|
-
def __init__(self, record: UploadedFileRec, file_urls: FileURLsProto):
|
68
|
+
def __init__(self, record: UploadedFileRec, file_urls: FileURLsProto) -> None:
|
69
69
|
# BytesIO's copy-on-write semantics doesn't seem to be mentioned in
|
70
70
|
# the Python docs - possibly because it's a CPython-only optimization
|
71
71
|
# and not guaranteed to be in other Python runtimes. But it's detailed
|
streamlit/source_util.py
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import re
|
18
|
-
from typing import TYPE_CHECKING, TypedDict
|
18
|
+
from typing import TYPE_CHECKING, TextIO, TypedDict
|
19
19
|
|
20
20
|
from typing_extensions import NotRequired, TypeAlias
|
21
21
|
|
@@ -38,7 +38,7 @@ class PageInfo(TypedDict):
|
|
38
38
|
url_pathname: NotRequired[str]
|
39
39
|
|
40
40
|
|
41
|
-
def open_python_file(filename: str):
|
41
|
+
def open_python_file(filename: str) -> TextIO:
|
42
42
|
"""Open a read-only Python file taking proper care of its encoding.
|
43
43
|
|
44
44
|
In Python 3, we would like all files to be opened with utf-8 encoding.
|
@@ -52,8 +52,7 @@ def open_python_file(filename: str):
|
|
52
52
|
# Open file respecting PEP263 encoding. If no encoding header is
|
53
53
|
# found, opens as utf-8.
|
54
54
|
return tokenize.open(filename)
|
55
|
-
|
56
|
-
return open(filename, encoding="utf-8")
|
55
|
+
return open(filename, encoding="utf-8")
|
57
56
|
|
58
57
|
|
59
58
|
PAGE_FILENAME_REGEX = re.compile(r"([0-9]*)[_ -]*(.*)\.py")
|
streamlit/static/index.html
CHANGED
@@ -51,7 +51,7 @@
|
|
51
51
|
<script>
|
52
52
|
window.prerenderReady = false
|
53
53
|
</script>
|
54
|
-
<script type="module" crossorigin src="./static/js/index.
|
54
|
+
<script type="module" crossorigin src="./static/js/index.By-NmdnB.js"></script>
|
55
55
|
<link rel="stylesheet" crossorigin href="./static/css/index.C6rq3aMZ.css">
|
56
56
|
</head>
|
57
57
|
<body>
|
@@ -1 +1 @@
|
|
1
|
-
import{r,E as a,_ as n}from"./index.
|
1
|
+
import{r,E as a,_ as n}from"./index.By-NmdnB.js";var i=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(a,n({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});i.displayName="ErrorOutline";export{i as E};
|
@@ -1 +1 @@
|
|
1
|
-
import{r as e,E as n,_ as a}from"./index.
|
1
|
+
import{r as e,E as n,_ as a}from"./index.By-NmdnB.js";var o=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),e.createElement("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}))});o.displayName="Delete";var i=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("rect",{width:24,height:24,fill:"none"}),e.createElement("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4l-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}))});i.displayName="FileDownload";export{o as D,i as F};
|