streamlit-nightly 1.35.1.dev20240610__py2.py3-none-any.whl → 1.35.1.dev20240612__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 +36 -13
- 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/proto/Block_pb2.py +24 -22
- streamlit/proto/Block_pb2.pyi +19 -1
- 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/static/asset-manifest.json +3 -3
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{8492.8ad745d1.chunk.js → 4335.b492cdb7.chunk.js} +1 -1
- streamlit/static/static/js/main.0ebf040e.js +2 -0
- 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.dev20240612.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240612.dist-info}/RECORD +120 -120
- streamlit/static/static/js/main.dc75074b.js +0 -2
- /streamlit/static/static/js/{main.dc75074b.js.LICENSE.txt → main.0ebf040e.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.35.1.dev20240610.data → streamlit_nightly-1.35.1.dev20240612.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240612.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240612.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240612.dist-info}/top_level.txt +0 -0
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(
|
streamlit/type_util.py
CHANGED
@@ -42,9 +42,7 @@ from typing import (
|
|
42
42
|
from typing_extensions import TypeAlias, TypeGuard
|
43
43
|
|
44
44
|
import streamlit as st
|
45
|
-
from streamlit import config, errors
|
46
|
-
from streamlit import logger as _logger
|
47
|
-
from streamlit import string_util
|
45
|
+
from streamlit import config, errors, logger, string_util
|
48
46
|
from streamlit.errors import StreamlitAPIException
|
49
47
|
|
50
48
|
if TYPE_CHECKING:
|
@@ -65,7 +63,7 @@ if TYPE_CHECKING:
|
|
65
63
|
# Maximum number of rows to request from an unevaluated (out-of-core) dataframe
|
66
64
|
MAX_UNEVALUATED_DF_ROWS = 10000
|
67
65
|
|
68
|
-
_LOGGER =
|
66
|
+
_LOGGER = logger.get_logger(__name__)
|
69
67
|
|
70
68
|
# The array value field names are part of the larger set of possible value
|
71
69
|
# field names. See the explanation for said set below. The message types
|
@@ -129,8 +127,7 @@ class DataFrameGenericAlias(Protocol[V_co]):
|
|
129
127
|
"""
|
130
128
|
|
131
129
|
@property
|
132
|
-
def iloc(self) -> _iLocIndexer:
|
133
|
-
...
|
130
|
+
def iloc(self) -> _iLocIndexer: ...
|
134
131
|
|
135
132
|
|
136
133
|
OptionSequence: TypeAlias = Union[
|
@@ -147,8 +144,7 @@ VegaLiteType = Literal["quantitative", "ordinal", "temporal", "nominal"]
|
|
147
144
|
|
148
145
|
|
149
146
|
class SupportsStr(Protocol):
|
150
|
-
def __str__(self) -> str:
|
151
|
-
...
|
147
|
+
def __str__(self) -> str: ...
|
152
148
|
|
153
149
|
|
154
150
|
def is_array_value_field_name(obj: object) -> TypeGuard[ArrayValueFieldName]:
|
@@ -158,20 +154,17 @@ def is_array_value_field_name(obj: object) -> TypeGuard[ArrayValueFieldName]:
|
|
158
154
|
@overload
|
159
155
|
def is_type(
|
160
156
|
obj: object, fqn_type_pattern: Literal["pydeck.bindings.deck.Deck"]
|
161
|
-
) -> TypeGuard[Deck]:
|
162
|
-
...
|
157
|
+
) -> TypeGuard[Deck]: ...
|
163
158
|
|
164
159
|
|
165
160
|
@overload
|
166
161
|
def is_type(
|
167
162
|
obj: object, fqn_type_pattern: Literal["plotly.graph_objs._figure.Figure"]
|
168
|
-
) -> TypeGuard[Figure]:
|
169
|
-
...
|
163
|
+
) -> TypeGuard[Figure]: ...
|
170
164
|
|
171
165
|
|
172
166
|
@overload
|
173
|
-
def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool:
|
174
|
-
...
|
167
|
+
def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool: ...
|
175
168
|
|
176
169
|
|
177
170
|
def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool:
|
@@ -344,7 +337,7 @@ def is_pyspark_data_object(obj: object) -> bool:
|
|
344
337
|
return (
|
345
338
|
is_type(obj, _PYSPARK_DF_TYPE_STR)
|
346
339
|
and hasattr(obj, "toPandas")
|
347
|
-
and callable(
|
340
|
+
and callable(obj.toPandas)
|
348
341
|
)
|
349
342
|
|
350
343
|
|
@@ -510,7 +503,7 @@ def is_function(x: object) -> TypeGuard[types.FunctionType]:
|
|
510
503
|
def is_namedtuple(x: object) -> TypeGuard[NamedTuple]:
|
511
504
|
t = type(x)
|
512
505
|
b = t.__bases__
|
513
|
-
if len(b) != 1 or b[0]
|
506
|
+
if len(b) != 1 or b[0] is not tuple:
|
514
507
|
return False
|
515
508
|
f = getattr(t, "_fields", None)
|
516
509
|
if not isinstance(f, tuple):
|
@@ -558,8 +551,7 @@ def convert_anything_to_df(
|
|
558
551
|
data: Any,
|
559
552
|
max_unevaluated_rows: int = MAX_UNEVALUATED_DF_ROWS,
|
560
553
|
ensure_copy: bool = False,
|
561
|
-
) -> DataFrame:
|
562
|
-
...
|
554
|
+
) -> DataFrame: ...
|
563
555
|
|
564
556
|
|
565
557
|
@overload
|
@@ -568,8 +560,7 @@ def convert_anything_to_df(
|
|
568
560
|
max_unevaluated_rows: int = MAX_UNEVALUATED_DF_ROWS,
|
569
561
|
ensure_copy: bool = False,
|
570
562
|
allow_styler: bool = False,
|
571
|
-
) -> DataFrame | Styler:
|
572
|
-
...
|
563
|
+
) -> DataFrame | Styler: ...
|
573
564
|
|
574
565
|
|
575
566
|
def convert_anything_to_df(
|
@@ -698,13 +689,11 @@ Offending object:
|
|
698
689
|
|
699
690
|
|
700
691
|
@overload
|
701
|
-
def ensure_iterable(obj: Iterable[V_co]) -> Iterable[V_co]:
|
702
|
-
...
|
692
|
+
def ensure_iterable(obj: Iterable[V_co]) -> Iterable[V_co]: ...
|
703
693
|
|
704
694
|
|
705
695
|
@overload
|
706
|
-
def ensure_iterable(obj: OptionSequence[V_co]) -> Iterable[Any]:
|
707
|
-
...
|
696
|
+
def ensure_iterable(obj: OptionSequence[V_co]) -> Iterable[Any]: ...
|
708
697
|
|
709
698
|
|
710
699
|
def ensure_iterable(obj: OptionSequence[V_co] | Iterable[V_co]) -> Iterable[Any]:
|
@@ -1304,19 +1293,17 @@ def convert_df_to_data_format(
|
|
1304
1293
|
df = _unify_missing_values(df)
|
1305
1294
|
# The key is expected to be the index -> this will return the first column
|
1306
1295
|
# as a dict with index as key.
|
1307
|
-
return
|
1296
|
+
return {} if df.empty else df.iloc[:, 0].to_dict()
|
1308
1297
|
|
1309
1298
|
raise ValueError(f"Unsupported input data format: {data_format}")
|
1310
1299
|
|
1311
1300
|
|
1312
1301
|
@overload
|
1313
|
-
def to_key(key: None) -> None:
|
1314
|
-
...
|
1302
|
+
def to_key(key: None) -> None: ...
|
1315
1303
|
|
1316
1304
|
|
1317
1305
|
@overload
|
1318
|
-
def to_key(key: Key) -> str:
|
1319
|
-
...
|
1306
|
+
def to_key(key: Key) -> str: ...
|
1320
1307
|
|
1321
1308
|
|
1322
1309
|
def to_key(key: Key | None) -> str | None:
|
streamlit/user_info.py
CHANGED
@@ -14,11 +14,13 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from typing import Iterator, Mapping, NoReturn, Union
|
17
|
+
from typing import TYPE_CHECKING, Iterator, Mapping, NoReturn, Union
|
18
18
|
|
19
19
|
from streamlit.errors import StreamlitAPIException
|
20
20
|
from streamlit.runtime.scriptrunner import get_script_run_ctx as _get_script_run_ctx
|
21
|
-
|
21
|
+
|
22
|
+
if TYPE_CHECKING:
|
23
|
+
from streamlit.runtime.scriptrunner.script_run_context import UserInfo
|
22
24
|
|
23
25
|
|
24
26
|
def _get_user_info() -> UserInfo:
|
streamlit/util.py
CHANGED
@@ -111,7 +111,7 @@ def repr_(self: Any) -> str:
|
|
111
111
|
classname = self.__class__.__name__
|
112
112
|
# Most of the falsey value, but excluding 0 and 0.0, since those often have
|
113
113
|
# semantic meaning within streamlit.
|
114
|
-
defaults: list[Any] = [None, "", False, [], set(),
|
114
|
+
defaults: list[Any] = [None, "", False, [], set(), {}]
|
115
115
|
if dataclasses.is_dataclass(self):
|
116
116
|
fields_vals = (
|
117
117
|
(f.name, getattr(self, f.name))
|
@@ -39,17 +39,20 @@ from __future__ import annotations
|
|
39
39
|
|
40
40
|
import os
|
41
41
|
import threading
|
42
|
-
from typing import Callable, Final, cast
|
42
|
+
from typing import TYPE_CHECKING, Callable, Final, cast
|
43
43
|
|
44
44
|
from blinker import ANY, Signal
|
45
|
+
from typing_extensions import Self
|
45
46
|
from watchdog import events
|
46
47
|
from watchdog.observers import Observer
|
47
|
-
from watchdog.observers.api import ObservedWatch
|
48
48
|
|
49
49
|
from streamlit.logger import get_logger
|
50
50
|
from streamlit.util import repr_
|
51
51
|
from streamlit.watcher import util
|
52
52
|
|
53
|
+
if TYPE_CHECKING:
|
54
|
+
from watchdog.observers.api import ObservedWatch
|
55
|
+
|
53
56
|
_LOGGER: Final = get_logger(__name__)
|
54
57
|
|
55
58
|
|
@@ -127,7 +130,7 @@ class _MultiPathWatcher:
|
|
127
130
|
return cast("_MultiPathWatcher", _MultiPathWatcher._singleton)
|
128
131
|
|
129
132
|
# Don't allow constructor to be called more than once.
|
130
|
-
def __new__(cls) ->
|
133
|
+
def __new__(cls) -> Self:
|
131
134
|
"""Constructor."""
|
132
135
|
if _MultiPathWatcher._singleton is not None:
|
133
136
|
raise RuntimeError("Use .get_singleton() instead")
|
@@ -14,12 +14,10 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
import collections
|
18
17
|
import os
|
19
18
|
import sys
|
20
|
-
import types
|
21
19
|
from pathlib import Path
|
22
|
-
from typing import TYPE_CHECKING, Callable, Final
|
20
|
+
from typing import TYPE_CHECKING, Any, Callable, Final, NamedTuple
|
23
21
|
|
24
22
|
from streamlit import config, file_util
|
25
23
|
from streamlit.folder_black_list import FolderBlackList
|
@@ -30,11 +28,17 @@ from streamlit.watcher.path_watcher import (
|
|
30
28
|
)
|
31
29
|
|
32
30
|
if TYPE_CHECKING:
|
31
|
+
from types import ModuleType
|
32
|
+
|
33
33
|
from streamlit.runtime.pages_manager import PagesManager
|
34
34
|
|
35
35
|
_LOGGER: Final = get_logger(__name__)
|
36
36
|
|
37
|
-
|
37
|
+
|
38
|
+
class WatchedModule(NamedTuple):
|
39
|
+
watcher: Any
|
40
|
+
module_name: Any
|
41
|
+
|
38
42
|
|
39
43
|
# This needs to be initialized lazily to avoid calling config.get_option() and
|
40
44
|
# thus initializing config options when this file is first imported.
|
@@ -42,7 +46,7 @@ PathWatcher = None
|
|
42
46
|
|
43
47
|
|
44
48
|
class LocalSourcesWatcher:
|
45
|
-
def __init__(self, pages_manager:
|
49
|
+
def __init__(self, pages_manager: PagesManager):
|
46
50
|
self._pages_manager = pages_manager
|
47
51
|
self._main_script_path = os.path.abspath(self._pages_manager.main_script_path)
|
48
52
|
self._script_folder = os.path.dirname(self._main_script_path)
|
@@ -182,7 +186,7 @@ class LocalSourcesWatcher:
|
|
182
186
|
return {p for p in paths if not self._folder_black_list.is_blacklisted(p)}
|
183
187
|
|
184
188
|
|
185
|
-
def get_module_paths(module:
|
189
|
+
def get_module_paths(module: ModuleType) -> set[str]:
|
186
190
|
paths_extractors = [
|
187
191
|
# https://docs.python.org/3/reference/datamodel.html
|
188
192
|
# __file__ is the pathname of the file from which the module was loaded
|
@@ -203,7 +207,7 @@ def get_module_paths(module: types.ModuleType) -> set[str]:
|
|
203
207
|
# Handling of "namespace packages" in which the __path__ attribute
|
204
208
|
# is a _NamespacePath object with a _path attribute containing
|
205
209
|
# the various paths of the package.
|
206
|
-
lambda m:
|
210
|
+
lambda m: list(m.__path__._path),
|
207
211
|
]
|
208
212
|
|
209
213
|
all_paths = set()
|
streamlit/web/bootstrap.py
CHANGED
@@ -113,7 +113,7 @@ def _on_server_start(server: Server) -> None:
|
|
113
113
|
try:
|
114
114
|
secrets.load_if_toml_exists()
|
115
115
|
except Exception as ex:
|
116
|
-
_LOGGER.error(
|
116
|
+
_LOGGER.error("Failed to load secrets.toml file", exc_info=ex)
|
117
117
|
|
118
118
|
def maybe_open_browser():
|
119
119
|
if config.get_option("server.headless"):
|
@@ -14,11 +14,15 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from
|
17
|
+
from typing import TYPE_CHECKING
|
18
|
+
|
18
19
|
from streamlit.runtime.caching.storage.local_disk_cache_storage import (
|
19
20
|
LocalDiskCacheStorageManager,
|
20
21
|
)
|
21
22
|
|
23
|
+
if TYPE_CHECKING:
|
24
|
+
from streamlit.runtime.caching.storage import CacheStorageManager
|
25
|
+
|
22
26
|
|
23
27
|
def create_default_cache_storage_manager() -> CacheStorageManager:
|
24
28
|
"""
|
streamlit/web/cli.py
CHANGED
@@ -18,7 +18,7 @@ from __future__ import annotations
|
|
18
18
|
|
19
19
|
import os
|
20
20
|
import sys
|
21
|
-
from typing import Any
|
21
|
+
from typing import TYPE_CHECKING, Any, Callable, TypeVar
|
22
22
|
|
23
23
|
# We cannot lazy-load click here because its used via decorators.
|
24
24
|
import click
|
@@ -26,12 +26,14 @@ import click
|
|
26
26
|
import streamlit.runtime.caching as caching
|
27
27
|
import streamlit.web.bootstrap as bootstrap
|
28
28
|
from streamlit import config as _config
|
29
|
-
from streamlit.config_option import ConfigOption
|
30
29
|
from streamlit.runtime.credentials import Credentials, check_credentials
|
31
30
|
from streamlit.web.cache_storage_manager_config import (
|
32
31
|
create_default_cache_storage_manager,
|
33
32
|
)
|
34
33
|
|
34
|
+
if TYPE_CHECKING:
|
35
|
+
from streamlit.config_option import ConfigOption
|
36
|
+
|
35
37
|
ACCEPTED_FILE_EXTENSIONS = ("py", "py3")
|
36
38
|
|
37
39
|
LOG_LEVELS = ("error", "warning", "info", "debug")
|
@@ -73,7 +75,10 @@ def _make_sensitive_option_callback(config_option: ConfigOption):
|
|
73
75
|
return callback
|
74
76
|
|
75
77
|
|
76
|
-
|
78
|
+
F = TypeVar("F", bound=Callable[..., Any])
|
79
|
+
|
80
|
+
|
81
|
+
def configurator_options(func: F) -> F:
|
77
82
|
"""Decorator that adds config param keys to click dynamically."""
|
78
83
|
for _, value in reversed(_config._config_options_template.items()):
|
79
84
|
parsed_parameter = _convert_config_option_to_click_option(value)
|
@@ -170,7 +175,7 @@ def main_version():
|
|
170
175
|
@main.command("docs")
|
171
176
|
def main_docs():
|
172
177
|
"""Show help in browser."""
|
173
|
-
|
178
|
+
click.echo("Showing help page in browser...")
|
174
179
|
from streamlit import util
|
175
180
|
|
176
181
|
util.open_browser("https://docs.streamlit.io")
|
@@ -17,7 +17,7 @@ from __future__ import annotations
|
|
17
17
|
import base64
|
18
18
|
import binascii
|
19
19
|
import json
|
20
|
-
from typing import Any, Awaitable, Final
|
20
|
+
from typing import TYPE_CHECKING, Any, Awaitable, Final
|
21
21
|
|
22
22
|
import tornado.concurrent
|
23
23
|
import tornado.locks
|
@@ -29,11 +29,13 @@ from tornado.websocket import WebSocketHandler
|
|
29
29
|
from streamlit import config
|
30
30
|
from streamlit.logger import get_logger
|
31
31
|
from streamlit.proto.BackMsg_pb2 import BackMsg
|
32
|
-
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
33
32
|
from streamlit.runtime import Runtime, SessionClient, SessionClientDisconnectedError
|
34
33
|
from streamlit.runtime.runtime_util import serialize_forward_msg
|
35
34
|
from streamlit.web.server.server_util import is_url_from_allowed_origins
|
36
35
|
|
36
|
+
if TYPE_CHECKING:
|
37
|
+
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
38
|
+
|
37
39
|
_LOGGER: Final = get_logger(__name__)
|
38
40
|
|
39
41
|
|
@@ -101,12 +103,9 @@ class BrowserWebSocketHandler(WebSocketHandler, SessionClient):
|
|
101
103
|
except (KeyError, binascii.Error, json.decoder.JSONDecodeError):
|
102
104
|
email = "test@example.com"
|
103
105
|
|
104
|
-
user_info: dict[str, str | None] =
|
105
|
-
|
106
|
-
|
107
|
-
user_info["email"] = None
|
108
|
-
else:
|
109
|
-
user_info["email"] = email
|
106
|
+
user_info: dict[str, str | None] = {
|
107
|
+
"email": None if is_public_cloud_app else email
|
108
|
+
}
|
110
109
|
|
111
110
|
existing_session_id = None
|
112
111
|
try:
|
@@ -16,14 +16,16 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
import mimetypes
|
18
18
|
import os
|
19
|
-
from typing import Final
|
19
|
+
from typing import TYPE_CHECKING, Final
|
20
20
|
|
21
21
|
import tornado.web
|
22
22
|
|
23
23
|
import streamlit.web.server.routes
|
24
|
-
from streamlit.components.types.base_component_registry import BaseComponentRegistry
|
25
24
|
from streamlit.logger import get_logger
|
26
25
|
|
26
|
+
if TYPE_CHECKING:
|
27
|
+
from streamlit.components.types.base_component_registry import BaseComponentRegistry
|
28
|
+
|
27
29
|
_LOGGER: Final = get_logger(__name__)
|
28
30
|
|
29
31
|
|
streamlit/web/server/routes.py
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import os
|
18
|
-
from typing import Final
|
18
|
+
from typing import Final, Sequence
|
19
19
|
|
20
20
|
import tornado.web
|
21
21
|
|
@@ -45,7 +45,7 @@ class StaticFileHandler(tornado.web.StaticFileHandler):
|
|
45
45
|
self,
|
46
46
|
path: str,
|
47
47
|
default_filename: str | None = None,
|
48
|
-
reserved_paths:
|
48
|
+
reserved_paths: Sequence[str] = (),
|
49
49
|
):
|
50
50
|
self._reserved_paths = reserved_paths
|
51
51
|
|
@@ -71,7 +71,7 @@ class StaticFileHandler(tornado.web.StaticFileHandler):
|
|
71
71
|
# If the file is not found, and there are no reserved paths,
|
72
72
|
# we try to serve the default file and allow the frontend to handle the issue.
|
73
73
|
if e.status_code == 404:
|
74
|
-
if any(
|
74
|
+
if any(self.path.endswith(x) for x in self._reserved_paths):
|
75
75
|
raise e
|
76
76
|
|
77
77
|
self.path = self.parse_url_path(self.default_filename or "index.html")
|