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
@@ -126,7 +126,7 @@ _NON_EXISTENT_COLUMN_NAME: Final = "DOES_NOT_EXIST" + _PROTECTION_SUFFIX
|
|
126
126
|
|
127
127
|
def maybe_raise_stack_warning(
|
128
128
|
stack: bool | ChartStackType | None, command: str | None, docs_link: str
|
129
|
-
):
|
129
|
+
) -> None:
|
130
130
|
# Check that the stack parameter is valid, raise more informative error if not
|
131
131
|
if stack not in (None, True, False, "normalize", "center", "layered"):
|
132
132
|
raise StreamlitAPIException(
|
@@ -373,7 +373,7 @@ def _infer_vegalite_type(
|
|
373
373
|
]:
|
374
374
|
return "quantitative"
|
375
375
|
|
376
|
-
|
376
|
+
if typ == "categorical" and data.cat.ordered:
|
377
377
|
# The original code returns a tuple here:
|
378
378
|
# return ("ordinal", data.cat.categories.tolist()) # noqa: ERA001
|
379
379
|
# But returning the tuple here isn't compatible with our
|
@@ -381,9 +381,9 @@ def _infer_vegalite_type(
|
|
381
381
|
# Altair already extracts the correct sort order somewhere else.
|
382
382
|
# More info about the issue here: https://github.com/streamlit/streamlit/issues/7776
|
383
383
|
return "ordinal"
|
384
|
-
|
384
|
+
if typ in ["string", "bytes", "categorical", "boolean", "mixed", "unicode"]:
|
385
385
|
return "nominal"
|
386
|
-
|
386
|
+
if typ in [
|
387
387
|
"datetime",
|
388
388
|
"datetime64",
|
389
389
|
"timedelta",
|
@@ -393,14 +393,13 @@ def _infer_vegalite_type(
|
|
393
393
|
"period",
|
394
394
|
]:
|
395
395
|
return "temporal"
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
return "nominal"
|
396
|
+
# STREAMLIT MOD: I commented this out since Streamlit doesn't use warnings.warn.
|
397
|
+
# > warnings.warn(
|
398
|
+
# > "I don't know how to infer vegalite type from '{}'. "
|
399
|
+
# > "Defaulting to nominal.".format(typ),
|
400
|
+
# > stacklevel=1,
|
401
|
+
# > )
|
402
|
+
return "nominal"
|
404
403
|
|
405
404
|
|
406
405
|
def _get_pandas_index_attr(
|
@@ -610,7 +609,9 @@ def _drop_unused_columns(df: pd.DataFrame, *column_names: str | None) -> pd.Data
|
|
610
609
|
return df[keep]
|
611
610
|
|
612
611
|
|
613
|
-
def _maybe_convert_color_column_in_place(
|
612
|
+
def _maybe_convert_color_column_in_place(
|
613
|
+
df: pd.DataFrame, color_column: str | None
|
614
|
+
) -> None:
|
614
615
|
"""If needed, convert color column to a format Vega understands."""
|
615
616
|
if color_column is None or len(df[color_column]) == 0:
|
616
617
|
return
|
@@ -669,18 +670,17 @@ def _parse_x_column(df: pd.DataFrame, x_from_user: str | None) -> str | None:
|
|
669
670
|
if x_from_user is None:
|
670
671
|
return None
|
671
672
|
|
672
|
-
|
673
|
+
if isinstance(x_from_user, str):
|
673
674
|
if x_from_user not in df.columns:
|
674
675
|
raise StreamlitColumnNotFoundError(df, x_from_user)
|
675
676
|
|
676
677
|
return x_from_user
|
677
678
|
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
)
|
679
|
+
raise StreamlitAPIException(
|
680
|
+
"x parameter should be a column name (str) or None to use the "
|
681
|
+
f" dataframe's index. Value given: {x_from_user} "
|
682
|
+
f"(type {type(x_from_user)})"
|
683
|
+
)
|
684
684
|
|
685
685
|
|
686
686
|
def _parse_y_columns(
|
@@ -935,9 +935,9 @@ def _update_encoding_with_stack(
|
|
935
935
|
encoding: alt.X | alt.Y,
|
936
936
|
) -> None:
|
937
937
|
if stack is None:
|
938
|
-
return
|
938
|
+
return
|
939
939
|
# Our layered option maps to vega's stack=False option
|
940
|
-
|
940
|
+
if stack == "layered":
|
941
941
|
stack = False
|
942
942
|
|
943
943
|
encoding["stack"] = stack
|
@@ -965,7 +965,7 @@ def _get_color_encoding(
|
|
965
965
|
return alt.ColorValue(to_css_color(cast("Any", color_value)))
|
966
966
|
|
967
967
|
# If the color value is a list of colors of approriate length, return that.
|
968
|
-
|
968
|
+
if isinstance(color_value, (list, tuple)):
|
969
969
|
color_values = cast("Collection[Color]", color_value)
|
970
970
|
|
971
971
|
if len(color_values) != len(y_column_list):
|
@@ -973,18 +973,17 @@ def _get_color_encoding(
|
|
973
973
|
|
974
974
|
if len(color_values) == 1:
|
975
975
|
return alt.ColorValue(to_css_color(cast("Any", color_value[0])))
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
)
|
976
|
+
return alt.Color(
|
977
|
+
field=color_column if color_column is not None else alt.Undefined,
|
978
|
+
scale=alt.Scale(range=[to_css_color(c) for c in color_values]),
|
979
|
+
legend=_COLOR_LEGEND_SETTINGS,
|
980
|
+
type="nominal",
|
981
|
+
title=" ",
|
982
|
+
)
|
984
983
|
|
985
984
|
raise StreamlitInvalidColorError(df, color_from_user)
|
986
985
|
|
987
|
-
|
986
|
+
if color_column is not None:
|
988
987
|
column_type: VegaLiteType
|
989
988
|
|
990
989
|
if color_column == _MELTED_COLOR_COLUMN_NAME:
|
@@ -1037,16 +1036,15 @@ def _get_size_encoding(
|
|
1037
1036
|
legend=_SIZE_LEGEND_SETTINGS,
|
1038
1037
|
)
|
1039
1038
|
|
1040
|
-
|
1039
|
+
if isinstance(size_value, (float, int)):
|
1041
1040
|
return alt.SizeValue(size_value)
|
1042
|
-
|
1041
|
+
if size_value is None:
|
1043
1042
|
return alt.SizeValue(100)
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
)
|
1043
|
+
raise StreamlitAPIException(
|
1044
|
+
f"This does not look like a valid size: {size_value!r}"
|
1045
|
+
)
|
1048
1046
|
|
1049
|
-
|
1047
|
+
if size_column is not None or size_value is not None:
|
1050
1048
|
raise Error(
|
1051
1049
|
f"Chart type {chart_type.name} does not support size argument. "
|
1052
1050
|
"This should never happen!"
|
@@ -83,7 +83,7 @@ def to_css_color(color: MaybeColor) -> Color:
|
|
83
83
|
ctuple = _normalize_tuple(ctuple, _int_formatter, _float_formatter)
|
84
84
|
if len(ctuple) == 3:
|
85
85
|
return f"rgb({ctuple[0]}, {ctuple[1]}, {ctuple[2]})"
|
86
|
-
|
86
|
+
if len(ctuple) == 4:
|
87
87
|
c4tuple = cast("MixedRGBAColorTuple", ctuple)
|
88
88
|
return f"rgba({c4tuple[0]}, {c4tuple[1]}, {c4tuple[2]}, {c4tuple[3]})"
|
89
89
|
|
@@ -155,7 +155,7 @@ def _to_color_tuple(
|
|
155
155
|
color: MaybeColor,
|
156
156
|
rgb_formatter: Callable[[float, MaybeColor], float],
|
157
157
|
alpha_formatter: Callable[[float, MaybeColor], float],
|
158
|
-
):
|
158
|
+
) -> ColorTuple:
|
159
159
|
"""Convert a potential color to a color tuple.
|
160
160
|
|
161
161
|
The exact type of color tuple this outputs is dictated by the formatter parameters.
|
@@ -224,7 +224,7 @@ def _normalize_tuple(
|
|
224
224
|
b = rgb_formatter(color[2], color)
|
225
225
|
return r, g, b
|
226
226
|
|
227
|
-
|
227
|
+
if len(color) == 4:
|
228
228
|
color_4tuple = cast("Color4Tuple", color)
|
229
229
|
r = rgb_formatter(color_4tuple[0], color_4tuple)
|
230
230
|
g = rgb_formatter(color_4tuple[1], color_4tuple)
|
@@ -1313,7 +1313,7 @@ def ImageColumn(
|
|
1313
1313
|
width: ColumnWidth | None = None,
|
1314
1314
|
help: str | None = None,
|
1315
1315
|
pinned: bool | None = None,
|
1316
|
-
):
|
1316
|
+
) -> ColumnConfig:
|
1317
1317
|
"""Configure an image column in ``st.dataframe`` or ``st.data_editor``.
|
1318
1318
|
|
1319
1319
|
The cell values need to be one of:
|
@@ -1403,7 +1403,7 @@ def ListColumn(
|
|
1403
1403
|
width: ColumnWidth | None = None,
|
1404
1404
|
help: str | None = None,
|
1405
1405
|
pinned: bool | None = None,
|
1406
|
-
):
|
1406
|
+
) -> ColumnConfig:
|
1407
1407
|
"""Configure a list column in ``st.dataframe`` or ``st.data_editor``.
|
1408
1408
|
|
1409
1409
|
This is the default column type for list-like values. List columns are not editable
|
streamlit/elements/lib/dialog.py
CHANGED
@@ -105,14 +105,14 @@ class Dialog(DeltaGenerator):
|
|
105
105
|
cursor: Cursor | None,
|
106
106
|
parent: DeltaGenerator | None,
|
107
107
|
block_type: str | None,
|
108
|
-
):
|
108
|
+
) -> None:
|
109
109
|
super().__init__(root_container, cursor, parent, block_type)
|
110
110
|
|
111
111
|
# Initialized in `_create()`:
|
112
112
|
self._current_proto: BlockProto | None = None
|
113
113
|
self._delta_path: list[int] | None = None
|
114
114
|
|
115
|
-
def _update(self, should_open: bool):
|
115
|
+
def _update(self, should_open: bool) -> None:
|
116
116
|
"""Send an updated proto message to indicate the open-status for the dialog."""
|
117
117
|
|
118
118
|
assert self._current_proto is not None, "Dialog not correctly initialized!"
|
@@ -26,7 +26,7 @@ class AttributeDictionary(dict[Any, Any]):
|
|
26
26
|
attribute-style access.
|
27
27
|
"""
|
28
28
|
|
29
|
-
def __getattr__(self, key):
|
29
|
+
def __getattr__(self, key: str) -> Any:
|
30
30
|
try:
|
31
31
|
item = self.__getitem__(key)
|
32
32
|
return AttributeDictionary(item) if isinstance(item, dict) else item
|
@@ -126,7 +126,7 @@ def check_cache_replay_rules() -> None:
|
|
126
126
|
exception(CachedWidgetWarning())
|
127
127
|
|
128
128
|
|
129
|
-
def check_fragment_path_policy(dg: DeltaGenerator):
|
129
|
+
def check_fragment_path_policy(dg: DeltaGenerator) -> None:
|
130
130
|
"""Ensures that the current widget is not written outside of the
|
131
131
|
fragment's delta path.
|
132
132
|
|
@@ -168,7 +168,7 @@ def check_widget_policies(
|
|
168
168
|
default_value: Sequence[Any] | Any | None = None,
|
169
169
|
writes_allowed: bool = True,
|
170
170
|
enable_check_callback_rules: bool = True,
|
171
|
-
):
|
171
|
+
) -> None:
|
172
172
|
"""Check all widget policies for the given DeltaGenerator."""
|
173
173
|
check_fragment_path_policy(dg)
|
174
174
|
check_cache_replay_rules()
|
@@ -179,7 +179,7 @@ def check_widget_policies(
|
|
179
179
|
)
|
180
180
|
|
181
181
|
|
182
|
-
def maybe_raise_label_warnings(label: str | None, label_visibility: str | None):
|
182
|
+
def maybe_raise_label_warnings(label: str | None, label_visibility: str | None) -> None:
|
183
183
|
if not label:
|
184
184
|
_LOGGER.warning(
|
185
185
|
"`label` got an empty value. This is discouraged for accessibility "
|
streamlit/elements/lib/utils.py
CHANGED
@@ -70,9 +70,9 @@ def get_label_visibility_proto_value(
|
|
70
70
|
|
71
71
|
if label_visibility_string == "visible":
|
72
72
|
return LabelVisibilityMessage.LabelVisibilityOptions.VISIBLE
|
73
|
-
|
73
|
+
if label_visibility_string == "hidden":
|
74
74
|
return LabelVisibilityMessage.LabelVisibilityOptions.HIDDEN
|
75
|
-
|
75
|
+
if label_visibility_string == "collapsed":
|
76
76
|
return LabelVisibilityMessage.LabelVisibilityOptions.COLLAPSED
|
77
77
|
|
78
78
|
raise ValueError(f"Unknown label visibility value: {label_visibility_string}")
|
@@ -85,9 +85,9 @@ def get_chat_input_accept_file_proto_value(
|
|
85
85
|
|
86
86
|
if accept_file_value is False:
|
87
87
|
return ChatInput.AcceptFile.NONE
|
88
|
-
|
88
|
+
if accept_file_value is True:
|
89
89
|
return ChatInput.AcceptFile.SINGLE
|
90
|
-
|
90
|
+
if accept_file_value == "multiple":
|
91
91
|
return ChatInput.AcceptFile.MULTIPLE
|
92
92
|
|
93
93
|
raise ValueError(f"Unknown accept file value: {accept_file_value}")
|
@@ -240,7 +240,7 @@ def compute_and_register_element_id(
|
|
240
240
|
return element_id
|
241
241
|
|
242
242
|
|
243
|
-
def save_for_app_testing(ctx: ScriptRunContext, k: str, v: Any):
|
243
|
+
def save_for_app_testing(ctx: ScriptRunContext, k: str, v: Any) -> None:
|
244
244
|
if config.get_option("global.appTest"):
|
245
245
|
try:
|
246
246
|
ctx.session_state[TESTING_KEY][k] = v
|
streamlit/elements/map.py
CHANGED
@@ -94,21 +94,26 @@ class MapMixin:
|
|
94
94
|
This is a wrapper around ``st.pydeck_chart`` to quickly create
|
95
95
|
scatterplot charts on top of a map, with auto-centering and auto-zoom.
|
96
96
|
|
97
|
-
When using this command,
|
98
|
-
content.
|
99
|
-
|
100
|
-
or
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
https://
|
97
|
+
When using this command, a service called Carto_ provides the map tiles to render
|
98
|
+
map content. If you're using advanced PyDeck features you may need to obtain
|
99
|
+
an API key from Carto first. You can do that as
|
100
|
+
``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
|
101
|
+
environment variable. See `PyDeck's documentation`_ for more information.
|
102
|
+
|
103
|
+
Another common provider for map tiles is Mapbox_. If you prefer to use that,
|
104
|
+
you'll need to create an account at https://mapbox.com and specify your Mapbox
|
105
|
+
key when creating the ``pydeck.Deck`` object. You can do that as
|
106
|
+
``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
|
107
|
+
environment variable.
|
108
|
+
|
109
|
+
.. _Carto: https://carto.com
|
110
|
+
.. _Mapbox: https://mapbox.com
|
111
|
+
.. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html
|
112
|
+
|
113
|
+
Carto and Mapbox are third-party products and Streamlit accepts no responsibility
|
114
|
+
or liability of any kind for Carto or Mapbox, or for any content or information
|
115
|
+
made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
|
116
|
+
their respective Terms of Use.
|
112
117
|
|
113
118
|
Parameters
|
114
119
|
----------
|
streamlit/elements/progress.py
CHANGED
@@ -61,26 +61,23 @@ def _check_float_between(value: float, low: float = 0.0, high: float = 1.0) -> b
|
|
61
61
|
)
|
62
62
|
|
63
63
|
|
64
|
-
def _get_value(value):
|
64
|
+
def _get_value(value: FloatOrInt) -> int:
|
65
65
|
if isinstance(value, int):
|
66
66
|
if 0 <= value <= 100:
|
67
67
|
return value
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
)
|
68
|
+
raise StreamlitAPIException(
|
69
|
+
"Progress Value has invalid value [0, 100]: %d" % value
|
70
|
+
)
|
72
71
|
|
73
|
-
|
72
|
+
if isinstance(value, float):
|
74
73
|
if _check_float_between(value, low=0.0, high=1.0):
|
75
74
|
return int(value * 100)
|
76
|
-
else:
|
77
|
-
raise StreamlitAPIException(
|
78
|
-
"Progress Value has invalid value [0.0, 1.0]: %f" % value
|
79
|
-
)
|
80
|
-
else:
|
81
75
|
raise StreamlitAPIException(
|
82
|
-
"Progress Value has invalid
|
76
|
+
"Progress Value has invalid value [0.0, 1.0]: %f" % value
|
83
77
|
)
|
78
|
+
raise StreamlitAPIException(
|
79
|
+
"Progress Value has invalid type: %s" % type(value).__name__
|
80
|
+
)
|
84
81
|
|
85
82
|
|
86
83
|
def _get_text(text: str | None) -> str | None:
|
@@ -253,7 +253,7 @@ class VegaLiteStateSerde:
|
|
253
253
|
def _prepare_vega_lite_spec(
|
254
254
|
spec: VegaLiteSpec,
|
255
255
|
use_container_width: bool,
|
256
|
-
**kwargs,
|
256
|
+
**kwargs: Any,
|
257
257
|
) -> VegaLiteSpec:
|
258
258
|
if kwargs:
|
259
259
|
# Support passing in kwargs.
|
@@ -345,7 +345,7 @@ def _convert_altair_to_vega_lite_spec(
|
|
345
345
|
|
346
346
|
datasets = {}
|
347
347
|
|
348
|
-
def id_transform(data) -> dict[str, str]:
|
348
|
+
def id_transform(data: Any) -> dict[str, str]:
|
349
349
|
"""Altair data transformer that serializes the data,
|
350
350
|
creates a stable name based on the hash of the data,
|
351
351
|
stores the bytes into the datasets mapping and
|
@@ -165,7 +165,7 @@ class ButtonGroupSerde(Generic[T]):
|
|
165
165
|
options: Sequence[T],
|
166
166
|
default_values: list[int],
|
167
167
|
type: Literal["single", "multi"],
|
168
|
-
):
|
168
|
+
) -> None:
|
169
169
|
self.options = options
|
170
170
|
self.default_values = default_values
|
171
171
|
self.type = type
|
@@ -250,7 +250,7 @@ def _build_proto(
|
|
250
250
|
return proto
|
251
251
|
|
252
252
|
|
253
|
-
def _maybe_raise_selection_mode_warning(selection_mode: SelectionMode):
|
253
|
+
def _maybe_raise_selection_mode_warning(selection_mode: SelectionMode) -> None:
|
254
254
|
"""Check if the selection_mode value is valid or raise exception otherwise."""
|
255
255
|
if selection_mode not in ["single", "multi"]:
|
256
256
|
raise StreamlitAPIException(
|
@@ -477,7 +477,7 @@ def _fix_column_headers(data_df: pd.DataFrame) -> None:
|
|
477
477
|
)
|
478
478
|
|
479
479
|
|
480
|
-
def _check_column_names(data_df: pd.DataFrame):
|
480
|
+
def _check_column_names(data_df: pd.DataFrame) -> None:
|
481
481
|
"""Check if the column names in the provided dataframe are valid.
|
482
482
|
|
483
483
|
It's not allowed to have duplicate column names or column names that are
|
@@ -511,7 +511,7 @@ def _check_type_compatibilities(
|
|
511
511
|
data_df: pd.DataFrame,
|
512
512
|
columns_config: ColumnConfigMapping,
|
513
513
|
dataframe_schema: DataframeSchema,
|
514
|
-
):
|
514
|
+
) -> None:
|
515
515
|
"""Check column type to data type compatibility.
|
516
516
|
|
517
517
|
Iterates the index and all columns of the dataframe to check if
|
@@ -75,7 +75,7 @@ class MultiSelectSerde(Generic[T]):
|
|
75
75
|
formatted_options: list[str],
|
76
76
|
formatted_option_to_option_index: dict[str, int],
|
77
77
|
default_options_indices: list[int] | None = None,
|
78
|
-
):
|
78
|
+
) -> None:
|
79
79
|
"""Initialize the MultiSelectSerde.
|
80
80
|
|
81
81
|
We do not store an option_to_formatted_option mapping because the generic
|
@@ -140,7 +140,7 @@ def _get_default_count(default: Sequence[Any] | Any | None) -> int:
|
|
140
140
|
|
141
141
|
def _check_max_selections(
|
142
142
|
selections: Sequence[Any] | Any | None, max_selections: int | None
|
143
|
-
):
|
143
|
+
) -> None:
|
144
144
|
if max_selections is None:
|
145
145
|
return
|
146
146
|
|
@@ -72,7 +72,7 @@ class SelectboxSerde(Generic[T]):
|
|
72
72
|
formatted_options: list[str],
|
73
73
|
formatted_option_to_option_index: dict[str, int],
|
74
74
|
default_option_index: int | None = None,
|
75
|
-
):
|
75
|
+
) -> None:
|
76
76
|
"""Initialize the SelectboxSerde.
|
77
77
|
|
78
78
|
We do not store an option_to_formatted_option mapping because the generic
|
@@ -85,8 +85,8 @@ SliderDatelikeSpanT: TypeAlias = Union[
|
|
85
85
|
StepNumericT: TypeAlias = SliderNumericT
|
86
86
|
StepDatelikeT: TypeAlias = timedelta
|
87
87
|
|
88
|
-
SliderStep = Union[int, float, timedelta]
|
89
|
-
SliderScalar = Union[int, float, date, time, datetime]
|
88
|
+
SliderStep: TypeAlias = Union[int, float, timedelta]
|
89
|
+
SliderScalar: TypeAlias = Union[int, float, date, time, datetime]
|
90
90
|
SliderValueT = TypeVar("SliderValueT", int, float, date, time, datetime)
|
91
91
|
SliderValueGeneric: TypeAlias = Union[
|
92
92
|
SliderValueT,
|
@@ -162,7 +162,7 @@ class SliderSerde:
|
|
162
162
|
single_value: bool
|
163
163
|
orig_tz: tzinfo | None
|
164
164
|
|
165
|
-
def deserialize_single_value(self, value: float):
|
165
|
+
def deserialize_single_value(self, value: float) -> SliderScalar:
|
166
166
|
if self.data_type == SliderProto.INT:
|
167
167
|
return int(value)
|
168
168
|
if self.data_type == SliderProto.DATETIME:
|
@@ -177,7 +177,7 @@ class SliderSerde:
|
|
177
177
|
)
|
178
178
|
return value
|
179
179
|
|
180
|
-
def deserialize(self, ui_value: list[float] | None):
|
180
|
+
def deserialize(self, ui_value: list[float] | None) -> Any:
|
181
181
|
if ui_value is not None:
|
182
182
|
val = ui_value
|
183
183
|
else:
|
@@ -185,8 +185,10 @@ class SliderSerde:
|
|
185
185
|
val = self.value
|
186
186
|
|
187
187
|
# The widget always returns a float array, so fix the return type if necessary
|
188
|
-
|
189
|
-
return
|
188
|
+
deserialized_values = [self.deserialize_single_value(v) for v in val]
|
189
|
+
return (
|
190
|
+
deserialized_values[0] if self.single_value else tuple(deserialized_values)
|
191
|
+
)
|
190
192
|
|
191
193
|
def serialize(self, v: Any) -> list[Any]:
|
192
194
|
range_value = isinstance(v, (list, tuple))
|
@@ -607,10 +609,10 @@ class SliderMixin:
|
|
607
609
|
def _slider(
|
608
610
|
self,
|
609
611
|
label: str,
|
610
|
-
min_value=None,
|
611
|
-
max_value=None,
|
612
|
-
value=None,
|
613
|
-
step=None,
|
612
|
+
min_value: Any = None,
|
613
|
+
max_value: Any = None,
|
614
|
+
value: Any = None,
|
615
|
+
step: Any = None,
|
614
616
|
format: str | None = None,
|
615
617
|
key: Key | None = None,
|
616
618
|
help: str | None = None,
|
@@ -693,12 +695,11 @@ class SliderMixin:
|
|
693
695
|
def value_to_generic_type(v):
|
694
696
|
if isinstance(v, Integral):
|
695
697
|
return SUPPORTED_TYPES[Integral]
|
696
|
-
|
698
|
+
if isinstance(v, Real):
|
697
699
|
return SUPPORTED_TYPES[Real]
|
698
|
-
|
699
|
-
return SUPPORTED_TYPES[type(v)]
|
700
|
+
return SUPPORTED_TYPES[type(v)]
|
700
701
|
|
701
|
-
def all_same_type(items):
|
702
|
+
def all_same_type(items: Any) -> bool:
|
702
703
|
return len(set(map(value_to_generic_type, items))) < 2
|
703
704
|
|
704
705
|
if not all_same_type(value):
|
@@ -930,6 +931,7 @@ class SliderMixin:
|
|
930
931
|
for value in serialized_values:
|
931
932
|
# Use the deserialized values for more readable error messages for dates/times
|
932
933
|
deserialized_value = serde.deserialize_single_value(value)
|
934
|
+
|
933
935
|
if value < slider_proto.min:
|
934
936
|
raise StreamlitValueBelowMinError(
|
935
937
|
value=deserialized_value,
|
streamlit/elements/write.py
CHANGED
@@ -245,7 +245,7 @@ class WriteMixin:
|
|
245
245
|
if not written_content:
|
246
246
|
# If nothing was streamed, return an empty string.
|
247
247
|
return ""
|
248
|
-
|
248
|
+
if len(written_content) == 1 and isinstance(written_content[0], str):
|
249
249
|
# If the output only contains a single string, return it as a string
|
250
250
|
return written_content[0]
|
251
251
|
|
@@ -253,7 +253,7 @@ class WriteMixin:
|
|
253
253
|
return written_content
|
254
254
|
|
255
255
|
@gather_metrics("write")
|
256
|
-
def write(self, *args: Any, unsafe_allow_html: bool = False, **kwargs) -> None:
|
256
|
+
def write(self, *args: Any, unsafe_allow_html: bool = False, **kwargs: Any) -> None:
|
257
257
|
"""Displays arguments in the app.
|
258
258
|
|
259
259
|
This is the Swiss Army knife of Streamlit commands: it does different
|
@@ -528,10 +528,7 @@ class WriteMixin:
|
|
528
528
|
):
|
529
529
|
flush_buffer()
|
530
530
|
self.write_stream(arg)
|
531
|
-
elif isinstance(arg, HELP_TYPES):
|
532
|
-
flush_buffer()
|
533
|
-
self.dg.help(arg)
|
534
|
-
elif dataclasses.is_dataclass(arg):
|
531
|
+
elif isinstance(arg, HELP_TYPES) or dataclasses.is_dataclass(arg):
|
535
532
|
flush_buffer()
|
536
533
|
self.dg.help(arg)
|
537
534
|
elif inspect.isclass(arg):
|