streamlit-nightly 1.36.1.dev20240702__py2.py3-none-any.whl → 1.36.1.dev20240703__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.
Files changed (48) hide show
  1. streamlit/commands/navigation.py +1 -1
  2. streamlit/components/v1/component_arrow.py +16 -11
  3. streamlit/components/v1/custom_component.py +2 -1
  4. streamlit/dataframe_util.py +835 -0
  5. streamlit/delta_generator.py +5 -3
  6. streamlit/elements/arrow.py +17 -13
  7. streamlit/elements/lib/built_in_chart_utils.py +78 -12
  8. streamlit/elements/lib/column_config_utils.py +1 -1
  9. streamlit/elements/lib/pandas_styler_utils.py +2 -2
  10. streamlit/elements/lib/policies.py +20 -2
  11. streamlit/elements/lib/utils.py +100 -10
  12. streamlit/elements/map.py +2 -2
  13. streamlit/elements/metric.py +5 -2
  14. streamlit/elements/plotly_chart.py +1 -1
  15. streamlit/elements/vega_charts.py +6 -5
  16. streamlit/elements/widgets/button.py +1 -1
  17. streamlit/elements/widgets/camera_input.py +7 -2
  18. streamlit/elements/widgets/chat.py +1 -1
  19. streamlit/elements/widgets/checkbox.py +7 -2
  20. streamlit/elements/widgets/color_picker.py +7 -2
  21. streamlit/elements/widgets/data_editor.py +10 -9
  22. streamlit/elements/widgets/file_uploader.py +7 -2
  23. streamlit/elements/widgets/multiselect.py +6 -7
  24. streamlit/elements/widgets/number_input.py +7 -2
  25. streamlit/elements/widgets/radio.py +6 -7
  26. streamlit/elements/widgets/select_slider.py +6 -7
  27. streamlit/elements/widgets/selectbox.py +6 -7
  28. streamlit/elements/widgets/slider.py +7 -2
  29. streamlit/elements/widgets/text_widgets.py +8 -5
  30. streamlit/elements/widgets/time_widgets.py +7 -2
  31. streamlit/elements/write.py +5 -5
  32. streamlit/runtime/caching/cache_utils.py +1 -1
  33. streamlit/runtime/state/common.py +51 -2
  34. streamlit/runtime/state/session_state.py +2 -1
  35. streamlit/runtime/state/session_state_proxy.py +1 -1
  36. streamlit/runtime/state/widgets.py +1 -1
  37. streamlit/static/asset-manifest.json +2 -2
  38. streamlit/static/index.html +1 -1
  39. streamlit/static/static/js/{main.e2ab315a.js → main.28e3c6e9.js} +2 -2
  40. streamlit/testing/v1/element_tree.py +3 -3
  41. streamlit/type_util.py +0 -1069
  42. {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/METADATA +1 -1
  43. {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/RECORD +48 -47
  44. /streamlit/static/static/js/{main.e2ab315a.js.LICENSE.txt → main.28e3c6e9.js.LICENSE.txt} +0 -0
  45. {streamlit_nightly-1.36.1.dev20240702.data → streamlit_nightly-1.36.1.dev20240703.data}/scripts/streamlit.cmd +0 -0
  46. {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/WHEEL +0 -0
  47. {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/entry_points.txt +0 -0
  48. {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/top_level.txt +0 -0
@@ -27,6 +27,7 @@ from streamlit.elements.lib.policies import (
27
27
  check_fragment_path_policy,
28
28
  check_session_state_rules,
29
29
  )
30
+ from streamlit.elements.lib.utils import Key, to_key
30
31
  from streamlit.errors import StreamlitAPIException
31
32
  from streamlit.proto.Block_pb2 import Block as BlockProto
32
33
  from streamlit.proto.ChatInput_pb2 import ChatInput as ChatInputProto
@@ -42,7 +43,6 @@ from streamlit.runtime.state import (
42
43
  )
43
44
  from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
44
45
  from streamlit.string_util import is_emoji, validate_material_icon
45
- from streamlit.type_util import Key, to_key
46
46
 
47
47
  if TYPE_CHECKING:
48
48
  from streamlit.delta_generator import DeltaGenerator
@@ -24,8 +24,14 @@ from streamlit.elements.lib.policies import (
24
24
  check_callback_rules,
25
25
  check_fragment_path_policy,
26
26
  check_session_state_rules,
27
+ maybe_raise_label_warnings,
28
+ )
29
+ from streamlit.elements.lib.utils import (
30
+ Key,
31
+ LabelVisibility,
32
+ get_label_visibility_proto_value,
33
+ to_key,
27
34
  )
28
- from streamlit.elements.lib.utils import get_label_visibility_proto_value
29
35
  from streamlit.proto.Checkbox_pb2 import Checkbox as CheckboxProto
30
36
  from streamlit.runtime.metrics_util import gather_metrics
31
37
  from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
@@ -36,7 +42,6 @@ from streamlit.runtime.state import (
36
42
  register_widget,
37
43
  )
38
44
  from streamlit.runtime.state.common import compute_widget_id
39
- from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
40
45
 
41
46
  if TYPE_CHECKING:
42
47
  from streamlit.delta_generator import DeltaGenerator
@@ -25,8 +25,14 @@ from streamlit.elements.lib.policies import (
25
25
  check_callback_rules,
26
26
  check_fragment_path_policy,
27
27
  check_session_state_rules,
28
+ maybe_raise_label_warnings,
29
+ )
30
+ from streamlit.elements.lib.utils import (
31
+ Key,
32
+ LabelVisibility,
33
+ get_label_visibility_proto_value,
34
+ to_key,
28
35
  )
29
- from streamlit.elements.lib.utils import get_label_visibility_proto_value
30
36
  from streamlit.errors import StreamlitAPIException
31
37
  from streamlit.proto.ColorPicker_pb2 import ColorPicker as ColorPickerProto
32
38
  from streamlit.runtime.metrics_util import gather_metrics
@@ -38,7 +44,6 @@ from streamlit.runtime.state import (
38
44
  register_widget,
39
45
  )
40
46
  from streamlit.runtime.state.common import compute_widget_id
41
- from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
42
47
 
43
48
  if TYPE_CHECKING:
44
49
  from streamlit.delta_generator import DeltaGenerator
@@ -37,8 +37,8 @@ from typing import (
37
37
 
38
38
  from typing_extensions import TypeAlias
39
39
 
40
+ from streamlit import dataframe_util
40
41
  from streamlit import logger as _logger
41
- from streamlit import type_util
42
42
  from streamlit.elements.form import current_form_id
43
43
  from streamlit.elements.lib.column_config_utils import (
44
44
  INDEX_IDENTIFIER,
@@ -60,6 +60,7 @@ from streamlit.elements.lib.policies import (
60
60
  check_fragment_path_policy,
61
61
  check_session_state_rules,
62
62
  )
63
+ from streamlit.elements.lib.utils import Key, to_key
63
64
  from streamlit.errors import StreamlitAPIException
64
65
  from streamlit.proto.Arrow_pb2 import Arrow as ArrowProto
65
66
  from streamlit.runtime.metrics_util import gather_metrics
@@ -71,7 +72,7 @@ from streamlit.runtime.state import (
71
72
  register_widget,
72
73
  )
73
74
  from streamlit.runtime.state.common import compute_widget_id
74
- from streamlit.type_util import DataFormat, DataFrameGenericAlias, Key, is_type, to_key
75
+ from streamlit.type_util import is_type
75
76
  from streamlit.util import calc_md5
76
77
 
77
78
  if TYPE_CHECKING:
@@ -89,7 +90,7 @@ _LOGGER: Final = _logger.get_logger(__name__)
89
90
  EditableData = TypeVar(
90
91
  "EditableData",
91
92
  bound=Union[
92
- DataFrameGenericAlias[Any], # covers DataFrame and Series
93
+ dataframe_util.DataFrameGenericAlias[Any], # covers DataFrame and Series
93
94
  Tuple[Any],
94
95
  List[Any],
95
96
  Set[Any],
@@ -795,8 +796,8 @@ class DataEditorMixin:
795
796
 
796
797
  column_config_mapping: ColumnConfigMapping = {}
797
798
 
798
- data_format = type_util.determine_data_format(data)
799
- if data_format == DataFormat.UNKNOWN:
799
+ data_format = dataframe_util.determine_data_format(data)
800
+ if data_format == dataframe_util.DataFormat.UNKNOWN:
800
801
  raise StreamlitAPIException(
801
802
  f"The data type ({type(data).__name__}) or format is not supported by the data editor. "
802
803
  "Please convert your data into a Pandas Dataframe or another supported data format."
@@ -804,7 +805,7 @@ class DataEditorMixin:
804
805
 
805
806
  # The dataframe should always be a copy of the original data
806
807
  # since we will apply edits directly to it.
807
- data_df = type_util.convert_anything_to_df(data, ensure_copy=True)
808
+ data_df = dataframe_util.convert_anything_to_pandas_df(data, ensure_copy=True)
808
809
 
809
810
  # Check if the index is supported.
810
811
  if not _is_supported_index(data_df.index):
@@ -855,7 +856,7 @@ class DataEditorMixin:
855
856
  # Throws an exception if any of the configured types are incompatible.
856
857
  _check_type_compatibilities(data_df, column_config_mapping, dataframe_schema)
857
858
 
858
- arrow_bytes = type_util.pyarrow_table_to_bytes(arrow_table)
859
+ arrow_bytes = dataframe_util.pyarrow_table_to_bytes(arrow_table)
859
860
 
860
861
  # We want to do this as early as possible to avoid introducing nondeterminism,
861
862
  # but it isn't clear how much processing is needed to have the data in a
@@ -902,7 +903,7 @@ class DataEditorMixin:
902
903
 
903
904
  proto.form_id = current_form_id(self.dg)
904
905
 
905
- if type_util.is_pandas_styler(data):
906
+ if dataframe_util.is_pandas_styler(data):
906
907
  # Pandas styler will only work for non-editable/disabled columns.
907
908
  # Get first 10 chars of md5 hash of the key or delta path as styler uuid
908
909
  # and set it as styler uuid.
@@ -936,7 +937,7 @@ class DataEditorMixin:
936
937
 
937
938
  _apply_dataframe_edits(data_df, widget_state.value, dataframe_schema)
938
939
  self.dg._enqueue("arrow_data_frame", proto)
939
- return type_util.convert_df_to_data_format(data_df, data_format)
940
+ return dataframe_util.convert_df_to_data_format(data_df, data_format)
940
941
 
941
942
  @property
942
943
  def dg(self) -> DeltaGenerator:
@@ -27,8 +27,14 @@ from streamlit.elements.lib.policies import (
27
27
  check_callback_rules,
28
28
  check_fragment_path_policy,
29
29
  check_session_state_rules,
30
+ maybe_raise_label_warnings,
31
+ )
32
+ from streamlit.elements.lib.utils import (
33
+ Key,
34
+ LabelVisibility,
35
+ get_label_visibility_proto_value,
36
+ to_key,
30
37
  )
31
- from streamlit.elements.lib.utils import get_label_visibility_proto_value
32
38
  from streamlit.proto.Common_pb2 import FileUploaderState as FileUploaderStateProto
33
39
  from streamlit.proto.Common_pb2 import UploadedFileInfo as UploadedFileInfoProto
34
40
  from streamlit.proto.FileUploader_pb2 import FileUploader as FileUploaderProto
@@ -42,7 +48,6 @@ from streamlit.runtime.state import (
42
48
  )
43
49
  from streamlit.runtime.state.common import compute_widget_id
44
50
  from streamlit.runtime.uploaded_file_manager import DeletedFile, UploadedFile
45
- from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
46
51
 
47
52
  if TYPE_CHECKING:
48
53
  from streamlit.delta_generator import DeltaGenerator
@@ -18,16 +18,21 @@ from dataclasses import dataclass
18
18
  from textwrap import dedent
19
19
  from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast, overload
20
20
 
21
+ from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
21
22
  from streamlit.elements.form import current_form_id
22
23
  from streamlit.elements.lib.policies import (
23
24
  check_cache_replay_rules,
24
25
  check_callback_rules,
25
26
  check_fragment_path_policy,
26
27
  check_session_state_rules,
28
+ maybe_raise_label_warnings,
27
29
  )
28
30
  from streamlit.elements.lib.utils import (
31
+ Key,
32
+ LabelVisibility,
29
33
  get_label_visibility_proto_value,
30
34
  maybe_coerce_enum_sequence,
35
+ to_key,
31
36
  )
32
37
  from streamlit.errors import StreamlitAPIException
33
38
  from streamlit.proto.MultiSelect_pb2 import MultiSelect as MultiSelectProto
@@ -41,16 +46,10 @@ from streamlit.runtime.state import (
41
46
  )
42
47
  from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
43
48
  from streamlit.type_util import (
44
- Key,
45
- LabelVisibility,
46
- OptionSequence,
47
49
  T,
48
50
  check_python_comparable,
49
- ensure_indexable,
50
51
  is_iterable,
51
52
  is_type,
52
- maybe_raise_label_warnings,
53
- to_key,
54
53
  )
55
54
 
56
55
  if TYPE_CHECKING:
@@ -298,7 +297,7 @@ class MultiSelectMixin:
298
297
  check_session_state_rules(default_value=default, key=key)
299
298
  maybe_raise_label_warnings(label, label_visibility)
300
299
 
301
- opt = ensure_indexable(options)
300
+ opt = convert_anything_to_sequence(options)
302
301
  check_python_comparable(opt)
303
302
 
304
303
  indices = _check_and_convert_to_indices(opt, default)
@@ -27,8 +27,14 @@ from streamlit.elements.lib.policies import (
27
27
  check_callback_rules,
28
28
  check_fragment_path_policy,
29
29
  check_session_state_rules,
30
+ maybe_raise_label_warnings,
31
+ )
32
+ from streamlit.elements.lib.utils import (
33
+ Key,
34
+ LabelVisibility,
35
+ get_label_visibility_proto_value,
36
+ to_key,
30
37
  )
31
- from streamlit.elements.lib.utils import get_label_visibility_proto_value
32
38
  from streamlit.errors import StreamlitAPIException
33
39
  from streamlit.js_number import JSNumber, JSNumberBoundsException
34
40
  from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
@@ -42,7 +48,6 @@ from streamlit.runtime.state import (
42
48
  register_widget,
43
49
  )
44
50
  from streamlit.runtime.state.common import compute_widget_id
45
- from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
46
51
 
47
52
  if TYPE_CHECKING:
48
53
  from streamlit.delta_generator import DeltaGenerator
@@ -18,16 +18,21 @@ from dataclasses import dataclass
18
18
  from textwrap import dedent
19
19
  from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
20
20
 
21
+ from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
21
22
  from streamlit.elements.form import current_form_id
22
23
  from streamlit.elements.lib.policies import (
23
24
  check_cache_replay_rules,
24
25
  check_callback_rules,
25
26
  check_fragment_path_policy,
26
27
  check_session_state_rules,
28
+ maybe_raise_label_warnings,
27
29
  )
28
30
  from streamlit.elements.lib.utils import (
31
+ Key,
32
+ LabelVisibility,
29
33
  get_label_visibility_proto_value,
30
34
  maybe_coerce_enum,
35
+ to_key,
31
36
  )
32
37
  from streamlit.errors import StreamlitAPIException
33
38
  from streamlit.proto.Radio_pb2 import Radio as RadioProto
@@ -42,14 +47,8 @@ from streamlit.runtime.state import (
42
47
  )
43
48
  from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
44
49
  from streamlit.type_util import (
45
- Key,
46
- LabelVisibility,
47
- OptionSequence,
48
50
  T,
49
51
  check_python_comparable,
50
- ensure_indexable,
51
- maybe_raise_label_warnings,
52
- to_key,
53
52
  )
54
53
  from streamlit.util import index_
55
54
 
@@ -264,7 +263,7 @@ class RadioMixin:
264
263
  check_session_state_rules(default_value=None if index == 0 else index, key=key)
265
264
  maybe_raise_label_warnings(label, label_visibility)
266
265
 
267
- opt = ensure_indexable(options)
266
+ opt = convert_anything_to_sequence(options)
268
267
  check_python_comparable(opt)
269
268
 
270
269
  id = compute_widget_id(
@@ -20,16 +20,21 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, Tuple, cast
20
20
 
21
21
  from typing_extensions import TypeGuard
22
22
 
23
+ from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
23
24
  from streamlit.elements.form import current_form_id
24
25
  from streamlit.elements.lib.policies import (
25
26
  check_cache_replay_rules,
26
27
  check_callback_rules,
27
28
  check_session_state_rules,
29
+ maybe_raise_label_warnings,
28
30
  )
29
31
  from streamlit.elements.lib.utils import (
32
+ Key,
33
+ LabelVisibility,
30
34
  get_label_visibility_proto_value,
31
35
  maybe_coerce_enum,
32
36
  maybe_coerce_enum_sequence,
37
+ to_key,
33
38
  )
34
39
  from streamlit.errors import StreamlitAPIException
35
40
  from streamlit.proto.Slider_pb2 import Slider as SliderProto
@@ -47,14 +52,8 @@ from streamlit.runtime.state.common import (
47
52
  save_for_app_testing,
48
53
  )
49
54
  from streamlit.type_util import (
50
- Key,
51
- LabelVisibility,
52
- OptionSequence,
53
55
  T,
54
56
  check_python_comparable,
55
- ensure_indexable,
56
- maybe_raise_label_warnings,
57
- to_key,
58
57
  )
59
58
  from streamlit.util import index_
60
59
 
@@ -268,7 +267,7 @@ class SelectSliderMixin:
268
267
  check_session_state_rules(default_value=value, key=key)
269
268
  maybe_raise_label_warnings(label, label_visibility)
270
269
 
271
- opt = ensure_indexable(options)
270
+ opt = convert_anything_to_sequence(options)
272
271
  check_python_comparable(opt)
273
272
 
274
273
  if len(opt) == 0:
@@ -17,16 +17,21 @@ from dataclasses import dataclass
17
17
  from textwrap import dedent
18
18
  from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
19
19
 
20
+ from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
20
21
  from streamlit.elements.form import current_form_id
21
22
  from streamlit.elements.lib.policies import (
22
23
  check_cache_replay_rules,
23
24
  check_callback_rules,
24
25
  check_fragment_path_policy,
25
26
  check_session_state_rules,
27
+ maybe_raise_label_warnings,
26
28
  )
27
29
  from streamlit.elements.lib.utils import (
30
+ Key,
31
+ LabelVisibility,
28
32
  get_label_visibility_proto_value,
29
33
  maybe_coerce_enum,
34
+ to_key,
30
35
  )
31
36
  from streamlit.errors import StreamlitAPIException
32
37
  from streamlit.proto.Selectbox_pb2 import Selectbox as SelectboxProto
@@ -41,14 +46,8 @@ from streamlit.runtime.state import (
41
46
  )
42
47
  from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
43
48
  from streamlit.type_util import (
44
- Key,
45
- LabelVisibility,
46
- OptionSequence,
47
49
  T,
48
50
  check_python_comparable,
49
- ensure_indexable,
50
- maybe_raise_label_warnings,
51
- to_key,
52
51
  )
53
52
  from streamlit.util import index_
54
53
 
@@ -244,7 +243,7 @@ class SelectboxMixin:
244
243
  check_session_state_rules(default_value=None if index == 0 else index, key=key)
245
244
  maybe_raise_label_warnings(label, label_visibility)
246
245
 
247
- opt = ensure_indexable(options)
246
+ opt = convert_anything_to_sequence(options)
248
247
  check_python_comparable(opt)
249
248
 
250
249
  id = compute_widget_id(
@@ -28,8 +28,14 @@ from streamlit.elements.lib.policies import (
28
28
  check_callback_rules,
29
29
  check_fragment_path_policy,
30
30
  check_session_state_rules,
31
+ maybe_raise_label_warnings,
32
+ )
33
+ from streamlit.elements.lib.utils import (
34
+ Key,
35
+ LabelVisibility,
36
+ get_label_visibility_proto_value,
37
+ to_key,
31
38
  )
32
- from streamlit.elements.lib.utils import get_label_visibility_proto_value
33
39
  from streamlit.errors import StreamlitAPIException
34
40
  from streamlit.js_number import JSNumber, JSNumberBoundsException
35
41
  from streamlit.proto.Slider_pb2 import Slider as SliderProto
@@ -43,7 +49,6 @@ from streamlit.runtime.state import (
43
49
  register_widget,
44
50
  )
45
51
  from streamlit.runtime.state.common import compute_widget_id
46
- from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
47
52
 
48
53
  if TYPE_CHECKING:
49
54
  from streamlit.delta_generator import DeltaGenerator
@@ -24,8 +24,14 @@ from streamlit.elements.lib.policies import (
24
24
  check_callback_rules,
25
25
  check_fragment_path_policy,
26
26
  check_session_state_rules,
27
+ maybe_raise_label_warnings,
28
+ )
29
+ from streamlit.elements.lib.utils import (
30
+ Key,
31
+ LabelVisibility,
32
+ get_label_visibility_proto_value,
33
+ to_key,
27
34
  )
28
- from streamlit.elements.lib.utils import get_label_visibility_proto_value
29
35
  from streamlit.errors import StreamlitAPIException
30
36
  from streamlit.proto.TextArea_pb2 import TextArea as TextAreaProto
31
37
  from streamlit.proto.TextInput_pb2 import TextInput as TextInputProto
@@ -40,15 +46,12 @@ from streamlit.runtime.state import (
40
46
  )
41
47
  from streamlit.runtime.state.common import compute_widget_id
42
48
  from streamlit.type_util import (
43
- Key,
44
- LabelVisibility,
45
49
  SupportsStr,
46
- maybe_raise_label_warnings,
47
- to_key,
48
50
  )
49
51
 
50
52
  if TYPE_CHECKING:
51
53
  from streamlit.delta_generator import DeltaGenerator
54
+ from streamlit.type_util import SupportsStr
52
55
 
53
56
 
54
57
  @dataclass
@@ -38,8 +38,14 @@ from streamlit.elements.lib.policies import (
38
38
  check_callback_rules,
39
39
  check_fragment_path_policy,
40
40
  check_session_state_rules,
41
+ maybe_raise_label_warnings,
42
+ )
43
+ from streamlit.elements.lib.utils import (
44
+ Key,
45
+ LabelVisibility,
46
+ get_label_visibility_proto_value,
47
+ to_key,
41
48
  )
42
- from streamlit.elements.lib.utils import get_label_visibility_proto_value
43
49
  from streamlit.errors import StreamlitAPIException
44
50
  from streamlit.proto.DateInput_pb2 import DateInput as DateInputProto
45
51
  from streamlit.proto.TimeInput_pb2 import TimeInput as TimeInputProto
@@ -54,7 +60,6 @@ from streamlit.runtime.state import (
54
60
  )
55
61
  from streamlit.runtime.state.common import compute_widget_id
56
62
  from streamlit.time_util import adjust_years
57
- from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
58
63
 
59
64
  if TYPE_CHECKING:
60
65
  from streamlit.delta_generator import DeltaGenerator
@@ -21,7 +21,7 @@ import types
21
21
  from io import StringIO
22
22
  from typing import TYPE_CHECKING, Any, Callable, Final, Generator, Iterable, List, cast
23
23
 
24
- from streamlit import type_util
24
+ from streamlit import dataframe_util, type_util
25
25
  from streamlit.errors import StreamlitAPIException
26
26
  from streamlit.logger import get_logger
27
27
  from streamlit.runtime.metrics_util import gather_metrics
@@ -128,7 +128,7 @@ class WriteMixin:
128
128
 
129
129
  # Just apply some basic checks for common iterable types that should
130
130
  # not be passed in here.
131
- if isinstance(stream, str) or type_util.is_dataframe_like(stream):
131
+ if isinstance(stream, str) or dataframe_util.is_dataframe_like(stream):
132
132
  raise StreamlitAPIException(
133
133
  "`st.write_stream` expects a generator or stream-like object as input "
134
134
  f"not {type(stream)}. Please use `st.write` instead for "
@@ -401,12 +401,12 @@ class WriteMixin:
401
401
  item()
402
402
  else:
403
403
  self.write(item, unsafe_allow_html=unsafe_allow_html)
404
- elif type_util.is_unevaluated_data_object(
404
+ elif dataframe_util.is_unevaluated_data_object(
405
405
  arg
406
- ) or type_util.is_snowpark_row_list(arg):
406
+ ) or dataframe_util.is_snowpark_row_list(arg):
407
407
  flush_buffer()
408
408
  self.dg.dataframe(arg)
409
- elif type_util.is_dataframe_like(arg):
409
+ elif dataframe_util.is_dataframe_like(arg):
410
410
  import numpy as np
411
411
 
412
412
  flush_buffer()
@@ -26,6 +26,7 @@ from collections import defaultdict
26
26
  from typing import TYPE_CHECKING, Any, Callable, Final
27
27
 
28
28
  from streamlit import type_util
29
+ from streamlit.dataframe_util import UNEVALUATED_DATAFRAME_TYPES
29
30
  from streamlit.elements.spinner import spinner
30
31
  from streamlit.logger import get_logger
31
32
  from streamlit.runtime.caching.cache_errors import (
@@ -44,7 +45,6 @@ from streamlit.runtime.caching.cached_message_replay import (
44
45
  replay_cached_messages,
45
46
  )
46
47
  from streamlit.runtime.caching.hashing import HashFuncsDict, update_hash
47
- from streamlit.type_util import UNEVALUATED_DATAFRAME_TYPES
48
48
  from streamlit.util import HASHLIB_KWARGS
49
49
 
50
50
  if TYPE_CHECKING:
@@ -27,13 +27,16 @@ from typing import (
27
27
  Final,
28
28
  Generic,
29
29
  Iterable,
30
+ Literal,
30
31
  Tuple,
31
32
  TypeVar,
32
33
  Union,
34
+ cast,
35
+ get_args,
33
36
  )
34
37
 
35
38
  from google.protobuf.message import Message
36
- from typing_extensions import TypeAlias
39
+ from typing_extensions import TypeAlias, TypeGuard
37
40
 
38
41
  from streamlit import config, util
39
42
  from streamlit.errors import StreamlitAPIException
@@ -64,7 +67,6 @@ if TYPE_CHECKING:
64
67
 
65
68
  from streamlit.runtime.scriptrunner.script_run_context import ScriptRunContext
66
69
  from streamlit.runtime.state.widgets import NoValue
67
- from streamlit.type_util import ValueFieldName
68
70
 
69
71
 
70
72
  # Protobuf types for all widgets.
@@ -110,6 +112,53 @@ WidgetCallback: TypeAlias = Callable[..., None]
110
112
  WidgetDeserializer: TypeAlias = Callable[[Any, str], T]
111
113
  WidgetSerializer: TypeAlias = Callable[[T], Any]
112
114
 
115
+ # The array value field names are part of the larger set of possible value
116
+ # field names. See the explanation for said set below. The message types
117
+ # associated with these fields are distinguished by storing data in a `data`
118
+ # field in their messages, meaning they need special treatment in certain
119
+ # circumstances. Hence, they need their own, dedicated, sub-type.
120
+ ArrayValueFieldName: TypeAlias = Literal[
121
+ "double_array_value",
122
+ "int_array_value",
123
+ "string_array_value",
124
+ ]
125
+
126
+ # A frozenset containing the allowed values of the ArrayValueFieldName type.
127
+ # Useful for membership checking.
128
+ _ARRAY_VALUE_FIELD_NAMES: Final = frozenset(
129
+ cast(
130
+ "tuple[ArrayValueFieldName, ...]",
131
+ # NOTE: get_args is not recursive, so this only works as long as
132
+ # ArrayValueFieldName remains flat.
133
+ get_args(ArrayValueFieldName),
134
+ )
135
+ )
136
+
137
+ # These are the possible field names that can be set in the `value` oneof-field
138
+ # of the WidgetState message (schema found in .proto/WidgetStates.proto).
139
+ # We need these as a literal type to ensure correspondence with the protobuf
140
+ # schema in certain parts of the python code.
141
+ # TODO(harahu): It would be preferable if this type was automatically derived
142
+ # from the protobuf schema, rather than manually maintained. Not sure how to
143
+ # achieve that, though.
144
+ ValueFieldName: TypeAlias = Literal[
145
+ ArrayValueFieldName,
146
+ "arrow_value",
147
+ "bool_value",
148
+ "bytes_value",
149
+ "double_value",
150
+ "file_uploader_state_value",
151
+ "int_value",
152
+ "json_value",
153
+ "string_value",
154
+ "trigger_value",
155
+ "string_trigger_value",
156
+ ]
157
+
158
+
159
+ def is_array_value_field_name(obj: object) -> TypeGuard[ArrayValueFieldName]:
160
+ return obj in _ARRAY_VALUE_FIELD_NAMES
161
+
113
162
 
114
163
  @dataclass(frozen=True)
115
164
  class WidgetMetadata(Generic[T]):
@@ -40,13 +40,14 @@ from streamlit.proto.WidgetStates_pb2 import WidgetStates as WidgetStatesProto
40
40
  from streamlit.runtime.state.common import (
41
41
  RegisterWidgetResult,
42
42
  T,
43
+ ValueFieldName,
43
44
  WidgetMetadata,
45
+ is_array_value_field_name,
44
46
  is_keyed_widget_id,
45
47
  is_widget_id,
46
48
  )
47
49
  from streamlit.runtime.state.query_params import QueryParams
48
50
  from streamlit.runtime.stats import CacheStat, CacheStatsProvider, group_stats
49
- from streamlit.type_util import ValueFieldName, is_array_value_field_name
50
51
 
51
52
  if TYPE_CHECKING:
52
53
  from streamlit.runtime.session_manager import SessionManager
@@ -18,11 +18,11 @@ from typing import Any, Final, Iterator, MutableMapping
18
18
 
19
19
  from streamlit import logger as _logger
20
20
  from streamlit import runtime
21
+ from streamlit.elements.lib.utils import Key
21
22
  from streamlit.runtime.metrics_util import gather_metrics
22
23
  from streamlit.runtime.state.common import require_valid_user_key
23
24
  from streamlit.runtime.state.safe_session_state import SafeSessionState
24
25
  from streamlit.runtime.state.session_state import SessionState
25
- from streamlit.type_util import Key
26
26
 
27
27
  _LOGGER: Final = _logger.get_logger(__name__)
28
28
 
@@ -25,6 +25,7 @@ from streamlit.proto.WidgetStates_pb2 import WidgetState, WidgetStates
25
25
  from streamlit.runtime.state.common import (
26
26
  RegisterWidgetResult,
27
27
  T,
28
+ ValueFieldName,
28
29
  WidgetArgs,
29
30
  WidgetCallback,
30
31
  WidgetDeserializer,
@@ -37,7 +38,6 @@ from streamlit.runtime.state.common import (
37
38
 
38
39
  if TYPE_CHECKING:
39
40
  from streamlit.runtime.scriptrunner import ScriptRunContext
40
- from streamlit.type_util import ValueFieldName
41
41
 
42
42
 
43
43
  ElementType: TypeAlias = str
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.29bca1b5.css",
4
- "main.js": "./static/js/main.e2ab315a.js",
4
+ "main.js": "./static/js/main.28e3c6e9.js",
5
5
  "static/js/9336.3e046ad7.chunk.js": "./static/js/9336.3e046ad7.chunk.js",
6
6
  "static/js/9330.2b4c99e0.chunk.js": "./static/js/9330.2b4c99e0.chunk.js",
7
7
  "static/js/2736.4336e2b9.chunk.js": "./static/js/2736.4336e2b9.chunk.js",
@@ -151,6 +151,6 @@
151
151
  },
152
152
  "entrypoints": [
153
153
  "static/css/main.29bca1b5.css",
154
- "static/js/main.e2ab315a.js"
154
+ "static/js/main.28e3c6e9.js"
155
155
  ]
156
156
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.e2ab315a.js"></script><link href="./static/css/main.29bca1b5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.28e3c6e9.js"></script><link href="./static/css/main.29bca1b5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>