streamlit 1.45.1__py3-none-any.whl → 1.46.1__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/__init__.py +5 -1
- streamlit/auth_util.py +12 -12
- streamlit/cli_util.py +4 -3
- streamlit/column_config.py +11 -9
- streamlit/commands/echo.py +6 -4
- streamlit/commands/execution_control.py +33 -32
- streamlit/commands/experimental_query_params.py +2 -2
- streamlit/commands/logo.py +9 -4
- streamlit/commands/navigation.py +61 -18
- streamlit/commands/page_config.py +57 -47
- streamlit/components/types/base_custom_component.py +7 -7
- streamlit/components/v1/component_registry.py +7 -3
- streamlit/components/v1/components.py +1 -1
- streamlit/components/v1/custom_component.py +8 -8
- streamlit/config.py +289 -144
- streamlit/config_option.py +19 -15
- streamlit/config_util.py +29 -23
- streamlit/connections/__init__.py +2 -2
- streamlit/connections/base_connection.py +5 -5
- streamlit/connections/snowflake_connection.py +13 -11
- streamlit/connections/snowpark_connection.py +3 -3
- streamlit/connections/sql_connection.py +20 -18
- streamlit/connections/util.py +2 -2
- streamlit/cursor.py +6 -6
- streamlit/dataframe_util.py +52 -52
- streamlit/delta_generator.py +46 -48
- streamlit/delta_generator_singletons.py +3 -3
- streamlit/deprecation_util.py +6 -6
- streamlit/elements/alert.py +37 -29
- streamlit/elements/arrow.py +40 -22
- streamlit/elements/code.py +46 -13
- streamlit/elements/deck_gl_json_chart.py +38 -27
- streamlit/elements/dialog_decorator.py +3 -4
- streamlit/elements/doc_string.py +64 -58
- streamlit/elements/exception.py +23 -27
- streamlit/elements/form.py +41 -0
- streamlit/elements/graphviz_chart.py +1 -1
- streamlit/elements/heading.py +60 -9
- streamlit/elements/html.py +3 -4
- streamlit/elements/image.py +8 -9
- streamlit/elements/json.py +21 -2
- streamlit/elements/layouts.py +120 -31
- streamlit/elements/lib/built_in_chart_utils.py +96 -73
- streamlit/elements/lib/color_util.py +3 -3
- streamlit/elements/lib/column_config_utils.py +2 -4
- streamlit/elements/lib/column_types.py +14 -8
- streamlit/elements/lib/dialog.py +9 -5
- streamlit/elements/lib/image_utils.py +39 -40
- streamlit/elements/lib/js_number.py +4 -4
- streamlit/elements/lib/layout_utils.py +65 -1
- streamlit/elements/lib/mutable_status_container.py +14 -3
- streamlit/elements/lib/options_selector_utils.py +22 -12
- streamlit/elements/lib/pandas_styler_utils.py +25 -21
- streamlit/elements/lib/policies.py +6 -5
- streamlit/elements/lib/streamlit_plotly_theme.py +54 -53
- streamlit/elements/lib/subtitle_utils.py +6 -9
- streamlit/elements/lib/utils.py +20 -5
- streamlit/elements/map.py +32 -56
- streamlit/elements/markdown.py +101 -12
- streamlit/elements/media.py +78 -21
- streamlit/elements/metric.py +32 -16
- streamlit/elements/plotly_chart.py +15 -15
- streamlit/elements/progress.py +33 -15
- streamlit/elements/spinner.py +31 -6
- streamlit/elements/text.py +21 -1
- streamlit/elements/toast.py +1 -2
- streamlit/elements/vega_charts.py +54 -23
- streamlit/elements/widgets/audio_input.py +24 -7
- streamlit/elements/widgets/button.py +26 -19
- streamlit/elements/widgets/button_group.py +10 -15
- streamlit/elements/widgets/camera_input.py +27 -7
- streamlit/elements/widgets/chat.py +91 -38
- streamlit/elements/widgets/checkbox.py +45 -4
- streamlit/elements/widgets/color_picker.py +40 -17
- streamlit/elements/widgets/data_editor.py +76 -37
- streamlit/elements/widgets/file_uploader.py +42 -13
- streamlit/elements/widgets/multiselect.py +7 -10
- streamlit/elements/widgets/number_input.py +123 -47
- streamlit/elements/widgets/radio.py +59 -13
- streamlit/elements/widgets/select_slider.py +35 -30
- streamlit/elements/widgets/selectbox.py +56 -9
- streamlit/elements/widgets/slider.py +190 -99
- streamlit/elements/widgets/text_widgets.py +54 -8
- streamlit/elements/widgets/time_widgets.py +53 -14
- streamlit/elements/write.py +5 -8
- streamlit/env_util.py +2 -7
- streamlit/error_util.py +16 -9
- streamlit/errors.py +69 -48
- streamlit/external/langchain/streamlit_callback_handler.py +10 -5
- streamlit/file_util.py +27 -10
- streamlit/git_util.py +29 -24
- streamlit/hello/animation_demo.py +9 -9
- streamlit/hello/dataframe_demo.py +5 -5
- streamlit/hello/hello.py +1 -0
- streamlit/hello/mapping_demo.py +7 -8
- streamlit/hello/plotting_demo.py +3 -3
- streamlit/hello/streamlit_app.py +28 -26
- streamlit/hello/utils.py +2 -1
- streamlit/logger.py +10 -11
- streamlit/navigation/page.py +11 -8
- streamlit/proto/Audio_pb2.py +4 -3
- streamlit/proto/Audio_pb2.pyi +8 -1
- streamlit/proto/Block_pb2.py +38 -29
- streamlit/proto/Block_pb2.pyi +72 -4
- streamlit/proto/ClientState_pb2.py +4 -4
- streamlit/proto/ClientState_pb2.pyi +7 -2
- streamlit/proto/Code_pb2.py +4 -2
- streamlit/proto/Code_pb2.pyi +1 -0
- streamlit/proto/DataFrame_pb2.pyi +1 -1
- streamlit/proto/DeckGlJsonChart_pb2.pyi +1 -1
- streamlit/proto/Element_pb2.py +5 -3
- streamlit/proto/Element_pb2.pyi +20 -3
- 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/NamedDataSet_pb2.pyi +1 -1
- streamlit/proto/Navigation_pb2.py +3 -3
- streamlit/proto/Navigation_pb2.pyi +4 -0
- streamlit/proto/NewSession_pb2.py +18 -16
- streamlit/proto/NewSession_pb2.pyi +29 -3
- streamlit/proto/PageConfig_pb2.py +7 -7
- streamlit/proto/PageConfig_pb2.pyi +21 -1
- streamlit/proto/Video_pb2.py +8 -7
- streamlit/proto/Video_pb2.pyi +8 -1
- streamlit/proto/WidthConfig_pb2.py +2 -2
- streamlit/proto/WidthConfig_pb2.pyi +15 -1
- streamlit/runtime/__init__.py +1 -1
- streamlit/runtime/app_session.py +53 -40
- streamlit/runtime/caching/__init__.py +9 -9
- streamlit/runtime/caching/cache_data_api.py +36 -30
- streamlit/runtime/caching/cache_errors.py +4 -4
- streamlit/runtime/caching/cache_resource_api.py +8 -8
- streamlit/runtime/caching/cache_utils.py +15 -14
- streamlit/runtime/caching/cached_message_replay.py +14 -8
- streamlit/runtime/caching/hashing.py +91 -97
- streamlit/runtime/caching/legacy_cache_api.py +2 -2
- streamlit/runtime/caching/storage/cache_storage_protocol.py +1 -1
- streamlit/runtime/caching/storage/dummy_cache_storage.py +1 -1
- streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +12 -14
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +6 -6
- streamlit/runtime/connection_factory.py +36 -36
- streamlit/runtime/context.py +58 -9
- streamlit/runtime/credentials.py +29 -40
- streamlit/runtime/forward_msg_queue.py +11 -11
- streamlit/runtime/fragment.py +7 -7
- streamlit/runtime/media_file_manager.py +3 -4
- streamlit/runtime/memory_media_file_storage.py +6 -5
- streamlit/runtime/memory_uploaded_file_manager.py +2 -2
- streamlit/runtime/metrics_util.py +11 -12
- streamlit/runtime/pages_manager.py +4 -6
- streamlit/runtime/runtime.py +8 -6
- streamlit/runtime/runtime_util.py +7 -6
- streamlit/runtime/scriptrunner/__init__.py +4 -4
- streamlit/runtime/scriptrunner/exec_code.py +12 -5
- streamlit/runtime/scriptrunner/magic.py +16 -12
- streamlit/runtime/scriptrunner/script_cache.py +1 -1
- streamlit/runtime/scriptrunner/script_runner.py +53 -29
- streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
- streamlit/runtime/scriptrunner_utils/script_requests.py +7 -4
- streamlit/runtime/scriptrunner_utils/script_run_context.py +10 -23
- streamlit/runtime/secrets.py +40 -35
- streamlit/runtime/session_manager.py +2 -1
- streamlit/runtime/state/__init__.py +5 -5
- streamlit/runtime/state/common.py +2 -2
- streamlit/runtime/state/query_params.py +13 -15
- streamlit/runtime/state/query_params_proxy.py +17 -13
- streamlit/runtime/state/safe_session_state.py +2 -2
- streamlit/runtime/state/session_state.py +52 -34
- streamlit/runtime/stats.py +2 -2
- streamlit/runtime/uploaded_file_manager.py +1 -1
- streamlit/runtime/websocket_session_manager.py +10 -6
- streamlit/source_util.py +8 -6
- streamlit/static/index.html +3 -17
- streamlit/static/manifest.json +1180 -0
- streamlit/static/static/css/{index.DqDwtg6_.css → index.CJVRHjQZ.css} +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.DU9IrB3M.js → ErrorOutline.esm.DitPpe1Y.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.P9rKwKo8.js → FileDownload.esm.AI3watX9.js} +1 -1
- streamlit/static/static/js/{FileHelper.D7RMkx0e.js → FileHelper.kt7mhnu8.js} +5 -5
- streamlit/static/static/js/{FormClearHelper.B67tgll0.js → FormClearHelper.D1M9GM_c.js} +1 -1
- streamlit/static/static/js/{Hooks.ncTJktu9.js → Hooks.BGwHKeUc.js} +1 -1
- streamlit/static/static/js/{InputInstructions.D-Y8geDN.js → InputInstructions.DaZ89mzH.js} +1 -1
- streamlit/static/static/js/{ProgressBar.B-kexwwD.js → ProgressBar.C0zPMe-p.js} +2 -2
- streamlit/static/static/js/{RenderInPortalIfExists.BgaoZgep.js → RenderInPortalIfExists.Ox8gQvdz.js} +1 -1
- streamlit/static/static/js/Toolbar.KhlcEc0K.js +1 -0
- streamlit/static/static/js/UploadFileInfo.0DCkpDDf.js +6 -0
- streamlit/static/static/js/{base-input.BoAa1U94.js → base-input.BJ4qsfSq.js} +4 -4
- streamlit/static/static/js/{checkbox.Z6iSfe5F.js → checkbox.DSDh78Xz.js} +2 -2
- streamlit/static/static/js/{createSuper.B4oGDYRm.js → createSuper.wQ9SIXEJ.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.msYws2Ou.js → data-grid-overlay-editor.DvbdPJ15.js} +1 -1
- streamlit/static/static/js/{downloader.kc14n2Hv.js → downloader.CD9rzih5.js} +1 -1
- streamlit/static/static/js/{es6.CxQz807-.js → es6.48Q9Qjgb.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.B19u0ONI.js → iframeResizer.contentWindow.CKdem3Bn.js} +1 -1
- streamlit/static/static/js/{index.LaIasviC.js → index.6md5Qhod.js} +1 -1
- streamlit/static/static/js/index.7hy6AeJ1.js +1 -0
- streamlit/static/static/js/index.B4CGJiBW.js +1 -0
- streamlit/static/static/js/index.B8oW0ZTD.js +1 -0
- streamlit/static/static/js/index.BU6RnlHI.js +73 -0
- streamlit/static/static/js/index.BUq9Wcf8.js +197 -0
- streamlit/static/static/js/{index.BFz9U2y0.js → index.BXXo-Yoj.js} +1 -1
- streamlit/static/static/js/index.Bae9H0OS.js +1 -0
- streamlit/static/static/js/{index.-5ruC9At.js → index.BhTl2Uyb.js} +1 -1
- streamlit/static/static/js/{index.BpILzHf_.js → index.BiSaCB1o.js} +20 -20
- streamlit/static/static/js/{index.xNQq3Ei5.js → index.BulSAJ9z.js} +1 -1
- streamlit/static/static/js/{index.9V1KdxfP.js → index.Bv-EuTKR.js} +1 -1
- streamlit/static/static/js/index.BvMLYCHi.js +1 -0
- streamlit/static/static/js/index.C1NIn1Y2.js +783 -0
- streamlit/static/static/js/index.CP-fthOJ.js +2 -0
- streamlit/static/static/js/{index.BoigZiu7.js → index.CS9guO3p.js} +1 -1
- streamlit/static/static/js/index.CYTBHth8.js +1 -0
- streamlit/static/static/js/{index.CmTAF0dM.js → index.CcJufcuD.js} +1 -1
- streamlit/static/static/js/index.CnENU1yn.js +1 -0
- streamlit/static/static/js/index.Cns13qBb.js +1 -0
- streamlit/static/static/js/index.Ct_xXq7w.js +1 -0
- streamlit/static/static/js/{index.BqfdT8-Q.js → index.CxGSemHL.js} +1 -1
- streamlit/static/static/js/index.D5S0ldVb.js +1 -0
- streamlit/static/static/js/index.D72B_ksb.js +2 -0
- streamlit/static/static/js/index.DI4yZ27M.js +1 -0
- streamlit/static/static/js/index.DN51vLxR.js +1 -0
- streamlit/static/static/js/index.DRtq5dka.js +1 -0
- streamlit/static/static/js/{index.BHXxWdde.js → index.DX-oiXlb.js} +1 -1
- streamlit/static/static/js/index.DlFE4_Aq.js +12 -0
- streamlit/static/static/js/{index.BHGGDa8K.js → index.J7BJwXOi.js} +2 -2
- streamlit/static/static/js/index.Jg38kJPP.js +1 -0
- streamlit/static/static/js/index.JhIO6abf.js +3 -0
- streamlit/static/static/js/{index.DeB9iKFW.js → index.NkRcWwc5.js} +255 -255
- streamlit/static/static/js/{index.BGga-hcS.js → index.prekPLrm.js} +25 -25
- streamlit/static/static/js/{index.BRXmLIsC.js → index.wyzngKUE.js} +1 -1
- streamlit/static/static/js/index.xW7mVdI8.js +1 -0
- streamlit/static/static/js/index.yk07dYGx.js +1 -0
- streamlit/static/static/js/{input.DsCfafm0.js → input.CxKZ5Wrc.js} +2 -2
- streamlit/static/static/js/{memory.nY_lMTtu.js → memory.DeZ9VUvl.js} +1 -1
- streamlit/static/static/js/{mergeWith.B_7zmsM4.js → mergeWith.CVkhrWUb.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CSeVhHRU.js → number-overlay-editor.Bpkm3nTq.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.nNhsvgRd.js → possibleConstructorReturn.CIDCId52.js} +1 -1
- streamlit/static/static/js/{sandbox.Cgm3iuL6.js → sandbox.TrkMaokR.js} +1 -1
- streamlit/static/static/js/{textarea.BR8rlyih.js → textarea.QKjxR64N.js} +2 -2
- streamlit/static/static/js/{timepicker.w4XhAenH.js → timepicker.DJYmE1dK.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CgkEPBwD.js → toConsumableArray.BZoworE-.js} +1 -1
- streamlit/static/static/js/{uniqueId.j-1rlNNH.js → uniqueId.O0UbJ2Bu.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.zXY9CjFS.js → useBasicWidgetState.Ci89jaH5.js} +1 -1
- streamlit/static/static/js/useOnInputChange.Cxh6ExEn.js +1 -0
- streamlit/static/static/js/{withFullScreenWrapper.Ov13692o.js → withFullScreenWrapper.iW37lS8Z.js} +1 -1
- streamlit/static/static/media/SourceCodeVF-Italic.ttf.Ba1oaZG1.woff2 +0 -0
- streamlit/static/static/media/SourceCodeVF-Upright.ttf.BjWn63N-.woff2 +0 -0
- streamlit/static/static/media/SourceSansVF-Italic.ttf.Bt9VkdQ3.woff2 +0 -0
- streamlit/static/static/media/SourceSansVF-Upright.ttf.BsWL4Kly.woff2 +0 -0
- streamlit/static/static/media/SourceSerifVariable-Italic.ttf.CVdzAtxO.woff2 +0 -0
- streamlit/static/static/media/SourceSerifVariable-Roman.ttf.mdpVL9bi.woff2 +0 -0
- streamlit/string_util.py +14 -19
- streamlit/temporary_directory.py +13 -4
- streamlit/testing/v1/app_test.py +15 -10
- streamlit/testing/v1/element_tree.py +157 -178
- streamlit/testing/v1/local_script_runner.py +11 -15
- streamlit/testing/v1/util.py +11 -4
- streamlit/type_util.py +8 -12
- streamlit/url_util.py +1 -1
- streamlit/user_info.py +6 -5
- streamlit/util.py +25 -1
- streamlit/vendor/pympler/asizeof.py +3 -2
- streamlit/watcher/event_based_path_watcher.py +21 -2
- streamlit/watcher/folder_black_list.py +2 -2
- streamlit/watcher/local_sources_watcher.py +64 -18
- streamlit/watcher/path_watcher.py +6 -10
- streamlit/watcher/polling_path_watcher.py +8 -7
- streamlit/watcher/util.py +7 -6
- streamlit/web/bootstrap.py +16 -14
- streamlit/web/cli.py +52 -45
- streamlit/web/server/__init__.py +7 -3
- streamlit/web/server/app_static_file_handler.py +1 -1
- streamlit/web/server/authlib_tornado_integration.py +9 -4
- streamlit/web/server/browser_websocket_handler.py +8 -2
- streamlit/web/server/component_request_handler.py +14 -10
- streamlit/web/server/media_file_handler.py +14 -7
- streamlit/web/server/oauth_authlib_routes.py +41 -9
- streamlit/web/server/oidc_mixin.py +35 -17
- streamlit/web/server/routes.py +32 -22
- streamlit/web/server/server.py +13 -24
- streamlit/web/server/server_util.py +43 -9
- streamlit/web/server/stats_request_handler.py +7 -5
- streamlit/web/server/upload_file_request_handler.py +22 -19
- streamlit/web/server/websocket_headers.py +1 -1
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/METADATA +4 -4
- streamlit-1.46.1.dist-info/RECORD +559 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/WHEEL +1 -1
- streamlit/elements/lib/event_utils.py +0 -39
- streamlit/static/static/js/Toolbar.D9RUZv9G.js +0 -1
- streamlit/static/static/js/UploadFileInfo.C-jY39rj.js +0 -1
- streamlit/static/static/js/index.8jhZBWF2.js +0 -3
- streamlit/static/static/js/index.BCx3C6e_.js +0 -1
- streamlit/static/static/js/index.BRuTz_S4.js +0 -1
- streamlit/static/static/js/index.Bcru_ti-.js +0 -1
- streamlit/static/static/js/index.Bl1FMJRd.js +0 -1
- streamlit/static/static/js/index.C1z8KpLA.js +0 -779
- streamlit/static/static/js/index.C32I2PUe.js +0 -2
- streamlit/static/static/js/index.C5GnDRB7.js +0 -1
- streamlit/static/static/js/index.CG4qPaaW.js +0 -2
- streamlit/static/static/js/index.C_msmT1u.js +0 -1
- streamlit/static/static/js/index.CbeNTdd6.js +0 -1
- streamlit/static/static/js/index.CnGQVJcw.js +0 -12
- streamlit/static/static/js/index.CopVVq4l.js +0 -1
- streamlit/static/static/js/index.CtXupx4d.js +0 -197
- streamlit/static/static/js/index.DGmCchO7.js +0 -1
- streamlit/static/static/js/index.DH6zBk0e.js +0 -1
- streamlit/static/static/js/index.DHVlVWsm.js +0 -1
- streamlit/static/static/js/index.DRKIVBoi.js +0 -1
- streamlit/static/static/js/index.DUd-lFXx.js +0 -73
- streamlit/static/static/js/index.D_uRBA4B.js +0 -1
- streamlit/static/static/js/index.QHNfgPJd.js +0 -1
- streamlit/static/static/js/index.a-RJocYL.js +0 -1
- streamlit/static/static/js/index.cvz4B1gy.js +0 -1
- streamlit/static/static/js/index.t--hEgTQ.js +0 -6
- streamlit/static/static/js/useOnInputChange.z04u96A8.js +0 -1
- streamlit/static/static/media/SourceCodePro-Bold.CFEfr7-q.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-BoldItalic.C-LkFXxa.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Italic.CxFOx7N-.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Regular.CBOlD63d.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBold.CFHwW3Wd.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBoldItalic.Cg2yRu82.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Bold.-6c9oR8J.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-BoldItalic.DmM_grLY.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Italic.I1ipWe7Q.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Regular.DZLUzqI4.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBold.sKQIyTMz.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBoldItalic.C0wP0icr.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Bold.8TUnKj4x.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-BoldItalic.CBVO7Ve7.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Italic.DkFgL2HZ.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Regular.CNJNET2S.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBold.CHyh9GC5.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBoldItalic.CBtz8sWN.woff2 +0 -0
- streamlit-1.45.1.dist-info/RECORD +0 -568
- {streamlit-1.45.1.data → streamlit-1.46.1.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/entry_points.txt +0 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/top_level.txt +0 -0
streamlit/errors.py
CHANGED
|
@@ -15,10 +15,14 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import os
|
|
18
|
-
from typing import Any, Literal
|
|
18
|
+
from typing import TYPE_CHECKING, Any, Literal
|
|
19
19
|
|
|
20
20
|
from streamlit import util
|
|
21
21
|
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from collections.abc import Collection
|
|
24
|
+
from datetime import date, time
|
|
25
|
+
|
|
22
26
|
|
|
23
27
|
class Error(Exception):
|
|
24
28
|
"""The base class for all exceptions thrown by Streamlit.
|
|
@@ -49,7 +53,7 @@ class FragmentStorageKeyError(Error, KeyError):
|
|
|
49
53
|
pass
|
|
50
54
|
|
|
51
55
|
|
|
52
|
-
class FragmentHandledException(Exception):
|
|
56
|
+
class FragmentHandledException(Exception): # noqa: N818
|
|
53
57
|
"""An exception that is raised by the fragment
|
|
54
58
|
when it has handled the exception itself.
|
|
55
59
|
"""
|
|
@@ -57,15 +61,15 @@ class FragmentHandledException(Exception):
|
|
|
57
61
|
pass
|
|
58
62
|
|
|
59
63
|
|
|
60
|
-
class NoStaticFiles(Error):
|
|
64
|
+
class NoStaticFiles(Error): # noqa: N818
|
|
61
65
|
pass
|
|
62
66
|
|
|
63
67
|
|
|
64
|
-
class NoSessionContext(Error):
|
|
68
|
+
class NoSessionContext(Error): # noqa: N818
|
|
65
69
|
pass
|
|
66
70
|
|
|
67
71
|
|
|
68
|
-
class MarkdownFormattedException(Error):
|
|
72
|
+
class MarkdownFormattedException(Error): # noqa: N818
|
|
69
73
|
"""Exceptions with Markdown in their description.
|
|
70
74
|
|
|
71
75
|
Instances of this class can use markdown in their messages, which will get
|
|
@@ -104,7 +108,7 @@ class StreamlitAuthError(StreamlitAPIException):
|
|
|
104
108
|
class StreamlitDuplicateElementId(DuplicateWidgetID):
|
|
105
109
|
"""An exception raised when the auto-generated ID of an element is not unique."""
|
|
106
110
|
|
|
107
|
-
def __init__(self, element_type: str):
|
|
111
|
+
def __init__(self, element_type: str) -> None:
|
|
108
112
|
super().__init__(
|
|
109
113
|
f"There are multiple `{element_type}` elements with the same "
|
|
110
114
|
"auto-generated ID. When this element is created, it is assigned an "
|
|
@@ -118,7 +122,7 @@ class StreamlitDuplicateElementId(DuplicateWidgetID):
|
|
|
118
122
|
class StreamlitDuplicateElementKey(DuplicateWidgetID):
|
|
119
123
|
"""An exception raised when the key of an element is not unique."""
|
|
120
124
|
|
|
121
|
-
def __init__(self, user_key: str):
|
|
125
|
+
def __init__(self, user_key: str) -> None:
|
|
122
126
|
super().__init__(
|
|
123
127
|
f"There are multiple elements with the same `key='{user_key}'`. "
|
|
124
128
|
"To fix this, please make sure that the `key` argument is unique for "
|
|
@@ -137,7 +141,7 @@ class StreamlitAPIWarning(StreamlitAPIException, Warning):
|
|
|
137
141
|
instead.
|
|
138
142
|
"""
|
|
139
143
|
|
|
140
|
-
def __init__(self, *args):
|
|
144
|
+
def __init__(self, *args: Any) -> None:
|
|
141
145
|
super().__init__(*args)
|
|
142
146
|
import inspect
|
|
143
147
|
import traceback
|
|
@@ -154,7 +158,7 @@ class StreamlitModuleNotFoundError(StreamlitAPIWarning):
|
|
|
154
158
|
that is not one of our core dependencies.
|
|
155
159
|
"""
|
|
156
160
|
|
|
157
|
-
def __init__(self, module_name, *args):
|
|
161
|
+
def __init__(self, module_name: str, *args: Any) -> None:
|
|
158
162
|
message = (
|
|
159
163
|
f'This Streamlit command requires module "{module_name}" to be installed.'
|
|
160
164
|
)
|
|
@@ -162,7 +166,7 @@ class StreamlitModuleNotFoundError(StreamlitAPIWarning):
|
|
|
162
166
|
|
|
163
167
|
|
|
164
168
|
class LocalizableStreamlitException(StreamlitAPIException):
|
|
165
|
-
def __init__(self, message: str, **kwargs):
|
|
169
|
+
def __init__(self, message: str, **kwargs: Any) -> None:
|
|
166
170
|
super().__init__((message).format(**kwargs))
|
|
167
171
|
self._exec_kwargs = kwargs
|
|
168
172
|
|
|
@@ -171,23 +175,10 @@ class LocalizableStreamlitException(StreamlitAPIException):
|
|
|
171
175
|
return self._exec_kwargs
|
|
172
176
|
|
|
173
177
|
|
|
174
|
-
# st.set_page_config
|
|
175
|
-
class StreamlitSetPageConfigMustBeFirstCommandError(LocalizableStreamlitException):
|
|
176
|
-
"""Exception raised when the set_page_config command is not the first executed streamlit command."""
|
|
177
|
-
|
|
178
|
-
def __init__(self):
|
|
179
|
-
super().__init__(
|
|
180
|
-
"`set_page_config()` can only be called once per app page, "
|
|
181
|
-
"and must be called as the first Streamlit command in your script.\n\n"
|
|
182
|
-
"For more information refer to the [docs]"
|
|
183
|
-
"(https://docs.streamlit.io/develop/api-reference/configuration/st.set_page_config)."
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
|
|
187
178
|
class StreamlitInvalidPageLayoutError(LocalizableStreamlitException):
|
|
188
179
|
"""Exception raised when an invalid value is specified for layout."""
|
|
189
180
|
|
|
190
|
-
def __init__(self, layout: str):
|
|
181
|
+
def __init__(self, layout: str) -> None:
|
|
191
182
|
super().__init__(
|
|
192
183
|
'`layout` must be `"centered"` or `"wide"` (got `"{layout}"`)',
|
|
193
184
|
layout=layout,
|
|
@@ -197,9 +188,10 @@ class StreamlitInvalidPageLayoutError(LocalizableStreamlitException):
|
|
|
197
188
|
class StreamlitInvalidSidebarStateError(LocalizableStreamlitException):
|
|
198
189
|
"""Exception raised when an invalid value is specified for `initial_sidebar_state`."""
|
|
199
190
|
|
|
200
|
-
def __init__(self, initial_sidebar_state: str):
|
|
191
|
+
def __init__(self, initial_sidebar_state: str) -> None:
|
|
201
192
|
super().__init__(
|
|
202
|
-
'`initial_sidebar_state` must be `"auto"` or `"expanded"` or
|
|
193
|
+
'`initial_sidebar_state` must be `"auto"` or `"expanded"` or '
|
|
194
|
+
'`"collapsed"` (got `"{initial_sidebar_state}"`)',
|
|
203
195
|
initial_sidebar_state=initial_sidebar_state,
|
|
204
196
|
)
|
|
205
197
|
|
|
@@ -207,7 +199,7 @@ class StreamlitInvalidSidebarStateError(LocalizableStreamlitException):
|
|
|
207
199
|
class StreamlitInvalidMenuItemKeyError(LocalizableStreamlitException):
|
|
208
200
|
"""Exception raised when an invalid key is specified."""
|
|
209
201
|
|
|
210
|
-
def __init__(self, key: str):
|
|
202
|
+
def __init__(self, key: str) -> None:
|
|
211
203
|
super().__init__(
|
|
212
204
|
'We only accept the keys: `"Get help"`, `"Report a bug"`, and `"About"` (`"{key}"` is not a valid key.)',
|
|
213
205
|
key=key,
|
|
@@ -217,7 +209,7 @@ class StreamlitInvalidMenuItemKeyError(LocalizableStreamlitException):
|
|
|
217
209
|
class StreamlitInvalidURLError(LocalizableStreamlitException):
|
|
218
210
|
"""Exception raised when an invalid URL is specified for any of the menu items except for “About”."""
|
|
219
211
|
|
|
220
|
-
def __init__(self, url: str):
|
|
212
|
+
def __init__(self, url: str) -> None:
|
|
221
213
|
super().__init__(
|
|
222
214
|
'"{url}" is a not a valid URL. '
|
|
223
215
|
'You must use a fully qualified domain beginning with "http://", "https://", or "mailto:".',
|
|
@@ -229,7 +221,7 @@ class StreamlitInvalidURLError(LocalizableStreamlitException):
|
|
|
229
221
|
class StreamlitInvalidColumnSpecError(LocalizableStreamlitException):
|
|
230
222
|
"""Exception raised when no weights are specified, or a negative weight is specified."""
|
|
231
223
|
|
|
232
|
-
def __init__(self):
|
|
224
|
+
def __init__(self) -> None:
|
|
233
225
|
super().__init__(
|
|
234
226
|
"The `spec` argument to `st.columns` must be either a "
|
|
235
227
|
"positive integer (number of columns) or a list of positive numbers (width ratios of the columns). "
|
|
@@ -241,7 +233,7 @@ class StreamlitInvalidColumnSpecError(LocalizableStreamlitException):
|
|
|
241
233
|
class StreamlitInvalidVerticalAlignmentError(LocalizableStreamlitException):
|
|
242
234
|
"""Exception raised when an invalid value is specified for vertical_alignment."""
|
|
243
235
|
|
|
244
|
-
def __init__(self, vertical_alignment: str):
|
|
236
|
+
def __init__(self, vertical_alignment: str) -> None:
|
|
245
237
|
super().__init__(
|
|
246
238
|
'The `vertical_alignment` argument to `st.columns` must be `"top"`, `"center"`, or `"bottom"`. \n'
|
|
247
239
|
"The argument passed was {vertical_alignment}.",
|
|
@@ -252,9 +244,9 @@ class StreamlitInvalidVerticalAlignmentError(LocalizableStreamlitException):
|
|
|
252
244
|
class StreamlitInvalidColumnGapError(LocalizableStreamlitException):
|
|
253
245
|
"""Exception raised when an invalid value is specified for gap."""
|
|
254
246
|
|
|
255
|
-
def __init__(self, gap: str):
|
|
247
|
+
def __init__(self, gap: str) -> None:
|
|
256
248
|
super().__init__(
|
|
257
|
-
'The `gap` argument to `st.columns` must be `"small"`, `"medium"`, or `"
|
|
249
|
+
'The `gap` argument to `st.columns` must be `"small"`, `"medium"`, `"large"`, or `"none"`. \n'
|
|
258
250
|
"The argument passed was {gap}.",
|
|
259
251
|
gap=gap,
|
|
260
252
|
)
|
|
@@ -264,7 +256,9 @@ class StreamlitInvalidColumnGapError(LocalizableStreamlitException):
|
|
|
264
256
|
class StreamlitSelectionCountExceedsMaxError(LocalizableStreamlitException):
|
|
265
257
|
"""Exception raised when there are more default selections specified than the max allowable selections."""
|
|
266
258
|
|
|
267
|
-
def __init__(
|
|
259
|
+
def __init__(
|
|
260
|
+
self, current_selections_count: int, max_selections_count: int
|
|
261
|
+
) -> None:
|
|
268
262
|
super().__init__(
|
|
269
263
|
"Multiselect has {current_selections_count} {current_selections_noun} "
|
|
270
264
|
"selected but `max_selections` is set to {max_selections_count}. "
|
|
@@ -291,7 +285,7 @@ class StreamlitMixedNumericTypesError(LocalizableStreamlitException):
|
|
|
291
285
|
min_value: int | float | None,
|
|
292
286
|
max_value: int | float | None,
|
|
293
287
|
step: int | float | None,
|
|
294
|
-
):
|
|
288
|
+
) -> None:
|
|
295
289
|
value_type = None
|
|
296
290
|
min_value_type = None
|
|
297
291
|
max_value_type = None
|
|
@@ -327,7 +321,11 @@ class StreamlitMixedNumericTypesError(LocalizableStreamlitException):
|
|
|
327
321
|
class StreamlitValueBelowMinError(LocalizableStreamlitException):
|
|
328
322
|
"""Exception raised when the `min_value` is greater than the `value`."""
|
|
329
323
|
|
|
330
|
-
def __init__(
|
|
324
|
+
def __init__(
|
|
325
|
+
self,
|
|
326
|
+
value: int | float | date | time,
|
|
327
|
+
min_value: int | float | date | time,
|
|
328
|
+
) -> None:
|
|
331
329
|
super().__init__(
|
|
332
330
|
"The `value` {value} is less than the `min_value` {min_value}.",
|
|
333
331
|
value=value,
|
|
@@ -338,7 +336,11 @@ class StreamlitValueBelowMinError(LocalizableStreamlitException):
|
|
|
338
336
|
class StreamlitValueAboveMaxError(LocalizableStreamlitException):
|
|
339
337
|
"""Exception raised when the `max_value` is less than the `value`."""
|
|
340
338
|
|
|
341
|
-
def __init__(
|
|
339
|
+
def __init__(
|
|
340
|
+
self,
|
|
341
|
+
value: int | float | date | time,
|
|
342
|
+
max_value: int | float | date | time,
|
|
343
|
+
) -> None:
|
|
342
344
|
super().__init__(
|
|
343
345
|
"The `value` {value} is greater than the `max_value` {max_value}.",
|
|
344
346
|
value=value,
|
|
@@ -349,7 +351,7 @@ class StreamlitValueAboveMaxError(LocalizableStreamlitException):
|
|
|
349
351
|
class StreamlitJSNumberBoundsError(LocalizableStreamlitException):
|
|
350
352
|
"""Exception raised when a number exceeds the Javascript limits."""
|
|
351
353
|
|
|
352
|
-
def __init__(self, message: str):
|
|
354
|
+
def __init__(self, message: str) -> None:
|
|
353
355
|
super().__init__(message)
|
|
354
356
|
|
|
355
357
|
|
|
@@ -358,7 +360,7 @@ class StreamlitInvalidNumberFormatError(LocalizableStreamlitException):
|
|
|
358
360
|
invalid characters.
|
|
359
361
|
"""
|
|
360
362
|
|
|
361
|
-
def __init__(self, format: str):
|
|
363
|
+
def __init__(self, format: str) -> None:
|
|
362
364
|
super().__init__(
|
|
363
365
|
"Format string for `st.number_input` contains invalid characters: {format}",
|
|
364
366
|
format=format,
|
|
@@ -369,7 +371,7 @@ class StreamlitInvalidNumberFormatError(LocalizableStreamlitException):
|
|
|
369
371
|
class StreamlitMissingPageLabelError(LocalizableStreamlitException):
|
|
370
372
|
"""Exception raised when a page_link is created without a label."""
|
|
371
373
|
|
|
372
|
-
def __init__(self):
|
|
374
|
+
def __init__(self) -> None:
|
|
373
375
|
super().__init__(
|
|
374
376
|
"The `label` param is required for external links used with `st.page_link` - please provide a `label`."
|
|
375
377
|
)
|
|
@@ -380,7 +382,7 @@ class StreamlitPageNotFoundError(LocalizableStreamlitException):
|
|
|
380
382
|
|
|
381
383
|
def __init__(
|
|
382
384
|
self, page: str, main_script_directory: str, uses_pages_directory: bool
|
|
383
|
-
):
|
|
385
|
+
) -> None:
|
|
384
386
|
directory = os.path.basename(main_script_directory)
|
|
385
387
|
|
|
386
388
|
message = (
|
|
@@ -408,14 +410,16 @@ class StreamlitPageNotFoundError(LocalizableStreamlitException):
|
|
|
408
410
|
class StreamlitFragmentWidgetsNotAllowedOutsideError(LocalizableStreamlitException):
|
|
409
411
|
"""Exception raised when the fragment attempts to write to an element outside of its container."""
|
|
410
412
|
|
|
411
|
-
def __init__(self):
|
|
413
|
+
def __init__(self) -> None:
|
|
412
414
|
super().__init__("Fragments cannot write widgets to outside containers.")
|
|
413
415
|
|
|
414
416
|
|
|
415
417
|
class StreamlitInvalidFormCallbackError(LocalizableStreamlitException):
|
|
416
|
-
"""Exception raised a `on_change` callback is set on any element in a form except for
|
|
418
|
+
"""Exception raised a `on_change` callback is set on any element in a form except for
|
|
419
|
+
the `st.form_submit_button`.
|
|
420
|
+
"""
|
|
417
421
|
|
|
418
|
-
def __init__(self):
|
|
422
|
+
def __init__(self) -> None:
|
|
419
423
|
super().__init__(
|
|
420
424
|
"Within a form, callbacks can only be defined on `st.form_submit_button`. "
|
|
421
425
|
"Defining callbacks on other widgets inside a form is not allowed."
|
|
@@ -425,7 +429,7 @@ class StreamlitInvalidFormCallbackError(LocalizableStreamlitException):
|
|
|
425
429
|
class StreamlitValueAssignmentNotAllowedError(LocalizableStreamlitException):
|
|
426
430
|
"""Exception raised when trying to set values where writes are not allowed."""
|
|
427
431
|
|
|
428
|
-
def __init__(self, key: str):
|
|
432
|
+
def __init__(self, key: str) -> None:
|
|
429
433
|
super().__init__(
|
|
430
434
|
"Values for the widget with `key` '{key}' cannot be set using `st.session_state`.",
|
|
431
435
|
key=key,
|
|
@@ -433,7 +437,9 @@ class StreamlitValueAssignmentNotAllowedError(LocalizableStreamlitException):
|
|
|
433
437
|
|
|
434
438
|
|
|
435
439
|
class StreamlitInvalidColorError(LocalizableStreamlitException):
|
|
436
|
-
def __init__(
|
|
440
|
+
def __init__(
|
|
441
|
+
self, color: str | Collection[Any] | tuple[int, int, int, int]
|
|
442
|
+
) -> None:
|
|
437
443
|
super().__init__(
|
|
438
444
|
"This does not look like a valid color: {color}.\n\n"
|
|
439
445
|
"Colors must be in one of the following formats:"
|
|
@@ -446,7 +452,7 @@ class StreamlitInvalidColorError(LocalizableStreamlitException):
|
|
|
446
452
|
class StreamlitBadTimeStringError(LocalizableStreamlitException):
|
|
447
453
|
"""Exception Raised when a time string argument is passed that cannot be parsed."""
|
|
448
454
|
|
|
449
|
-
def __init__(self, time_string: str):
|
|
455
|
+
def __init__(self, time_string: str) -> None:
|
|
450
456
|
super().__init__(
|
|
451
457
|
"Time string doesn't look right. It should be formatted as"
|
|
452
458
|
"`'1d2h34m'` or `2 days`, for example. Got: {time_string}",
|
|
@@ -457,14 +463,14 @@ class StreamlitBadTimeStringError(LocalizableStreamlitException):
|
|
|
457
463
|
class StreamlitSecretNotFoundError(LocalizableStreamlitException, FileNotFoundError):
|
|
458
464
|
"""Exception raised when a secret cannot be found or parsed in the secrets.toml file."""
|
|
459
465
|
|
|
460
|
-
def __init__(self, message: str):
|
|
466
|
+
def __init__(self, message: str) -> None:
|
|
461
467
|
super().__init__(message)
|
|
462
468
|
|
|
463
469
|
|
|
464
470
|
class StreamlitInvalidWidthError(LocalizableStreamlitException):
|
|
465
471
|
"""Exception raised when an invalid width value is provided."""
|
|
466
472
|
|
|
467
|
-
def __init__(self, width: Any, allow_content: bool = False):
|
|
473
|
+
def __init__(self, width: Any, allow_content: bool = False) -> None:
|
|
468
474
|
valid_values = "an integer (pixels) or 'stretch'"
|
|
469
475
|
if allow_content:
|
|
470
476
|
valid_values = "an integer (pixels), 'stretch', or 'content'"
|
|
@@ -474,3 +480,18 @@ class StreamlitInvalidWidthError(LocalizableStreamlitException):
|
|
|
474
480
|
width=repr(width),
|
|
475
481
|
valid_values=valid_values,
|
|
476
482
|
)
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
class StreamlitInvalidHeightError(LocalizableStreamlitException):
|
|
486
|
+
"""Exception raised when an invalid height value is provided."""
|
|
487
|
+
|
|
488
|
+
def __init__(self, height: Any, allow_content: bool = False) -> None:
|
|
489
|
+
valid_values = "an integer (pixels) or 'stretch'"
|
|
490
|
+
if allow_content:
|
|
491
|
+
valid_values = "an integer (pixels), 'stretch', or 'content'"
|
|
492
|
+
|
|
493
|
+
super().__init__(
|
|
494
|
+
"Invalid height value: {height}. Height must be either {valid_values}.",
|
|
495
|
+
height=repr(height),
|
|
496
|
+
valid_values=valid_values,
|
|
497
|
+
)
|
|
@@ -36,6 +36,10 @@ This module is lazy-loaded.
|
|
|
36
36
|
# by default.
|
|
37
37
|
# mypy: disable-error-code="import-not-found, unused-ignore, misc"
|
|
38
38
|
|
|
39
|
+
# Deactivate unused argument errors for this file since we need lots of
|
|
40
|
+
# unused arguments to comply with the LangChain callback interface.
|
|
41
|
+
# ruff: noqa: ARG002
|
|
42
|
+
|
|
39
43
|
from __future__ import annotations
|
|
40
44
|
|
|
41
45
|
import time
|
|
@@ -151,7 +155,7 @@ class LLMThought:
|
|
|
151
155
|
labeler: LLMThoughtLabeler,
|
|
152
156
|
expanded: bool,
|
|
153
157
|
collapse_on_complete: bool,
|
|
154
|
-
):
|
|
158
|
+
) -> None:
|
|
155
159
|
self._container = parent_container.status(
|
|
156
160
|
labeler.get_initial_label(), expanded=expanded
|
|
157
161
|
)
|
|
@@ -246,9 +250,10 @@ class LLMThought:
|
|
|
246
250
|
def complete(self, final_label: str | None = None) -> None:
|
|
247
251
|
"""Finish the thought."""
|
|
248
252
|
if final_label is None and self._state == LLMThoughtState.RUNNING_TOOL:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
253
|
+
if self._last_tool is None:
|
|
254
|
+
raise RuntimeError(
|
|
255
|
+
"_last_tool should never be null when _state == RUNNING_TOOL"
|
|
256
|
+
)
|
|
252
257
|
final_label = self._labeler.get_tool_label(
|
|
253
258
|
self._last_tool, is_complete=True
|
|
254
259
|
)
|
|
@@ -279,7 +284,7 @@ class StreamlitCallbackHandler(BaseCallbackHandler):
|
|
|
279
284
|
expand_new_thoughts: bool = False,
|
|
280
285
|
collapse_completed_thoughts: bool = False,
|
|
281
286
|
thought_labeler: LLMThoughtLabeler | None = None,
|
|
282
|
-
):
|
|
287
|
+
) -> None:
|
|
283
288
|
"""Construct a new StreamlitCallbackHandler. This CallbackHandler is geared
|
|
284
289
|
towards use with a LangChain Agent; it displays the Agent's LLM and tool-usage
|
|
285
290
|
"thoughts" inside a series of Streamlit expanders.
|
streamlit/file_util.py
CHANGED
|
@@ -19,15 +19,19 @@ import errno
|
|
|
19
19
|
import io
|
|
20
20
|
import os
|
|
21
21
|
from pathlib import Path
|
|
22
|
+
from typing import IO, TYPE_CHECKING, Any, Final
|
|
22
23
|
|
|
23
24
|
from streamlit import env_util, errors
|
|
24
25
|
from streamlit.string_util import is_binary_string
|
|
25
26
|
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
from collections.abc import Generator
|
|
29
|
+
|
|
26
30
|
# Configuration and credentials are stored inside the ~/.streamlit folder
|
|
27
|
-
CONFIG_FOLDER_NAME = ".streamlit"
|
|
31
|
+
CONFIG_FOLDER_NAME: Final = ".streamlit"
|
|
28
32
|
|
|
29
33
|
# If enableStaticServing is enabled, static file served from the ./static folder
|
|
30
|
-
APP_STATIC_FOLDER_NAME = "static"
|
|
34
|
+
APP_STATIC_FOLDER_NAME: Final = "static"
|
|
31
35
|
|
|
32
36
|
|
|
33
37
|
def get_encoded_file_data(
|
|
@@ -62,7 +66,7 @@ def get_encoded_file_data(
|
|
|
62
66
|
|
|
63
67
|
|
|
64
68
|
@contextlib.contextmanager
|
|
65
|
-
def streamlit_read(path, binary=False):
|
|
69
|
+
def streamlit_read(path: str, binary: bool = False) -> Generator[IO[Any], None, None]:
|
|
66
70
|
"""Opens a context to read this file relative to the streamlit path.
|
|
67
71
|
|
|
68
72
|
For example:
|
|
@@ -87,7 +91,7 @@ def streamlit_read(path, binary=False):
|
|
|
87
91
|
|
|
88
92
|
|
|
89
93
|
@contextlib.contextmanager
|
|
90
|
-
def streamlit_write(path, binary=False):
|
|
94
|
+
def streamlit_write(path: str, binary: bool = False) -> Generator[IO[Any], None, None]:
|
|
91
95
|
"""Opens a file for writing within the streamlit path, and
|
|
92
96
|
ensuring that the path exists.
|
|
93
97
|
|
|
@@ -128,12 +132,11 @@ def get_static_dir() -> str:
|
|
|
128
132
|
|
|
129
133
|
def get_app_static_dir(main_script_path: str) -> str:
|
|
130
134
|
"""Get the folder where app static files live."""
|
|
131
|
-
|
|
132
|
-
static_dir = main_script_path.parent / APP_STATIC_FOLDER_NAME
|
|
135
|
+
static_dir = Path(main_script_path).parent / APP_STATIC_FOLDER_NAME
|
|
133
136
|
return os.path.abspath(static_dir)
|
|
134
137
|
|
|
135
138
|
|
|
136
|
-
def get_streamlit_file_path(*filepath) -> str:
|
|
139
|
+
def get_streamlit_file_path(*filepath: str) -> str:
|
|
137
140
|
"""Return the full path to a file in ~/.streamlit.
|
|
138
141
|
|
|
139
142
|
This doesn't guarantee that the file (or its directory) exists.
|
|
@@ -145,7 +148,7 @@ def get_streamlit_file_path(*filepath) -> str:
|
|
|
145
148
|
return str(home / CONFIG_FOLDER_NAME / Path(*filepath))
|
|
146
149
|
|
|
147
150
|
|
|
148
|
-
def get_project_streamlit_file_path(*filepath):
|
|
151
|
+
def get_project_streamlit_file_path(*filepath: str) -> str:
|
|
149
152
|
"""Return the full path to a filepath in ${CWD}/.streamlit.
|
|
150
153
|
|
|
151
154
|
This doesn't guarantee that the file (or its directory) exists.
|
|
@@ -153,6 +156,20 @@ def get_project_streamlit_file_path(*filepath):
|
|
|
153
156
|
return str(Path.cwd() / CONFIG_FOLDER_NAME / Path(*filepath))
|
|
154
157
|
|
|
155
158
|
|
|
159
|
+
def get_main_script_streamlit_file_path(main_script_path: str, filename: str) -> str:
|
|
160
|
+
"""Return the full path to a file in the .streamlit folder relative to the
|
|
161
|
+
main script's path.
|
|
162
|
+
|
|
163
|
+
This doesn't guarantee that the file (or its directory) exists.
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
return str(
|
|
167
|
+
Path(os.path.abspath(os.path.dirname(main_script_path)))
|
|
168
|
+
/ CONFIG_FOLDER_NAME
|
|
169
|
+
/ filename
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
|
|
156
173
|
def file_is_in_folder_glob(filepath: str, folderpath_glob: str) -> bool:
|
|
157
174
|
"""Test whether a file is in some folder with globbing support.
|
|
158
175
|
|
|
@@ -214,7 +231,7 @@ def file_in_pythonpath(filepath: str) -> bool:
|
|
|
214
231
|
)
|
|
215
232
|
|
|
216
233
|
|
|
217
|
-
def normalize_path_join(*args):
|
|
234
|
+
def normalize_path_join(*args: str) -> str:
|
|
218
235
|
"""Return the normalized path of the joined path.
|
|
219
236
|
|
|
220
237
|
Parameters
|
|
@@ -230,7 +247,7 @@ def normalize_path_join(*args):
|
|
|
230
247
|
return os.path.normpath(os.path.join(*args))
|
|
231
248
|
|
|
232
249
|
|
|
233
|
-
def get_main_script_directory(main_script):
|
|
250
|
+
def get_main_script_directory(main_script: str) -> str:
|
|
234
251
|
"""Return the full path to the main script directory.
|
|
235
252
|
|
|
236
253
|
Parameters
|
streamlit/git_util.py
CHANGED
|
@@ -16,10 +16,13 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import os
|
|
18
18
|
import re
|
|
19
|
-
from typing import
|
|
19
|
+
from typing import TYPE_CHECKING, cast
|
|
20
20
|
|
|
21
21
|
from streamlit import util
|
|
22
22
|
|
|
23
|
+
if TYPE_CHECKING:
|
|
24
|
+
from git import Commit, Remote, RemoteReference, Repo
|
|
25
|
+
|
|
23
26
|
# Github has two URLs, one that is https and one that is ssh
|
|
24
27
|
GITHUB_HTTP_URL = r"^https://(www\.)?github.com/(.+)/(.+)(?:.git)?$"
|
|
25
28
|
GITHUB_SSH_URL = r"^git@github.com:(.+)/(.+)(?:.git)?$"
|
|
@@ -31,19 +34,17 @@ MIN_GIT_VERSION = (2, 7, 0)
|
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
class GitRepo:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
repo: Repo | None
|
|
38
|
+
|
|
39
|
+
def __init__(self, path: str) -> None:
|
|
40
|
+
# If we have a valid repo, git_version will be a tuple
|
|
41
|
+
# of 3+ ints: (major, minor, patch, possible_additional_patch_number)
|
|
37
42
|
self.git_version: tuple[int, ...] | None = None
|
|
38
43
|
|
|
39
44
|
try:
|
|
40
45
|
import git
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
# type errors on Mac and Linux. We bypass type checking entirely
|
|
44
|
-
# by re-declaring the `git` import as an "Any".
|
|
45
|
-
git_package: Any = git
|
|
46
|
-
self.repo = git_package.Repo(path, search_parent_directories=True)
|
|
47
|
+
self.repo = git.Repo(path, search_parent_directories=True)
|
|
47
48
|
self.git_version = self.repo.git.version_info
|
|
48
49
|
|
|
49
50
|
if self.git_version >= MIN_GIT_VERSION:
|
|
@@ -69,8 +70,8 @@ class GitRepo:
|
|
|
69
70
|
)
|
|
70
71
|
|
|
71
72
|
@property
|
|
72
|
-
def tracking_branch(self):
|
|
73
|
-
if not self.is_valid():
|
|
73
|
+
def tracking_branch(self) -> RemoteReference | None:
|
|
74
|
+
if self.repo is None or not self.is_valid():
|
|
74
75
|
return None
|
|
75
76
|
|
|
76
77
|
if self.is_head_detached:
|
|
@@ -79,41 +80,45 @@ class GitRepo:
|
|
|
79
80
|
return self.repo.active_branch.tracking_branch()
|
|
80
81
|
|
|
81
82
|
@property
|
|
82
|
-
def untracked_files(self):
|
|
83
|
-
if not self.is_valid():
|
|
83
|
+
def untracked_files(self) -> list[str] | None:
|
|
84
|
+
if self.repo is None or not self.is_valid():
|
|
84
85
|
return None
|
|
85
86
|
|
|
86
87
|
return self.repo.untracked_files
|
|
87
88
|
|
|
88
89
|
@property
|
|
89
|
-
def is_head_detached(self):
|
|
90
|
-
if not self.is_valid():
|
|
90
|
+
def is_head_detached(self) -> bool:
|
|
91
|
+
if self.repo is None or not self.is_valid():
|
|
91
92
|
return False
|
|
92
93
|
|
|
93
94
|
return self.repo.head.is_detached
|
|
94
95
|
|
|
95
96
|
@property
|
|
96
|
-
def uncommitted_files(self):
|
|
97
|
-
if not self.is_valid():
|
|
97
|
+
def uncommitted_files(self) -> list[str] | None:
|
|
98
|
+
if self.repo is None or not self.is_valid():
|
|
98
99
|
return None
|
|
99
100
|
|
|
100
|
-
return [item.a_path for item in self.repo.index.diff(None)]
|
|
101
|
+
return [cast("str", item.a_path) for item in self.repo.index.diff(None)]
|
|
101
102
|
|
|
102
103
|
@property
|
|
103
|
-
def ahead_commits(self):
|
|
104
|
-
if not self.is_valid():
|
|
104
|
+
def ahead_commits(self) -> list[Commit] | None:
|
|
105
|
+
if self.repo is None or not self.is_valid():
|
|
105
106
|
return None
|
|
106
107
|
|
|
107
108
|
try:
|
|
108
|
-
|
|
109
|
+
tracking_branch_info = self.get_tracking_branch_remote()
|
|
110
|
+
if tracking_branch_info is None:
|
|
111
|
+
return None
|
|
112
|
+
|
|
113
|
+
remote, branch_name = tracking_branch_info
|
|
109
114
|
remote_branch = f"{remote.name}/{branch_name}"
|
|
110
115
|
|
|
111
116
|
return list(self.repo.iter_commits(f"{remote_branch}..{branch_name}"))
|
|
112
117
|
except Exception:
|
|
113
118
|
return []
|
|
114
119
|
|
|
115
|
-
def get_tracking_branch_remote(self):
|
|
116
|
-
if not self.is_valid():
|
|
120
|
+
def get_tracking_branch_remote(self) -> tuple[Remote, str] | None:
|
|
121
|
+
if self.repo is None or not self.is_valid():
|
|
117
122
|
return None
|
|
118
123
|
|
|
119
124
|
tracking_branch = self.tracking_branch
|
|
@@ -145,7 +150,7 @@ class GitRepo:
|
|
|
145
150
|
|
|
146
151
|
return False
|
|
147
152
|
|
|
148
|
-
def get_repo_info(self):
|
|
153
|
+
def get_repo_info(self) -> tuple[str, str, str] | None:
|
|
149
154
|
if not self.is_valid():
|
|
150
155
|
return None
|
|
151
156
|
|
|
@@ -42,22 +42,22 @@ def animation_demo() -> None:
|
|
|
42
42
|
for frame_num, a in enumerate(np.linspace(0.0, 4 * np.pi, 100)):
|
|
43
43
|
# Here were setting value for these two elements.
|
|
44
44
|
progress_bar.progress(frame_num)
|
|
45
|
-
frame_text.text("Frame
|
|
45
|
+
frame_text.text(f"Frame {frame_num + 1}/100")
|
|
46
46
|
|
|
47
47
|
# Performing some fractal wizardry.
|
|
48
48
|
c = separation * np.exp(1j * a)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
z = np.tile(x, (n, 1)) + 1j * np.tile(y, (1, m))
|
|
50
|
+
c_matrix = np.full((n, m), c)
|
|
51
|
+
m_matrix: Any = np.full((n, m), True, dtype=bool)
|
|
52
|
+
n_matrix = np.zeros((n, m))
|
|
53
53
|
|
|
54
54
|
for i in range(iterations):
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
z[m_matrix] = z[m_matrix] * z[m_matrix] + c_matrix[m_matrix]
|
|
56
|
+
m_matrix[np.abs(z) > 2] = False
|
|
57
|
+
n_matrix[m_matrix] = i
|
|
58
58
|
|
|
59
59
|
# Update the image placeholder by calling the image() function on it.
|
|
60
|
-
image.image(1.0 - (
|
|
60
|
+
image.image(1.0 - (n_matrix / n_matrix.max()), use_container_width=True)
|
|
61
61
|
|
|
62
62
|
# We clear elements by calling empty on them.
|
|
63
63
|
progress_bar.empty()
|
|
@@ -21,15 +21,15 @@ import streamlit as st
|
|
|
21
21
|
from streamlit.hello.utils import show_code
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
def data_frame_demo():
|
|
24
|
+
def data_frame_demo() -> None:
|
|
25
25
|
@st.cache_data
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
df = pd.read_csv(
|
|
26
|
+
def get_un_data() -> pd.DataFrame:
|
|
27
|
+
aws_bucket_url = "https://streamlit-demo-data.s3-us-west-2.amazonaws.com"
|
|
28
|
+
df = pd.read_csv(aws_bucket_url + "/agri.csv.gz")
|
|
29
29
|
return df.set_index("Region")
|
|
30
30
|
|
|
31
31
|
try:
|
|
32
|
-
df =
|
|
32
|
+
df = get_un_data()
|
|
33
33
|
countries = st.multiselect(
|
|
34
34
|
"Choose countries", list(df.index), ["China", "United States of America"]
|
|
35
35
|
)
|