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
streamlit/__init__.py
CHANGED
@@ -44,7 +44,6 @@ For more detailed info, see https://docs.streamlit.io.
|
|
44
44
|
|
45
45
|
# IMPORTANT: Prefix with an underscore anything that the user shouldn't see.
|
46
46
|
|
47
|
-
|
48
47
|
import os as _os
|
49
48
|
|
50
49
|
# Set Matplotlib backend to avoid a crash.
|
@@ -266,3 +265,8 @@ experimental_data_editor = _main.experimental_data_editor
|
|
266
265
|
experimental_connection = _deprecate_func_name(
|
267
266
|
connection, "experimental_connection", "2024-04-01", name_override="connection"
|
268
267
|
)
|
268
|
+
|
269
|
+
# make it possible to call streamlit.components.v1.html etc. by importing it here
|
270
|
+
# import in the very end to avoid partially-initialized module import errors, because
|
271
|
+
# streamlit.components.v1 also uses some streamlit imports
|
272
|
+
import streamlit.components.v1 # noqa: F401
|
streamlit/case_converters.py
CHANGED
@@ -80,11 +80,11 @@ def convert_dict_keys(
|
|
80
80
|
converted by `func`.
|
81
81
|
|
82
82
|
"""
|
83
|
-
out_dict =
|
83
|
+
out_dict = {}
|
84
84
|
for k, v in in_dict.items():
|
85
85
|
converted_key = func(k)
|
86
86
|
|
87
|
-
if
|
87
|
+
if isinstance(v, dict):
|
88
88
|
out_dict[converted_key] = convert_dict_keys(func, v)
|
89
89
|
else:
|
90
90
|
out_dict[converted_key] = v
|
streamlit/cli_util.py
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
"""
|
15
|
+
"""Utilities related to the CLI."""
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
@@ -28,7 +28,7 @@ def print_to_cli(message: str, **kwargs) -> None:
|
|
28
28
|
|
29
29
|
click.secho(message, **kwargs)
|
30
30
|
except ImportError:
|
31
|
-
print(message, flush=True)
|
31
|
+
print(message, flush=True) # noqa: T201
|
32
32
|
|
33
33
|
|
34
34
|
def style_for_cli(message: str, **kwargs) -> str:
|
streamlit/color_util.py
CHANGED
@@ -196,8 +196,8 @@ def _to_color_tuple(
|
|
196
196
|
|
197
197
|
try:
|
198
198
|
color = int(r, 16), int(g, 16), int(b, 16), int(a, 16)
|
199
|
-
except:
|
200
|
-
raise InvalidColorException(color)
|
199
|
+
except Exception as ex:
|
200
|
+
raise InvalidColorException(color) from ex
|
201
201
|
|
202
202
|
if is_color_tuple_like(color):
|
203
203
|
color_tuple = cast(ColorTuple, color)
|
@@ -125,18 +125,16 @@ def _ensure_no_embed_params(
|
|
125
125
|
all_current_params = parse.parse_qs(query_string, keep_blank_values=True)
|
126
126
|
current_embed_params = parse.urlencode(
|
127
127
|
{
|
128
|
-
EMBED_QUERY_PARAM:
|
129
|
-
|
130
|
-
for param in util.extract_key_query_params(
|
128
|
+
EMBED_QUERY_PARAM: list(
|
129
|
+
util.extract_key_query_params(
|
131
130
|
all_current_params, param_key=EMBED_QUERY_PARAM
|
132
131
|
)
|
133
|
-
|
134
|
-
EMBED_OPTIONS_QUERY_PARAM:
|
135
|
-
|
136
|
-
for param in util.extract_key_query_params(
|
132
|
+
),
|
133
|
+
EMBED_OPTIONS_QUERY_PARAM: list(
|
134
|
+
util.extract_key_query_params(
|
137
135
|
all_current_params, param_key=EMBED_OPTIONS_QUERY_PARAM
|
138
136
|
)
|
139
|
-
|
137
|
+
),
|
140
138
|
},
|
141
139
|
doseq=True,
|
142
140
|
)
|
streamlit/commands/logo.py
CHANGED
@@ -16,8 +16,6 @@
|
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
19
|
-
from typing import TYPE_CHECKING
|
20
|
-
|
21
19
|
from streamlit import url_util
|
22
20
|
from streamlit.elements.image import AtomicImage, WidthBehaviour, image_to_url
|
23
21
|
from streamlit.errors import StreamlitAPIException
|
@@ -25,9 +23,6 @@ from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
|
25
23
|
from streamlit.runtime.metrics_util import gather_metrics
|
26
24
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
27
25
|
|
28
|
-
if TYPE_CHECKING:
|
29
|
-
from PIL import Image
|
30
|
-
|
31
26
|
|
32
27
|
def _invalid_logo_text(field_name: str):
|
33
28
|
return f"The {field_name} passed to st.logo is invalid - See [documentation](https://docs.streamlit.io/develop/api-reference/media/st.logo) for more information on valid types"
|
@@ -126,8 +121,8 @@ def logo(
|
|
126
121
|
image_id="logo",
|
127
122
|
)
|
128
123
|
fwd_msg.logo.image = image_url
|
129
|
-
except Exception:
|
130
|
-
raise StreamlitAPIException(_invalid_logo_text("image"))
|
124
|
+
except Exception as ex:
|
125
|
+
raise StreamlitAPIException(_invalid_logo_text("image")) from ex
|
131
126
|
|
132
127
|
if link:
|
133
128
|
# Handle external links:
|
@@ -149,7 +144,7 @@ def logo(
|
|
149
144
|
image_id="icon-image",
|
150
145
|
)
|
151
146
|
fwd_msg.logo.icon_image = icon_image_url
|
152
|
-
except Exception:
|
153
|
-
raise StreamlitAPIException(_invalid_logo_text("icon_image"))
|
147
|
+
except Exception as ex:
|
148
|
+
raise StreamlitAPIException(_invalid_logo_text("icon_image")) from ex
|
154
149
|
|
155
150
|
ctx.enqueue(fwd_msg)
|
streamlit/commands/navigation.py
CHANGED
@@ -15,12 +15,11 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
from pathlib import Path
|
18
|
-
from typing import Literal
|
18
|
+
from typing import TYPE_CHECKING, Literal
|
19
19
|
|
20
20
|
from typing_extensions import TypeAlias
|
21
21
|
|
22
22
|
from streamlit.errors import StreamlitAPIException
|
23
|
-
from streamlit.navigation.page import StreamlitPage
|
24
23
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
25
24
|
from streamlit.proto.Navigation_pb2 import Navigation as NavigationProto
|
26
25
|
from streamlit.runtime.metrics_util import gather_metrics
|
@@ -28,13 +27,16 @@ from streamlit.runtime.scriptrunner.script_run_context import (
|
|
28
27
|
ScriptRunContext,
|
29
28
|
get_script_run_ctx,
|
30
29
|
)
|
31
|
-
|
30
|
+
|
31
|
+
if TYPE_CHECKING:
|
32
|
+
from streamlit.navigation.page import StreamlitPage
|
33
|
+
from streamlit.source_util import PageHash, PageInfo
|
32
34
|
|
33
35
|
SectionHeader: TypeAlias = str
|
34
36
|
|
35
37
|
|
36
38
|
def pages_from_nav_sections(
|
37
|
-
nav_sections: dict[SectionHeader, list[StreamlitPage]]
|
39
|
+
nav_sections: dict[SectionHeader, list[StreamlitPage]],
|
38
40
|
) -> list[StreamlitPage]:
|
39
41
|
page_list = []
|
40
42
|
for pages in nav_sections.values():
|
@@ -16,14 +16,16 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
import os
|
18
18
|
import threading
|
19
|
-
from typing import Final
|
19
|
+
from typing import TYPE_CHECKING, Final
|
20
20
|
|
21
21
|
from streamlit import util
|
22
22
|
from streamlit.components.types.base_component_registry import BaseComponentRegistry
|
23
|
-
from streamlit.components.types.base_custom_component import BaseCustomComponent
|
24
23
|
from streamlit.errors import StreamlitAPIException
|
25
24
|
from streamlit.logger import get_logger
|
26
25
|
|
26
|
+
if TYPE_CHECKING:
|
27
|
+
from streamlit.components.types.base_custom_component import BaseCustomComponent
|
28
|
+
|
27
29
|
_LOGGER: Final = get_logger(__name__)
|
28
30
|
|
29
31
|
|
@@ -15,9 +15,10 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
from abc import abstractmethod
|
18
|
-
from typing import Protocol
|
18
|
+
from typing import TYPE_CHECKING, Protocol
|
19
19
|
|
20
|
-
|
20
|
+
if TYPE_CHECKING:
|
21
|
+
from streamlit.components.types.base_custom_component import BaseCustomComponent
|
21
22
|
|
22
23
|
|
23
24
|
class BaseComponentRegistry(Protocol):
|
@@ -22,11 +22,12 @@ from typing import TYPE_CHECKING, Any
|
|
22
22
|
|
23
23
|
from streamlit import type_util
|
24
24
|
from streamlit.elements.lib import pandas_styler_utils
|
25
|
-
from streamlit.proto.Components_pb2 import ArrowTable as ArrowTableProto
|
26
25
|
|
27
26
|
if TYPE_CHECKING:
|
28
27
|
from pandas import DataFrame, Index, Series
|
29
28
|
|
29
|
+
from streamlit.proto.Components_pb2 import ArrowTable as ArrowTableProto
|
30
|
+
|
30
31
|
|
31
32
|
def marshall(
|
32
33
|
proto: ArrowTableProto, data: Any, default_uuid: str | None = None
|
@@ -16,13 +16,17 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
import inspect
|
18
18
|
import os
|
19
|
-
from
|
19
|
+
from typing import TYPE_CHECKING
|
20
20
|
|
21
|
-
from streamlit.components.types.base_component_registry import BaseComponentRegistry
|
22
21
|
from streamlit.components.v1.custom_component import CustomComponent
|
23
22
|
from streamlit.runtime import get_instance
|
24
23
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
25
24
|
|
25
|
+
if TYPE_CHECKING:
|
26
|
+
from types import FrameType
|
27
|
+
|
28
|
+
from streamlit.components.types.base_component_registry import BaseComponentRegistry
|
29
|
+
|
26
30
|
|
27
31
|
def _get_module_name(caller_frame: FrameType) -> str:
|
28
32
|
# Get the caller's module name. `__name__` gives us the module's
|
@@ -19,5 +19,7 @@
|
|
19
19
|
# Since we do not know what other internals are used out in the wild, let's try to
|
20
20
|
# model the old behavior and not to break things.
|
21
21
|
|
22
|
-
from streamlit.components.v1.component_registry import
|
23
|
-
|
22
|
+
from streamlit.components.v1.component_registry import (
|
23
|
+
declare_component as declare_component,
|
24
|
+
)
|
25
|
+
from streamlit.components.v1.custom_component import * # noqa: F403
|
@@ -17,8 +17,8 @@ from __future__ import annotations
|
|
17
17
|
import json
|
18
18
|
from typing import TYPE_CHECKING, Any
|
19
19
|
|
20
|
-
from streamlit import _main, type_util
|
21
20
|
from streamlit.components.types.base_custom_component import BaseCustomComponent
|
21
|
+
from streamlit.delta_generator import main_dg
|
22
22
|
from streamlit.elements.form import current_form_id
|
23
23
|
from streamlit.elements.lib.policies import check_cache_replay_rules
|
24
24
|
from streamlit.errors import StreamlitAPIException
|
@@ -29,7 +29,7 @@ from streamlit.runtime.metrics_util import gather_metrics
|
|
29
29
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
30
30
|
from streamlit.runtime.state import NoValue, register_widget
|
31
31
|
from streamlit.runtime.state.common import compute_widget_id
|
32
|
-
from streamlit.type_util import to_bytes
|
32
|
+
from streamlit.type_util import is_bytes_like, is_dataframe_like, to_bytes
|
33
33
|
|
34
34
|
if TYPE_CHECKING:
|
35
35
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -100,7 +100,7 @@ class CustomComponent(BaseCustomComponent):
|
|
100
100
|
raise MarshallComponentException(f"Argument '{args[0]}' needs a label")
|
101
101
|
|
102
102
|
try:
|
103
|
-
import pyarrow
|
103
|
+
import pyarrow # noqa: F401
|
104
104
|
|
105
105
|
from streamlit.components.v1 import component_arrow
|
106
106
|
except ImportError:
|
@@ -122,12 +122,12 @@ And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt."""
|
|
122
122
|
json_args = {}
|
123
123
|
special_args = []
|
124
124
|
for arg_name, arg_val in all_args.items():
|
125
|
-
if
|
125
|
+
if is_bytes_like(arg_val):
|
126
126
|
bytes_arg = SpecialArg()
|
127
127
|
bytes_arg.key = arg_name
|
128
128
|
bytes_arg.bytes = to_bytes(arg_val)
|
129
129
|
special_args.append(bytes_arg)
|
130
|
-
elif
|
130
|
+
elif is_dataframe_like(arg_val):
|
131
131
|
dataframe_arg = SpecialArg()
|
132
132
|
dataframe_arg.key = arg_name
|
133
133
|
component_arrow.marshall(dataframe_arg.arrow_dataframe.data, arg_val)
|
@@ -221,7 +221,7 @@ And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt."""
|
|
221
221
|
|
222
222
|
# We currently only support writing to st._main, but this will change
|
223
223
|
# when we settle on an improved API in a post-layout world.
|
224
|
-
dg =
|
224
|
+
dg = main_dg
|
225
225
|
|
226
226
|
element = Element()
|
227
227
|
return_value = marshall_component(dg, element)
|
streamlit/config.py
CHANGED
@@ -121,9 +121,7 @@ def set_user_option(key: str, value: Any) -> None:
|
|
121
121
|
return
|
122
122
|
|
123
123
|
raise StreamlitAPIException(
|
124
|
-
"{key} cannot be set on the fly. Set as command line option, e.g. streamlit run script.py --{key}, or in config.toml instead."
|
125
|
-
key=key
|
126
|
-
)
|
124
|
+
f"{key} cannot be set on the fly. Set as command line option, e.g. streamlit run script.py --{key}, or in config.toml instead."
|
127
125
|
)
|
128
126
|
|
129
127
|
|
@@ -142,7 +140,7 @@ def get_option(key: str) -> Any:
|
|
142
140
|
config_options = get_config_options()
|
143
141
|
|
144
142
|
if key not in config_options:
|
145
|
-
raise RuntimeError('Config key "
|
143
|
+
raise RuntimeError(f'Config key "{key}" not defined.')
|
146
144
|
return config_options[key].value
|
147
145
|
|
148
146
|
|
@@ -174,9 +172,9 @@ def get_options_for_section(section: str) -> dict[str, Any]:
|
|
174
172
|
|
175
173
|
def _create_section(section: str, description: str) -> None:
|
176
174
|
"""Create a config section and store it globally in this module."""
|
177
|
-
assert
|
178
|
-
|
179
|
-
)
|
175
|
+
assert (
|
176
|
+
section not in _section_descriptions
|
177
|
+
), f'Cannot define section "{section}" twice.'
|
180
178
|
_section_descriptions[section] = description
|
181
179
|
|
182
180
|
|
@@ -247,7 +245,7 @@ def _create_option(
|
|
247
245
|
option.section,
|
248
246
|
", ".join(_section_descriptions.keys()),
|
249
247
|
)
|
250
|
-
assert key not in _config_options_template, 'Cannot define option "
|
248
|
+
assert key not in _config_options_template, f'Cannot define option "{key}" twice.'
|
251
249
|
_config_options_template[key] = option
|
252
250
|
return option
|
253
251
|
|
@@ -467,6 +465,9 @@ _create_option(
|
|
467
465
|
visibility="hidden",
|
468
466
|
type_=bool,
|
469
467
|
scriptable=True,
|
468
|
+
deprecated=True,
|
469
|
+
deprecation_text="logger.enableRich has been deprecated and will be removed in a future version. Exception formatting via rich will be automatically used if rich is enable.",
|
470
|
+
expiration_date="2024-09-10",
|
470
471
|
)
|
471
472
|
|
472
473
|
# Config Section: Client #
|
@@ -1354,9 +1355,9 @@ def _check_conflicts() -> None:
|
|
1354
1355
|
"server.port"
|
1355
1356
|
), "server.port does not work when global.developmentMode is true."
|
1356
1357
|
|
1357
|
-
assert _is_unset(
|
1358
|
-
"browser.serverPort
|
1359
|
-
)
|
1358
|
+
assert _is_unset(
|
1359
|
+
"browser.serverPort"
|
1360
|
+
), "browser.serverPort does not work when global.developmentMode is true."
|
1360
1361
|
|
1361
1362
|
# XSRF conflicts
|
1362
1363
|
if get_option("server.enableXsrfProtection"):
|
@@ -1405,12 +1406,14 @@ def on_config_parsed(
|
|
1405
1406
|
Callable[[], bool]
|
1406
1407
|
A function that the caller can use to deregister func.
|
1407
1408
|
"""
|
1409
|
+
|
1408
1410
|
# We need to use the same receiver when we connect or disconnect on the
|
1409
1411
|
# Signal. If we don't do this, then the registered receiver won't be released
|
1410
1412
|
# leading to a memory leak because the Signal will keep a reference of the
|
1411
1413
|
# callable argument. When the callable argument is an object method, then
|
1412
1414
|
# the reference to that object won't be released.
|
1413
|
-
receiver
|
1415
|
+
def receiver(_):
|
1416
|
+
return func_with_lock()
|
1414
1417
|
|
1415
1418
|
def disconnect():
|
1416
1419
|
return _on_config_parsed.disconnect(receiver)
|
@@ -20,7 +20,6 @@
|
|
20
20
|
|
21
21
|
from __future__ import annotations
|
22
22
|
|
23
|
-
from datetime import timedelta
|
24
23
|
from typing import TYPE_CHECKING, cast
|
25
24
|
|
26
25
|
from streamlit.connections import BaseConnection
|
@@ -29,6 +28,8 @@ from streamlit.errors import StreamlitAPIException
|
|
29
28
|
from streamlit.runtime.caching import cache_data
|
30
29
|
|
31
30
|
if TYPE_CHECKING:
|
31
|
+
from datetime import timedelta
|
32
|
+
|
32
33
|
from pandas import DataFrame
|
33
34
|
from snowflake.connector.cursor import SnowflakeCursor # type:ignore[import]
|
34
35
|
from snowflake.snowpark.session import Session # type:ignore[import]
|
@@ -23,7 +23,6 @@ from __future__ import annotations
|
|
23
23
|
import threading
|
24
24
|
from collections import ChainMap
|
25
25
|
from contextlib import contextmanager
|
26
|
-
from datetime import timedelta
|
27
26
|
from typing import TYPE_CHECKING, Iterator, cast
|
28
27
|
|
29
28
|
from streamlit.connections import BaseConnection
|
@@ -36,6 +35,8 @@ from streamlit.errors import StreamlitAPIException
|
|
36
35
|
from streamlit.runtime.caching import cache_data
|
37
36
|
|
38
37
|
if TYPE_CHECKING:
|
38
|
+
from datetime import timedelta
|
39
|
+
|
39
40
|
from pandas import DataFrame
|
40
41
|
from snowflake.snowpark.session import Session # type:ignore[import]
|
41
42
|
|
@@ -65,9 +66,6 @@ class SnowparkConnection(BaseConnection["Session"]):
|
|
65
66
|
|
66
67
|
def _connect(self, **kwargs) -> Session:
|
67
68
|
from snowflake.snowpark.context import get_active_session # type:ignore[import]
|
68
|
-
from snowflake.snowpark.exceptions import ( # type:ignore[import]
|
69
|
-
SnowparkSessionException,
|
70
|
-
)
|
71
69
|
from snowflake.snowpark.session import Session
|
72
70
|
|
73
71
|
# If we're running in SiS, just call get_active_session(). Otherwise, attempt to
|
@@ -16,7 +16,6 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
from collections import ChainMap
|
18
18
|
from copy import deepcopy
|
19
|
-
from datetime import timedelta
|
20
19
|
from typing import TYPE_CHECKING, cast
|
21
20
|
|
22
21
|
from streamlit.connections import BaseConnection
|
@@ -25,6 +24,8 @@ from streamlit.errors import StreamlitAPIException
|
|
25
24
|
from streamlit.runtime.caching import cache_data
|
26
25
|
|
27
26
|
if TYPE_CHECKING:
|
27
|
+
from datetime import timedelta
|
28
|
+
|
28
29
|
from pandas import DataFrame
|
29
30
|
from sqlalchemy.engine import Connection as SQLAlchemyConnection
|
30
31
|
from sqlalchemy.engine.base import Engine
|
streamlit/delta_generator.py
CHANGED
@@ -26,7 +26,6 @@ from typing import (
|
|
26
26
|
Final,
|
27
27
|
Hashable,
|
28
28
|
Iterable,
|
29
|
-
List,
|
30
29
|
Literal,
|
31
30
|
NoReturn,
|
32
31
|
TypeVar,
|
@@ -45,7 +44,6 @@ from streamlit import (
|
|
45
44
|
type_util,
|
46
45
|
util,
|
47
46
|
)
|
48
|
-
from streamlit.cursor import Cursor
|
49
47
|
from streamlit.elements.alert import AlertMixin
|
50
48
|
from streamlit.elements.arrow import ArrowMixin
|
51
49
|
from streamlit.elements.balloons import BalloonsMixin
|
@@ -101,6 +99,7 @@ if TYPE_CHECKING:
|
|
101
99
|
from numpy import typing as npt
|
102
100
|
from pandas import DataFrame
|
103
101
|
|
102
|
+
from streamlit.cursor import Cursor
|
104
103
|
from streamlit.elements.arrow import Data
|
105
104
|
from streamlit.elements.lib.built_in_chart_utils import AddRowsMetadata
|
106
105
|
|
@@ -358,7 +357,7 @@ class DeltaGenerator(
|
|
358
357
|
return dg
|
359
358
|
|
360
359
|
@property
|
361
|
-
def _ancestors(self) -> Iterable[
|
360
|
+
def _ancestors(self) -> Iterable[DeltaGenerator]:
|
362
361
|
current_dg: DeltaGenerator | None = self
|
363
362
|
while current_dg is not None:
|
364
363
|
yield current_dg
|
@@ -735,7 +734,7 @@ def _writes_directly_to_sidebar(dg: DG) -> bool:
|
|
735
734
|
|
736
735
|
|
737
736
|
def _check_nested_element_violation(
|
738
|
-
dg: DeltaGenerator, block_type: str | None, ancestor_block_types:
|
737
|
+
dg: DeltaGenerator, block_type: str | None, ancestor_block_types: list[BlockType]
|
739
738
|
) -> None:
|
740
739
|
"""Check if elements are nested in a forbidden way.
|
741
740
|
|
streamlit/elements/arrow.py
CHANGED
@@ -24,7 +24,6 @@ from typing import (
|
|
24
24
|
Iterable,
|
25
25
|
List,
|
26
26
|
Literal,
|
27
|
-
Set,
|
28
27
|
TypedDict,
|
29
28
|
Union,
|
30
29
|
cast,
|
@@ -185,7 +184,7 @@ class DataframeSelectionSerde:
|
|
185
184
|
|
186
185
|
def parse_selection_mode(
|
187
186
|
selection_mode: SelectionMode | Iterable[SelectionMode],
|
188
|
-
) ->
|
187
|
+
) -> set[ArrowProto.SelectionMode.ValueType]:
|
189
188
|
"""Parse and check the user provided selection modes."""
|
190
189
|
if isinstance(selection_mode, str):
|
191
190
|
# Only a single selection mode was passed
|
@@ -238,8 +237,7 @@ class ArrowMixin:
|
|
238
237
|
key: Key | None = None,
|
239
238
|
on_select: Literal["ignore"], # No default value here to make it work with mypy
|
240
239
|
selection_mode: SelectionMode | Iterable[SelectionMode] = "multi-row",
|
241
|
-
) -> DeltaGenerator:
|
242
|
-
...
|
240
|
+
) -> DeltaGenerator: ...
|
243
241
|
|
244
242
|
@overload
|
245
243
|
def dataframe(
|
@@ -255,8 +253,7 @@ class ArrowMixin:
|
|
255
253
|
key: Key | None = None,
|
256
254
|
on_select: Literal["rerun"] | WidgetCallback = "rerun",
|
257
255
|
selection_mode: SelectionMode | Iterable[SelectionMode] = "multi-row",
|
258
|
-
) -> DataframeState:
|
259
|
-
...
|
256
|
+
) -> DataframeState: ...
|
260
257
|
|
261
258
|
@gather_metrics("dataframe")
|
262
259
|
def dataframe(
|
streamlit/elements/code.py
CHANGED
@@ -19,10 +19,10 @@ from typing import TYPE_CHECKING, cast
|
|
19
19
|
from streamlit.proto.Code_pb2 import Code as CodeProto
|
20
20
|
from streamlit.runtime.metrics_util import gather_metrics
|
21
21
|
from streamlit.string_util import clean_text
|
22
|
-
from streamlit.type_util import SupportsStr
|
23
22
|
|
24
23
|
if TYPE_CHECKING:
|
25
24
|
from streamlit.delta_generator import DeltaGenerator
|
25
|
+
from streamlit.type_util import SupportsStr
|
26
26
|
|
27
27
|
|
28
28
|
class CodeMixin:
|
@@ -15,14 +15,16 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
from functools import wraps
|
18
|
-
from typing import Callable, TypeVar, cast, overload
|
18
|
+
from typing import TYPE_CHECKING, Callable, TypeVar, cast, overload
|
19
19
|
|
20
20
|
from streamlit.delta_generator import event_dg, get_last_dg_added_to_context_stack
|
21
|
-
from streamlit.elements.lib.dialog import DialogWidth
|
22
21
|
from streamlit.errors import StreamlitAPIException
|
23
22
|
from streamlit.runtime.fragment import _fragment
|
24
23
|
from streamlit.runtime.metrics_util import gather_metrics
|
25
24
|
|
25
|
+
if TYPE_CHECKING:
|
26
|
+
from streamlit.elements.lib.dialog import DialogWidth
|
27
|
+
|
26
28
|
|
27
29
|
def _assert_no_nested_dialogs() -> None:
|
28
30
|
"""Check the current stack for existing DeltaGenerator's of type 'dialog'.
|
@@ -79,8 +81,9 @@ def _dialog_decorator(
|
|
79
81
|
|
80
82
|
|
81
83
|
@overload
|
82
|
-
def dialog_decorator(
|
83
|
-
|
84
|
+
def dialog_decorator(
|
85
|
+
title: str, *, width: DialogWidth = "small"
|
86
|
+
) -> Callable[[F], F]: ...
|
84
87
|
|
85
88
|
|
86
89
|
# 'title' can be a function since `dialog_decorator` is a decorator. We just call it 'title' here though
|
@@ -88,8 +91,7 @@ def dialog_decorator(title: str, *, width: DialogWidth = "small") -> Callable[[F
|
|
88
91
|
# The user is supposed to call it like @st.dialog("my_title") , which makes 'title' a positional arg, hence
|
89
92
|
# this 'trick'. The overload is required to have a good type hint for the decorated function args.
|
90
93
|
@overload
|
91
|
-
def dialog_decorator(title: F, *, width: DialogWidth = "small") -> F:
|
92
|
-
...
|
94
|
+
def dialog_decorator(title: F, *, width: DialogWidth = "small") -> F: ...
|
93
95
|
|
94
96
|
|
95
97
|
@gather_metrics("experimental_dialog")
|
@@ -175,7 +177,7 @@ def dialog_decorator(
|
|
175
177
|
"""
|
176
178
|
|
177
179
|
func_or_title = title
|
178
|
-
if
|
180
|
+
if isinstance(func_or_title, str):
|
179
181
|
# Support passing the params via function decorator
|
180
182
|
def wrapper(f: F) -> F:
|
181
183
|
title: str = func_or_title
|
@@ -183,5 +185,5 @@ def dialog_decorator(
|
|
183
185
|
|
184
186
|
return wrapper
|
185
187
|
|
186
|
-
func: F =
|
188
|
+
func: F = func_or_title
|
187
189
|
return _dialog_decorator(func, "", width=width)
|
streamlit/elements/doc_string.py
CHANGED
@@ -375,7 +375,7 @@ def _is_stcommand(tree, command_name):
|
|
375
375
|
"""Checks whether the AST in tree is a call for command_name."""
|
376
376
|
root_node = tree.body[0].value
|
377
377
|
|
378
|
-
if not
|
378
|
+
if not isinstance(root_node, ast.Call):
|
379
379
|
return False
|
380
380
|
|
381
381
|
return (
|
streamlit/elements/exception.py
CHANGED
@@ -103,7 +103,7 @@ def marshall(exception_proto: ExceptionProto, exception: BaseException) -> None:
|
|
103
103
|
# Some exceptions (like UserHashError) have an alternate_name attribute so
|
104
104
|
# we can pretend to the user that the exception is called something else.
|
105
105
|
if getattr(exception, "alternate_name", None) is not None:
|
106
|
-
exception_proto.type =
|
106
|
+
exception_proto.type = exception.alternate_name # type: ignore[attr-defined]
|
107
107
|
else:
|
108
108
|
exception_proto.type = type(exception).__name__
|
109
109
|
|
streamlit/elements/form.py
CHANGED
@@ -21,10 +21,10 @@ from streamlit.errors import StreamlitAPIException
|
|
21
21
|
from streamlit.proto import Block_pb2
|
22
22
|
from streamlit.runtime.metrics_util import gather_metrics
|
23
23
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
24
|
-
from streamlit.runtime.state import WidgetArgs, WidgetCallback, WidgetKwargs
|
25
24
|
|
26
25
|
if TYPE_CHECKING:
|
27
26
|
from streamlit.delta_generator import DeltaGenerator
|
27
|
+
from streamlit.runtime.state import WidgetArgs, WidgetCallback, WidgetKwargs
|
28
28
|
|
29
29
|
|
30
30
|
class FormData(NamedTuple):
|
streamlit/elements/heading.py
CHANGED
@@ -23,10 +23,10 @@ from streamlit.errors import StreamlitAPIException
|
|
23
23
|
from streamlit.proto.Heading_pb2 import Heading as HeadingProto
|
24
24
|
from streamlit.runtime.metrics_util import gather_metrics
|
25
25
|
from streamlit.string_util import clean_text
|
26
|
-
from streamlit.type_util import SupportsStr
|
27
26
|
|
28
27
|
if TYPE_CHECKING:
|
29
28
|
from streamlit.delta_generator import DeltaGenerator
|
29
|
+
from streamlit.type_util import SupportsStr
|
30
30
|
|
31
31
|
|
32
32
|
class HeadingProtoTag(Enum):
|
streamlit/elements/html.py
CHANGED
@@ -75,7 +75,7 @@ class HtmlMixin:
|
|
75
75
|
html_proto = HtmlProto()
|
76
76
|
# Check if the body is a file path
|
77
77
|
if os.path.isfile(body):
|
78
|
-
with open(body,
|
78
|
+
with open(body, encoding="utf-8") as f:
|
79
79
|
html_proto.body = f.read()
|
80
80
|
else:
|
81
81
|
html_proto.body = clean_text(body)
|