streamlit-nightly 1.35.1.dev20240610__py2.py3-none-any.whl → 1.35.1.dev20240611__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/__init__.py +5 -1
- streamlit/case_converters.py +2 -2
- streamlit/cli_util.py +2 -2
- streamlit/color_util.py +2 -2
- streamlit/commands/experimental_query_params.py +6 -8
- streamlit/commands/logo.py +4 -9
- streamlit/commands/navigation.py +6 -4
- streamlit/components/lib/local_component_registry.py +4 -2
- streamlit/components/types/base_component_registry.py +3 -2
- streamlit/components/v1/component_arrow.py +2 -1
- streamlit/components/v1/component_registry.py +6 -2
- streamlit/components/v1/components.py +4 -2
- streamlit/components/v1/custom_component.py +6 -6
- streamlit/config.py +15 -12
- streamlit/connections/snowflake_connection.py +2 -1
- streamlit/connections/snowpark_connection.py +2 -4
- streamlit/connections/sql_connection.py +2 -1
- streamlit/delta_generator.py +3 -4
- streamlit/elements/arrow.py +3 -6
- streamlit/elements/code.py +1 -1
- streamlit/elements/dialog_decorator.py +10 -8
- streamlit/elements/doc_string.py +1 -1
- streamlit/elements/exception.py +1 -1
- streamlit/elements/form.py +1 -1
- streamlit/elements/heading.py +1 -1
- streamlit/elements/html.py +1 -1
- streamlit/elements/image.py +5 -3
- streamlit/elements/layouts.py +7 -7
- streamlit/elements/lib/built_in_chart_utils.py +24 -12
- streamlit/elements/lib/column_config_utils.py +2 -1
- streamlit/elements/lib/dialog.py +8 -5
- streamlit/elements/lib/dicttools.py +3 -3
- streamlit/elements/lib/mutable_status_container.py +8 -5
- streamlit/elements/lib/pandas_styler_utils.py +2 -1
- streamlit/elements/lib/subtitle_utils.py +0 -1
- streamlit/elements/lib/utils.py +8 -10
- streamlit/elements/plotly_chart.py +5 -10
- streamlit/elements/pyplot.py +0 -1
- streamlit/elements/toast.py +2 -2
- streamlit/elements/vega_charts.py +46 -10
- streamlit/elements/widgets/color_picker.py +6 -4
- streamlit/elements/widgets/file_uploader.py +4 -8
- streamlit/elements/widgets/multiselect.py +2 -4
- streamlit/elements/widgets/number_input.py +4 -8
- streamlit/elements/widgets/select_slider.py +1 -1
- streamlit/elements/widgets/slider.py +2 -5
- streamlit/elements/widgets/time_widgets.py +5 -5
- streamlit/errors.py +1 -6
- streamlit/git_util.py +2 -2
- streamlit/hello/Animation_Demo.py +0 -1
- streamlit/logger.py +1 -1
- streamlit/navigation/page.py +6 -1
- streamlit/net_util.py +2 -5
- streamlit/proto/AutoRerun_pb2.py +3 -2
- streamlit/runtime/app_session.py +7 -7
- streamlit/runtime/caching/__init__.py +9 -13
- streamlit/runtime/caching/cache_data_api.py +18 -7
- streamlit/runtime/caching/cache_errors.py +8 -6
- streamlit/runtime/caching/cache_resource_api.py +10 -9
- streamlit/runtime/caching/cache_utils.py +10 -7
- streamlit/runtime/caching/cached_message_replay.py +10 -9
- streamlit/runtime/caching/hashing.py +3 -3
- streamlit/runtime/caching/storage/cache_storage_protocol.py +1 -1
- streamlit/runtime/connection_factory.py +4 -2
- streamlit/runtime/credentials.py +11 -20
- streamlit/runtime/forward_msg_cache.py +10 -11
- streamlit/runtime/forward_msg_queue.py +6 -4
- streamlit/runtime/fragment.py +7 -9
- streamlit/runtime/media_file_manager.py +4 -4
- streamlit/runtime/memory_media_file_storage.py +7 -8
- streamlit/runtime/metrics_util.py +2 -4
- streamlit/runtime/pages_manager.py +41 -41
- streamlit/runtime/runtime.py +4 -4
- streamlit/runtime/runtime_util.py +7 -12
- streamlit/runtime/scriptrunner/magic.py +1 -1
- streamlit/runtime/scriptrunner/script_requests.py +4 -2
- streamlit/runtime/scriptrunner/script_run_context.py +15 -15
- streamlit/runtime/scriptrunner/script_runner.py +8 -8
- streamlit/runtime/secrets.py +3 -5
- streamlit/runtime/session_manager.py +8 -7
- streamlit/runtime/state/common.py +1 -1
- streamlit/runtime/state/query_params_proxy.py +5 -10
- streamlit/runtime/state/safe_session_state.py +8 -7
- streamlit/runtime/state/widgets.py +27 -27
- streamlit/runtime/stats.py +1 -1
- streamlit/runtime/uploaded_file_manager.py +4 -2
- streamlit/runtime/websocket_session_manager.py +6 -4
- streamlit/string_util.py +1 -1
- streamlit/testing/v1/app_test.py +4 -2
- streamlit/testing/v1/element_tree.py +33 -37
- streamlit/testing/v1/local_script_runner.py +7 -7
- streamlit/time_util.py +2 -4
- streamlit/type_util.py +16 -29
- streamlit/user_info.py +4 -2
- streamlit/util.py +1 -1
- streamlit/watcher/event_based_path_watcher.py +6 -3
- streamlit/watcher/local_sources_watcher.py +11 -7
- streamlit/web/bootstrap.py +1 -1
- streamlit/web/cache_storage_manager_config.py +5 -1
- streamlit/web/cli.py +9 -4
- streamlit/web/server/browser_websocket_handler.py +7 -8
- streamlit/web/server/component_request_handler.py +4 -2
- streamlit/web/server/routes.py +3 -3
- streamlit/web/server/server.py +12 -12
- streamlit/web/server/server_util.py +5 -6
- streamlit/web/server/stats_request_handler.py +1 -1
- streamlit/web/server/upload_file_request_handler.py +5 -3
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/RECORD +113 -113
- {streamlit_nightly-1.35.1.dev20240610.data → streamlit_nightly-1.35.1.dev20240611.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/top_level.txt +0 -0
@@ -25,16 +25,16 @@ from typing_extensions import TypeAlias
|
|
25
25
|
from streamlit import runtime
|
26
26
|
from streamlit.errors import StreamlitAPIException
|
27
27
|
from streamlit.logger import get_logger
|
28
|
-
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
29
|
-
from streamlit.proto.PageProfile_pb2 import Command
|
30
|
-
from streamlit.runtime.scriptrunner.script_requests import ScriptRequests
|
31
|
-
from streamlit.runtime.state import SafeSessionState
|
32
|
-
from streamlit.runtime.uploaded_file_manager import UploadedFileManager
|
33
28
|
|
34
29
|
if TYPE_CHECKING:
|
30
|
+
from streamlit.cursor import RunningCursor
|
31
|
+
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
32
|
+
from streamlit.proto.PageProfile_pb2 import Command
|
35
33
|
from streamlit.runtime.fragment import FragmentStorage
|
36
34
|
from streamlit.runtime.pages_manager import PagesManager
|
37
|
-
|
35
|
+
from streamlit.runtime.scriptrunner.script_requests import ScriptRequests
|
36
|
+
from streamlit.runtime.state import SafeSessionState
|
37
|
+
from streamlit.runtime.uploaded_file_manager import UploadedFileManager
|
38
38
|
_LOGGER: Final = get_logger(__name__)
|
39
39
|
|
40
40
|
UserInfo: TypeAlias = Dict[str, Union[str, None]]
|
@@ -62,8 +62,8 @@ class ScriptRunContext:
|
|
62
62
|
uploaded_file_mgr: UploadedFileManager
|
63
63
|
main_script_path: str
|
64
64
|
user_info: UserInfo
|
65
|
-
fragment_storage:
|
66
|
-
pages_manager:
|
65
|
+
fragment_storage: FragmentStorage
|
66
|
+
pages_manager: PagesManager
|
67
67
|
|
68
68
|
gather_usage_stats: bool = False
|
69
69
|
command_tracking_deactivated: bool = False
|
@@ -74,7 +74,7 @@ class ScriptRunContext:
|
|
74
74
|
widget_ids_this_run: set[str] = field(default_factory=set)
|
75
75
|
widget_user_keys_this_run: set[str] = field(default_factory=set)
|
76
76
|
form_ids_this_run: set[str] = field(default_factory=set)
|
77
|
-
cursors: dict[int,
|
77
|
+
cursors: dict[int, RunningCursor] = field(default_factory=dict)
|
78
78
|
script_requests: ScriptRequests | None = None
|
79
79
|
current_fragment_id: str | None = None
|
80
80
|
fragment_ids_this_run: set[str] | None = None
|
@@ -139,9 +139,9 @@ class ScriptRunContext:
|
|
139
139
|
if msg.HasField("page_config_changed") and not self._set_page_config_allowed:
|
140
140
|
raise StreamlitAPIException(
|
141
141
|
"`set_page_config()` can only be called once per app page, "
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
"and must be called as the first Streamlit command in your script.\n\n"
|
143
|
+
"For more information refer to the [docs]"
|
144
|
+
"(https://docs.streamlit.io/library/api-reference/utilities/st.set_page_config)."
|
145
145
|
)
|
146
146
|
|
147
147
|
# We want to disallow set_page config if one of the following occurs:
|
@@ -161,8 +161,8 @@ class ScriptRunContext:
|
|
161
161
|
if self._experimental_query_params_used and self._production_query_params_used:
|
162
162
|
raise StreamlitAPIException(
|
163
163
|
"Using `st.query_params` together with either `st.experimental_get_query_params` "
|
164
|
-
|
165
|
-
|
164
|
+
"or `st.experimental_set_query_params` is not supported. Please convert your app "
|
165
|
+
"to only use `st.query_params`"
|
166
166
|
)
|
167
167
|
|
168
168
|
def mark_experimental_query_params_used(self):
|
@@ -233,4 +233,4 @@ def get_script_run_ctx(suppress_warning: bool = False) -> ScriptRunContext | Non
|
|
233
233
|
|
234
234
|
|
235
235
|
# Needed to avoid circular dependencies while running tests.
|
236
|
-
import streamlit
|
236
|
+
import streamlit # noqa: E402, F401
|
@@ -25,12 +25,11 @@ from typing import TYPE_CHECKING, Callable, Final
|
|
25
25
|
|
26
26
|
from blinker import Signal
|
27
27
|
|
28
|
-
from streamlit import config, runtime,
|
28
|
+
from streamlit import config, runtime, util
|
29
29
|
from streamlit.error_util import handle_uncaught_app_exception
|
30
30
|
from streamlit.logger import get_logger
|
31
31
|
from streamlit.proto.ClientState_pb2 import ClientState
|
32
32
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
33
|
-
from streamlit.runtime.scriptrunner.script_cache import ScriptCache
|
34
33
|
from streamlit.runtime.scriptrunner.script_requests import (
|
35
34
|
RerunData,
|
36
35
|
ScriptRequests,
|
@@ -46,18 +45,19 @@ from streamlit.runtime.state import (
|
|
46
45
|
SafeSessionState,
|
47
46
|
SessionState,
|
48
47
|
)
|
49
|
-
from streamlit.runtime.uploaded_file_manager import UploadedFileManager
|
50
48
|
from streamlit.vendor.ipython.modified_sys_path import modified_sys_path
|
51
49
|
|
52
50
|
if TYPE_CHECKING:
|
53
51
|
from streamlit.runtime.fragment import FragmentStorage
|
54
52
|
from streamlit.runtime.pages_manager import PagesManager
|
53
|
+
from streamlit.runtime.scriptrunner.script_cache import ScriptCache
|
54
|
+
from streamlit.runtime.uploaded_file_manager import UploadedFileManager
|
55
55
|
|
56
56
|
_LOGGER: Final = get_logger(__name__)
|
57
57
|
|
58
58
|
|
59
59
|
class ScriptRunnerEvent(Enum):
|
60
|
-
|
60
|
+
# "Control" events. These are emitted when the ScriptRunner's state changes.
|
61
61
|
|
62
62
|
# The script started running.
|
63
63
|
SCRIPT_STARTED = "SCRIPT_STARTED"
|
@@ -80,8 +80,8 @@ class ScriptRunnerEvent(Enum):
|
|
80
80
|
# is shut down.
|
81
81
|
SHUTDOWN = "SHUTDOWN"
|
82
82
|
|
83
|
-
|
84
|
-
|
83
|
+
# "Data" events. These are emitted when the ScriptRunner's script has
|
84
|
+
# data to send to the frontend.
|
85
85
|
|
86
86
|
# The script has a ForwardMsg to send to the frontend.
|
87
87
|
ENQUEUE_FORWARD_MSG = "ENQUEUE_FORWARD_MSG"
|
@@ -114,8 +114,8 @@ class ScriptRunner:
|
|
114
114
|
script_cache: ScriptCache,
|
115
115
|
initial_rerun_data: RerunData,
|
116
116
|
user_info: dict[str, str | None],
|
117
|
-
fragment_storage:
|
118
|
-
pages_manager:
|
117
|
+
fragment_storage: FragmentStorage,
|
118
|
+
pages_manager: PagesManager,
|
119
119
|
):
|
120
120
|
"""Initialize the ScriptRunner.
|
121
121
|
|
streamlit/runtime/secrets.py
CHANGED
@@ -25,7 +25,6 @@ from typing import (
|
|
25
25
|
KeysView,
|
26
26
|
Mapping,
|
27
27
|
NoReturn,
|
28
|
-
Union,
|
29
28
|
ValuesView,
|
30
29
|
)
|
31
30
|
|
@@ -45,12 +44,11 @@ SECRETS_FILE_LOCS: Final[list[str]] = [
|
|
45
44
|
]
|
46
45
|
|
47
46
|
|
48
|
-
def _convert_to_dict(obj:
|
49
|
-
"""
|
47
|
+
def _convert_to_dict(obj: Mapping[str, Any] | AttrDict) -> dict[str, Any]:
|
48
|
+
"""Convert Mapping or AttrDict objects to dictionaries."""
|
50
49
|
if isinstance(obj, AttrDict):
|
51
50
|
return obj.to_dict()
|
52
|
-
|
53
|
-
return {k: _convert_to_dict(v) for k, v in obj.items()}
|
51
|
+
return {k: v.to_dict() if isinstance(v, AttrDict) else v for k, v in obj.items()}
|
54
52
|
|
55
53
|
|
56
54
|
def _missing_attr_error_message(attr_name: str) -> str:
|
@@ -16,13 +16,14 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
from abc import abstractmethod
|
18
18
|
from dataclasses import dataclass
|
19
|
-
from typing import Callable, Protocol, cast
|
20
|
-
|
21
|
-
|
22
|
-
from streamlit.
|
23
|
-
from streamlit.runtime.
|
24
|
-
from streamlit.runtime.
|
25
|
-
from streamlit.runtime.
|
19
|
+
from typing import TYPE_CHECKING, Callable, Protocol, cast
|
20
|
+
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
23
|
+
from streamlit.runtime.app_session import AppSession
|
24
|
+
from streamlit.runtime.script_data import ScriptData
|
25
|
+
from streamlit.runtime.scriptrunner.script_cache import ScriptCache
|
26
|
+
from streamlit.runtime.uploaded_file_manager import UploadedFileManager
|
26
27
|
|
27
28
|
|
28
29
|
class SessionClientDisconnectedError(Exception):
|
@@ -57,7 +57,6 @@ from streamlit.proto.Slider_pb2 import Slider
|
|
57
57
|
from streamlit.proto.TextArea_pb2 import TextArea
|
58
58
|
from streamlit.proto.TextInput_pb2 import TextInput
|
59
59
|
from streamlit.proto.TimeInput_pb2 import TimeInput
|
60
|
-
from streamlit.type_util import ValueFieldName
|
61
60
|
from streamlit.util import HASHLIB_KWARGS
|
62
61
|
|
63
62
|
if TYPE_CHECKING:
|
@@ -65,6 +64,7 @@ if TYPE_CHECKING:
|
|
65
64
|
|
66
65
|
from streamlit.runtime.scriptrunner.script_run_context import ScriptRunContext
|
67
66
|
from streamlit.runtime.state.widgets import NoValue
|
67
|
+
from streamlit.type_util import ValueFieldName
|
68
68
|
|
69
69
|
|
70
70
|
# Protobuf types for all widgets.
|
@@ -74,18 +74,15 @@ class QueryParamsProxy(MutableMapping[str, str]):
|
|
74
74
|
@overload
|
75
75
|
def update(
|
76
76
|
self, mapping: SupportsKeysAndGetItem[str, str | Iterable[str]], /, **kwds: str
|
77
|
-
) -> None:
|
78
|
-
...
|
77
|
+
) -> None: ...
|
79
78
|
|
80
79
|
@overload
|
81
80
|
def update(
|
82
81
|
self, keys_and_values: Iterable[tuple[str, str | Iterable[str]]], /, **kwds: str
|
83
|
-
) -> None:
|
84
|
-
...
|
82
|
+
) -> None: ...
|
85
83
|
|
86
84
|
@overload
|
87
|
-
def update(self, **kwds: str | Iterable[str]) -> None:
|
88
|
-
...
|
85
|
+
def update(self, **kwds: str | Iterable[str]) -> None: ...
|
89
86
|
|
90
87
|
def update(self, other=(), /, **kwds):
|
91
88
|
"""
|
@@ -167,14 +164,12 @@ class QueryParamsProxy(MutableMapping[str, str]):
|
|
167
164
|
@overload
|
168
165
|
def from_dict(
|
169
166
|
self, keys_and_values: Iterable[tuple[str, str | Iterable[str]]]
|
170
|
-
) -> None:
|
171
|
-
...
|
167
|
+
) -> None: ...
|
172
168
|
|
173
169
|
@overload
|
174
170
|
def from_dict(
|
175
171
|
self, mapping: SupportsKeysAndGetItem[str, str | Iterable[str]]
|
176
|
-
) -> None:
|
177
|
-
...
|
172
|
+
) -> None: ...
|
178
173
|
|
179
174
|
@gather_metrics("query_params.from_dict")
|
180
175
|
def from_dict(self, params):
|
@@ -16,13 +16,14 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
import threading
|
18
18
|
from contextlib import contextmanager
|
19
|
-
from typing import Any, Callable, Iterator
|
20
|
-
|
21
|
-
|
22
|
-
from streamlit.proto.WidgetStates_pb2 import
|
23
|
-
from streamlit.
|
24
|
-
from streamlit.runtime.state.
|
25
|
-
from streamlit.runtime.state.
|
19
|
+
from typing import TYPE_CHECKING, Any, Callable, Iterator
|
20
|
+
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
from streamlit.proto.WidgetStates_pb2 import WidgetState as WidgetStateProto
|
23
|
+
from streamlit.proto.WidgetStates_pb2 import WidgetStates as WidgetStatesProto
|
24
|
+
from streamlit.runtime.state.common import RegisterWidgetResult, T, WidgetMetadata
|
25
|
+
from streamlit.runtime.state.query_params import QueryParams
|
26
|
+
from streamlit.runtime.state.session_state import SessionState
|
26
27
|
|
27
28
|
|
28
29
|
class SafeSessionState:
|
@@ -34,10 +34,10 @@ from streamlit.runtime.state.common import (
|
|
34
34
|
WidgetSerializer,
|
35
35
|
user_key_from_widget_id,
|
36
36
|
)
|
37
|
-
from streamlit.type_util import ValueFieldName
|
38
37
|
|
39
38
|
if TYPE_CHECKING:
|
40
39
|
from streamlit.runtime.scriptrunner import ScriptRunContext
|
40
|
+
from streamlit.type_util import ValueFieldName
|
41
41
|
|
42
42
|
|
43
43
|
ElementType: TypeAlias = str
|
@@ -48,32 +48,32 @@ ElementType: TypeAlias = str
|
|
48
48
|
# not able to always rely on the proto as the type may be needed earlier.
|
49
49
|
# Thankfully, in these cases (when value_type == "trigger_value"), the static
|
50
50
|
# table here being slightly inaccurate should never pose a problem.
|
51
|
-
ELEMENT_TYPE_TO_VALUE_TYPE: Final[
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
51
|
+
ELEMENT_TYPE_TO_VALUE_TYPE: Final[Mapping[ElementType, ValueFieldName]] = (
|
52
|
+
MappingProxyType(
|
53
|
+
{
|
54
|
+
"button": "trigger_value",
|
55
|
+
"camera_input": "file_uploader_state_value",
|
56
|
+
"checkbox": "bool_value",
|
57
|
+
"chat_input": "string_trigger_value",
|
58
|
+
"color_picker": "string_value",
|
59
|
+
"component_instance": "json_value",
|
60
|
+
"data_editor": "string_value",
|
61
|
+
"dataframe": "string_value",
|
62
|
+
"date_input": "string_array_value",
|
63
|
+
"download_button": "trigger_value",
|
64
|
+
"file_uploader": "file_uploader_state_value",
|
65
|
+
"multiselect": "int_array_value",
|
66
|
+
"number_input": "double_value",
|
67
|
+
"plotly_chart": "string_value",
|
68
|
+
"radio": "int_value",
|
69
|
+
"selectbox": "int_value",
|
70
|
+
"slider": "double_array_value",
|
71
|
+
"text_area": "string_value",
|
72
|
+
"text_input": "string_value",
|
73
|
+
"time_input": "string_value",
|
74
|
+
"vega_lite_chart": "string_value",
|
75
|
+
}
|
76
|
+
)
|
77
77
|
)
|
78
78
|
|
79
79
|
|
streamlit/runtime/stats.py
CHANGED
@@ -76,7 +76,7 @@ def group_stats(stats: list[CacheStat]) -> list[CacheStat]:
|
|
76
76
|
CacheStat(
|
77
77
|
category_name=category_name,
|
78
78
|
cache_name=cache_name,
|
79
|
-
byte_length=sum(
|
79
|
+
byte_length=sum(item.byte_length for item in single_group_stats),
|
80
80
|
)
|
81
81
|
)
|
82
82
|
return result
|
@@ -16,12 +16,14 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
import io
|
18
18
|
from abc import abstractmethod
|
19
|
-
from typing import NamedTuple, Protocol, Sequence
|
19
|
+
from typing import TYPE_CHECKING, NamedTuple, Protocol, Sequence
|
20
20
|
|
21
21
|
from streamlit import util
|
22
|
-
from streamlit.proto.Common_pb2 import FileURLs as FileURLsProto
|
23
22
|
from streamlit.runtime.stats import CacheStatsProvider
|
24
23
|
|
24
|
+
if TYPE_CHECKING:
|
25
|
+
from streamlit.proto.Common_pb2 import FileURLs as FileURLsProto
|
26
|
+
|
25
27
|
|
26
28
|
class UploadedFileRec(NamedTuple):
|
27
29
|
"""Metadata and raw bytes for an uploaded file. Immutable."""
|
@@ -14,12 +14,10 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from typing import Callable, Final, List, cast
|
17
|
+
from typing import TYPE_CHECKING, Callable, Final, List, cast
|
18
18
|
|
19
19
|
from streamlit.logger import get_logger
|
20
20
|
from streamlit.runtime.app_session import AppSession
|
21
|
-
from streamlit.runtime.script_data import ScriptData
|
22
|
-
from streamlit.runtime.scriptrunner.script_cache import ScriptCache
|
23
21
|
from streamlit.runtime.session_manager import (
|
24
22
|
ActiveSessionInfo,
|
25
23
|
SessionClient,
|
@@ -27,7 +25,11 @@ from streamlit.runtime.session_manager import (
|
|
27
25
|
SessionManager,
|
28
26
|
SessionStorage,
|
29
27
|
)
|
30
|
-
|
28
|
+
|
29
|
+
if TYPE_CHECKING:
|
30
|
+
from streamlit.runtime.script_data import ScriptData
|
31
|
+
from streamlit.runtime.scriptrunner.script_cache import ScriptCache
|
32
|
+
from streamlit.runtime.uploaded_file_manager import UploadedFileManager
|
31
33
|
|
32
34
|
_LOGGER: Final = get_logger(__name__)
|
33
35
|
|
streamlit/string_util.py
CHANGED
streamlit/testing/v1/app_test.py
CHANGED
@@ -19,12 +19,11 @@ import tempfile
|
|
19
19
|
import textwrap
|
20
20
|
import traceback
|
21
21
|
from pathlib import Path
|
22
|
-
from typing import Any, Callable, Sequence
|
22
|
+
from typing import TYPE_CHECKING, Any, Callable, Sequence
|
23
23
|
from unittest.mock import MagicMock
|
24
24
|
from urllib import parse
|
25
25
|
|
26
26
|
from streamlit import source_util
|
27
|
-
from streamlit.proto.WidgetStates_pb2 import WidgetStates
|
28
27
|
from streamlit.runtime import Runtime
|
29
28
|
from streamlit.runtime.caching.storage.dummy_cache_storage import (
|
30
29
|
MemoryCacheStorageManager,
|
@@ -87,6 +86,9 @@ from streamlit.testing.v1.local_script_runner import LocalScriptRunner
|
|
87
86
|
from streamlit.testing.v1.util import patch_config_options
|
88
87
|
from streamlit.util import HASHLIB_KWARGS, calc_md5
|
89
88
|
|
89
|
+
if TYPE_CHECKING:
|
90
|
+
from streamlit.proto.WidgetStates_pb2 import WidgetStates
|
91
|
+
|
90
92
|
TMP_DIR = tempfile.TemporaryDirectory()
|
91
93
|
|
92
94
|
|
@@ -48,38 +48,38 @@ from streamlit.elements.widgets.time_widgets import (
|
|
48
48
|
_parse_date_value,
|
49
49
|
)
|
50
50
|
from streamlit.proto.Alert_pb2 import Alert as AlertProto
|
51
|
-
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
|
52
|
-
from streamlit.proto.Block_pb2 import Block as BlockProto
|
53
|
-
from streamlit.proto.Button_pb2 import Button as ButtonProto
|
54
|
-
from streamlit.proto.ChatInput_pb2 import ChatInput as ChatInputProto
|
55
51
|
from streamlit.proto.Checkbox_pb2 import Checkbox as CheckboxProto
|
56
|
-
from streamlit.proto.Code_pb2 import Code as CodeProto
|
57
|
-
from streamlit.proto.ColorPicker_pb2 import ColorPicker as ColorPickerProto
|
58
|
-
from streamlit.proto.DateInput_pb2 import DateInput as DateInputProto
|
59
|
-
from streamlit.proto.Element_pb2 import Element as ElementProto
|
60
|
-
from streamlit.proto.Exception_pb2 import Exception as ExceptionProto
|
61
|
-
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
62
|
-
from streamlit.proto.Heading_pb2 import Heading as HeadingProto
|
63
|
-
from streamlit.proto.Json_pb2 import Json as JsonProto
|
64
52
|
from streamlit.proto.Markdown_pb2 import Markdown as MarkdownProto
|
65
|
-
from streamlit.proto.Metric_pb2 import Metric as MetricProto
|
66
|
-
from streamlit.proto.MultiSelect_pb2 import MultiSelect as MultiSelectProto
|
67
|
-
from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
|
68
|
-
from streamlit.proto.Radio_pb2 import Radio as RadioProto
|
69
|
-
from streamlit.proto.Selectbox_pb2 import Selectbox as SelectboxProto
|
70
53
|
from streamlit.proto.Slider_pb2 import Slider as SliderProto
|
71
|
-
from streamlit.proto.Text_pb2 import Text as TextProto
|
72
|
-
from streamlit.proto.TextArea_pb2 import TextArea as TextAreaProto
|
73
|
-
from streamlit.proto.TextInput_pb2 import TextInput as TextInputProto
|
74
|
-
from streamlit.proto.TimeInput_pb2 import TimeInput as TimeInputProto
|
75
|
-
from streamlit.proto.Toast_pb2 import Toast as ToastProto
|
76
54
|
from streamlit.proto.WidgetStates_pb2 import WidgetState, WidgetStates
|
77
55
|
from streamlit.runtime.state.common import TESTING_KEY, user_key_from_widget_id
|
78
|
-
from streamlit.runtime.state.safe_session_state import SafeSessionState
|
79
56
|
|
80
57
|
if TYPE_CHECKING:
|
81
58
|
from pandas import DataFrame as PandasDataframe
|
82
59
|
|
60
|
+
from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
|
61
|
+
from streamlit.proto.Block_pb2 import Block as BlockProto
|
62
|
+
from streamlit.proto.Button_pb2 import Button as ButtonProto
|
63
|
+
from streamlit.proto.ChatInput_pb2 import ChatInput as ChatInputProto
|
64
|
+
from streamlit.proto.Code_pb2 import Code as CodeProto
|
65
|
+
from streamlit.proto.ColorPicker_pb2 import ColorPicker as ColorPickerProto
|
66
|
+
from streamlit.proto.DateInput_pb2 import DateInput as DateInputProto
|
67
|
+
from streamlit.proto.Element_pb2 import Element as ElementProto
|
68
|
+
from streamlit.proto.Exception_pb2 import Exception as ExceptionProto
|
69
|
+
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
70
|
+
from streamlit.proto.Heading_pb2 import Heading as HeadingProto
|
71
|
+
from streamlit.proto.Json_pb2 import Json as JsonProto
|
72
|
+
from streamlit.proto.Metric_pb2 import Metric as MetricProto
|
73
|
+
from streamlit.proto.MultiSelect_pb2 import MultiSelect as MultiSelectProto
|
74
|
+
from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
|
75
|
+
from streamlit.proto.Radio_pb2 import Radio as RadioProto
|
76
|
+
from streamlit.proto.Selectbox_pb2 import Selectbox as SelectboxProto
|
77
|
+
from streamlit.proto.Text_pb2 import Text as TextProto
|
78
|
+
from streamlit.proto.TextArea_pb2 import TextArea as TextAreaProto
|
79
|
+
from streamlit.proto.TextInput_pb2 import TextInput as TextInputProto
|
80
|
+
from streamlit.proto.TimeInput_pb2 import TimeInput as TimeInputProto
|
81
|
+
from streamlit.proto.Toast_pb2 import Toast as ToastProto
|
82
|
+
from streamlit.runtime.state.safe_session_state import SafeSessionState
|
83
83
|
from streamlit.testing.v1.app_test import AppTest
|
84
84
|
|
85
85
|
T = TypeVar("T")
|
@@ -125,8 +125,7 @@ class Element(ABC):
|
|
125
125
|
key: str | None
|
126
126
|
|
127
127
|
@abstractmethod
|
128
|
-
def __init__(self, proto: ElementProto, root: ElementTree):
|
129
|
-
...
|
128
|
+
def __init__(self, proto: ElementProto, root: ElementTree): ...
|
130
129
|
|
131
130
|
def __iter__(self):
|
132
131
|
yield self
|
@@ -199,8 +198,7 @@ class Widget(Element, ABC):
|
|
199
198
|
|
200
199
|
@property
|
201
200
|
@abstractmethod
|
202
|
-
def _widget_state(self) -> WidgetState:
|
203
|
-
...
|
201
|
+
def _widget_state(self) -> WidgetState: ...
|
204
202
|
|
205
203
|
|
206
204
|
El = TypeVar("El", bound=Element, covariant=True)
|
@@ -218,12 +216,10 @@ class ElementList(Generic[El]):
|
|
218
216
|
return len(self)
|
219
217
|
|
220
218
|
@overload
|
221
|
-
def __getitem__(self, idx: int) -> El:
|
222
|
-
...
|
219
|
+
def __getitem__(self, idx: int) -> El: ...
|
223
220
|
|
224
221
|
@overload
|
225
|
-
def __getitem__(self, idx: slice) -> ElementList[El]:
|
226
|
-
...
|
222
|
+
def __getitem__(self, idx: slice) -> ElementList[El]: ...
|
227
223
|
|
228
224
|
def __getitem__(self, idx: int | slice) -> El | ElementList[El]:
|
229
225
|
if isinstance(idx, slice):
|
@@ -251,7 +247,7 @@ class ElementList(Generic[El]):
|
|
251
247
|
W = TypeVar("W", bound=Widget, covariant=True)
|
252
248
|
|
253
249
|
|
254
|
-
class WidgetList(
|
250
|
+
class WidgetList(ElementList[W], Generic[W]):
|
255
251
|
def __call__(self, key: str) -> W:
|
256
252
|
for e in self._list:
|
257
253
|
if e.key == key:
|
@@ -1014,7 +1010,7 @@ class SelectSlider(Widget, Generic[T]):
|
|
1014
1010
|
except (ValueError, TypeError):
|
1015
1011
|
try:
|
1016
1012
|
v = serde.serialize([self.format_func(val) for val in self.value]) # type: ignore
|
1017
|
-
except:
|
1013
|
+
except: # noqa: E722
|
1018
1014
|
raise ValueError(f"Could not find index for {self.value}")
|
1019
1015
|
|
1020
1016
|
ws = WidgetState()
|
@@ -1586,7 +1582,7 @@ def repr_(self) -> str:
|
|
1586
1582
|
"""
|
1587
1583
|
classname = self.__class__.__name__
|
1588
1584
|
|
1589
|
-
defaults: list[Any] = [None, "", False, [], set(),
|
1585
|
+
defaults: list[Any] = [None, "", False, [], set(), {}]
|
1590
1586
|
|
1591
1587
|
if is_dataclass(self):
|
1592
1588
|
fields_vals = (
|
@@ -1600,11 +1596,11 @@ def repr_(self) -> str:
|
|
1600
1596
|
fields_vals = ((f, v) for (f, v) in self.__dict__.items() if v not in defaults)
|
1601
1597
|
|
1602
1598
|
reprs = []
|
1603
|
-
for
|
1599
|
+
for field_name, value in fields_vals:
|
1604
1600
|
if isinstance(value, dict):
|
1605
|
-
line = f"{
|
1601
|
+
line = f"{field_name}={format_dict(value)}"
|
1606
1602
|
else:
|
1607
|
-
line = f"{
|
1603
|
+
line = f"{field_name}={value!r}"
|
1608
1604
|
reprs.append(line)
|
1609
1605
|
|
1610
1606
|
reprs[0] = "\n" + reprs[0]
|
@@ -20,19 +20,19 @@ from typing import TYPE_CHECKING, Any
|
|
20
20
|
from urllib import parse
|
21
21
|
|
22
22
|
from streamlit import runtime
|
23
|
-
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
24
|
-
from streamlit.proto.WidgetStates_pb2 import WidgetStates
|
25
23
|
from streamlit.runtime.forward_msg_queue import ForwardMsgQueue
|
26
24
|
from streamlit.runtime.fragment import MemoryFragmentStorage
|
27
25
|
from streamlit.runtime.memory_uploaded_file_manager import MemoryUploadedFileManager
|
28
26
|
from streamlit.runtime.scriptrunner import RerunData, ScriptRunner, ScriptRunnerEvent
|
29
27
|
from streamlit.runtime.scriptrunner.script_cache import ScriptCache
|
30
|
-
from streamlit.runtime.scriptrunner.script_run_context import ScriptRunContext
|
31
|
-
from streamlit.runtime.state.safe_session_state import SafeSessionState
|
32
28
|
from streamlit.testing.v1.element_tree import ElementTree, parse_tree_from_messages
|
33
29
|
|
34
30
|
if TYPE_CHECKING:
|
31
|
+
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
32
|
+
from streamlit.proto.WidgetStates_pb2 import WidgetStates
|
35
33
|
from streamlit.runtime.pages_manager import PagesManager
|
34
|
+
from streamlit.runtime.scriptrunner.script_run_context import ScriptRunContext
|
35
|
+
from streamlit.runtime.state.safe_session_state import SafeSessionState
|
36
36
|
|
37
37
|
|
38
38
|
class LocalScriptRunner(ScriptRunner):
|
@@ -42,7 +42,7 @@ class LocalScriptRunner(ScriptRunner):
|
|
42
42
|
self,
|
43
43
|
script_path: str,
|
44
44
|
session_state: SafeSessionState,
|
45
|
-
pages_manager:
|
45
|
+
pages_manager: PagesManager,
|
46
46
|
args=None,
|
47
47
|
kwargs=None,
|
48
48
|
):
|
@@ -53,8 +53,8 @@ class LocalScriptRunner(ScriptRunner):
|
|
53
53
|
self.forward_msg_queue = ForwardMsgQueue()
|
54
54
|
self.script_path = script_path
|
55
55
|
self.session_state = session_state
|
56
|
-
self.args = args if args is not None else
|
57
|
-
self.kwargs = kwargs if kwargs is not None else
|
56
|
+
self.args = args if args is not None else ()
|
57
|
+
self.kwargs = kwargs if kwargs is not None else {}
|
58
58
|
|
59
59
|
super().__init__(
|
60
60
|
session_id="test session id",
|
streamlit/time_util.py
CHANGED
@@ -52,13 +52,11 @@ class BadTimeStringError(StreamlitAPIException):
|
|
52
52
|
@overload
|
53
53
|
def time_to_seconds(
|
54
54
|
t: float | timedelta | str | None, *, coerce_none_to_inf: Literal[False]
|
55
|
-
) -> float | None:
|
56
|
-
...
|
55
|
+
) -> float | None: ...
|
57
56
|
|
58
57
|
|
59
58
|
@overload
|
60
|
-
def time_to_seconds(t: float | timedelta | str | None) -> float:
|
61
|
-
...
|
59
|
+
def time_to_seconds(t: float | timedelta | str | None) -> float: ...
|
62
60
|
|
63
61
|
|
64
62
|
def time_to_seconds(
|