streamlit-nightly 1.36.1.dev20240707__py2.py3-none-any.whl → 1.36.1.dev20240709__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 (60) hide show
  1. streamlit/code_util.py +1 -1
  2. streamlit/commands/execution_control.py +6 -2
  3. streamlit/commands/logo.py +5 -1
  4. streamlit/commands/navigation.py +5 -5
  5. streamlit/connections/base_connection.py +1 -1
  6. streamlit/connections/snowpark_connection.py +1 -1
  7. streamlit/connections/sql_connection.py +5 -1
  8. streamlit/delta_generator.py +14 -14
  9. streamlit/elements/arrow.py +19 -11
  10. streamlit/elements/bokeh_chart.py +2 -6
  11. streamlit/elements/code.py +1 -1
  12. streamlit/elements/deck_gl_json_chart.py +32 -29
  13. streamlit/elements/doc_string.py +1 -1
  14. streamlit/elements/empty.py +1 -1
  15. streamlit/elements/exception.py +1 -1
  16. streamlit/elements/form.py +7 -8
  17. streamlit/elements/graphviz_chart.py +13 -13
  18. streamlit/elements/heading.py +6 -6
  19. streamlit/elements/html.py +3 -1
  20. streamlit/elements/image.py +1 -1
  21. streamlit/elements/json.py +12 -10
  22. streamlit/elements/layouts.py +21 -21
  23. streamlit/elements/lib/built_in_chart_utils.py +21 -7
  24. streamlit/elements/markdown.py +3 -3
  25. streamlit/elements/media.py +2 -2
  26. streamlit/elements/metric.py +4 -4
  27. streamlit/elements/spinner.py +1 -1
  28. streamlit/elements/text.py +1 -1
  29. streamlit/elements/vega_charts.py +87 -43
  30. streamlit/elements/widgets/button.py +5 -5
  31. streamlit/elements/widgets/file_uploader.py +3 -1
  32. streamlit/elements/widgets/multiselect.py +2 -1
  33. streamlit/elements/widgets/number_input.py +6 -2
  34. streamlit/elements/widgets/radio.py +6 -1
  35. streamlit/elements/widgets/select_slider.py +21 -3
  36. streamlit/elements/widgets/selectbox.py +6 -5
  37. streamlit/elements/widgets/slider.py +5 -6
  38. streamlit/elements/widgets/text_widgets.py +1 -1
  39. streamlit/elements/write.py +17 -13
  40. streamlit/runtime/caching/cache_data_api.py +3 -3
  41. streamlit/runtime/caching/cache_resource_api.py +3 -3
  42. streamlit/runtime/caching/legacy_cache_api.py +1 -1
  43. streamlit/runtime/connection_factory.py +10 -4
  44. streamlit/static/asset-manifest.json +5 -5
  45. streamlit/static/index.html +1 -1
  46. streamlit/static/static/js/{2736.4336e2b9.chunk.js → 2736.7d516fcc.chunk.js} +1 -1
  47. streamlit/static/static/js/3301.0cd98943.chunk.js +1 -0
  48. streamlit/static/static/js/7175.4cdaec13.chunk.js +1 -0
  49. streamlit/static/static/js/{main.28e3c6e9.js → main.2bfed63a.js} +2 -2
  50. streamlit/testing/v1/util.py +2 -2
  51. streamlit/type_util.py +1 -1
  52. {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/METADATA +1 -1
  53. {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/RECORD +58 -58
  54. {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/WHEEL +1 -1
  55. streamlit/static/static/js/3301.1d1b10bb.chunk.js +0 -1
  56. streamlit/static/static/js/7175.8f4014ec.chunk.js +0 -1
  57. /streamlit/static/static/js/{main.28e3c6e9.js.LICENSE.txt → main.2bfed63a.js.LICENSE.txt} +0 -0
  58. {streamlit_nightly-1.36.1.dev20240707.data → streamlit_nightly-1.36.1.dev20240709.data}/scripts/streamlit.cmd +0 -0
  59. {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/entry_points.txt +0 -0
  60. {streamlit_nightly-1.36.1.dev20240707.dist-info → streamlit_nightly-1.36.1.dev20240709.dist-info}/top_level.txt +0 -0
streamlit/code_util.py CHANGED
@@ -73,7 +73,7 @@ def get_method_args_from_code(args: list[Any], line: str) -> list[str]:
73
73
 
74
74
  Example
75
75
  -------
76
- >>> line = 'foo(bar, baz, my(func, tion))'
76
+ >>> line = "foo(bar, baz, my(func, tion))"
77
77
  >>>
78
78
  >>> get_method_args_from_code(range(0, 3), line)
79
79
  ['bar', 'baz', 'my(func, tion)']
@@ -39,11 +39,11 @@ def stop() -> NoReturn: # type: ignore[misc]
39
39
  -------
40
40
  >>> import streamlit as st
41
41
  >>>
42
- >>> name = st.text_input('Name')
42
+ >>> name = st.text_input("Name")
43
43
  >>> if not name:
44
44
  >>> st.warning('Please input a name.')
45
45
  >>> st.stop()
46
- >>> st.success('Thank you for inputting a name.')
46
+ >>> st.success("Thank you for inputting a name.")
47
47
 
48
48
  """
49
49
  ctx = get_script_run_ctx()
@@ -151,6 +151,10 @@ def switch_page(page: str | StreamlitPage) -> NoReturn: # type: ignore[misc]
151
151
 
152
152
  page_script_hash = matched_pages[0]["page_script_hash"]
153
153
 
154
+ # We want to reset query params (with exception of embed) when switching pages
155
+ with ctx.session_state.query_params() as qp:
156
+ qp.clear()
157
+
154
158
  ctx.script_requests.request_rerun(
155
159
  RerunData(
156
160
  query_string=ctx.query_string,
@@ -81,7 +81,11 @@ def logo(
81
81
 
82
82
  >>> import streamlit as st
83
83
  >>>
84
- >>> st.logo(LOGO_URL_LARGE, link="https://streamlit.io/gallery", icon_image=LOGO_URL_SMALL)
84
+ >>> st.logo(
85
+ ... LOGO_URL_LARGE,
86
+ ... link="https://streamlit.io/gallery",
87
+ ... icon_image=LOGO_URL_SMALL,
88
+ ... )
85
89
 
86
90
  Try switching logos around in the following example:
87
91
 
@@ -126,14 +126,14 @@ def navigation(
126
126
  >>> import streamlit as st
127
127
  >>>
128
128
  >>> pages = {
129
- ... "Your account" : [
129
+ ... "Your account": [
130
130
  ... st.Page("create_account.py", title="Create your account"),
131
- ... st.Page("manage_account.py", title="Manage your account")
131
+ ... st.Page("manage_account.py", title="Manage your account"),
132
132
  ... ],
133
- ... "Resources" : [
133
+ ... "Resources": [
134
134
  ... st.Page("learn.py", title="Learn about us"),
135
- ... st.Page("trial.py", title="Try it out")
136
- ... ]
135
+ ... st.Page("trial.py", title="Try it out"),
136
+ ... ],
137
137
  ... }
138
138
  >>>
139
139
  >>> pg = st.navigation(pages)
@@ -164,7 +164,7 @@ class BaseConnection(ABC, Generic[RawConnectionT]):
164
164
  >>> # Note: is_healthy() isn't a real method and is just shown for example here.
165
165
  >>> if not conn.is_healthy():
166
166
  ... conn.reset()
167
- ...
167
+ >>>
168
168
  >>> # Do stuff with conn...
169
169
  """
170
170
  self._raw_instance = None
@@ -205,7 +205,7 @@ class SnowparkConnection(BaseConnection["Session"]):
205
205
  >>> conn = st.connection("snowpark")
206
206
  >>> with conn.safe_session() as session:
207
207
  ... df = session.table("mytable").limit(10).to_pandas()
208
- ...
208
+ >>>
209
209
  >>> st.dataframe(df)
210
210
  """
211
211
  with self._lock:
@@ -186,7 +186,11 @@ class SQLConnection(BaseConnection["Engine"]):
186
186
  >>> import streamlit as st
187
187
  >>>
188
188
  >>> conn = st.connection("sql")
189
- >>> df = conn.query("select * from pet_owners where owner = :owner", ttl=3600, params={"owner":"barbara"})
189
+ >>> df = conn.query(
190
+ ... "select * from pet_owners where owner = :owner",
191
+ ... ttl=3600,
192
+ ... params={"owner": "barbara"},
193
+ ... )
190
194
  >>> st.dataframe(df)
191
195
  """
192
196
 
@@ -577,15 +577,13 @@ class DeltaGenerator(
577
577
  >>> import numpy as np
578
578
  >>>
579
579
  >>> df1 = pd.DataFrame(
580
- ... np.random.randn(50, 20),
581
- ... columns=('col %d' % i for i in range(20)))
582
- ...
580
+ ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
581
+ ... )
583
582
  >>> my_table = st.table(df1)
584
583
  >>>
585
584
  >>> df2 = pd.DataFrame(
586
- ... np.random.randn(50, 20),
587
- ... columns=('col %d' % i for i in range(20)))
588
- ...
585
+ ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
586
+ ... )
589
587
  >>> my_table.add_rows(df2)
590
588
  >>> # Now the table shown in the Streamlit app contains the data for
591
589
  >>> # df1 followed by the data for df2.
@@ -602,14 +600,16 @@ class DeltaGenerator(
602
600
  And for plots whose datasets are named, you can pass the data with a
603
601
  keyword argument where the key is the name:
604
602
 
605
- >>> my_chart = st.vega_lite_chart({
606
- ... 'mark': 'line',
607
- ... 'encoding': {'x': 'a', 'y': 'b'},
608
- ... 'datasets': {
609
- ... 'some_fancy_name': df1, # <-- named dataset
610
- ... },
611
- ... 'data': {'name': 'some_fancy_name'},
612
- ... }),
603
+ >>> my_chart = st.vega_lite_chart(
604
+ ... {
605
+ ... "mark": "line",
606
+ ... "encoding": {"x": "a", "y": "b"},
607
+ ... "datasets": {
608
+ ... "some_fancy_name": df1, # <-- named dataset
609
+ ... },
610
+ ... "data": {"name": "some_fancy_name"},
611
+ ... }
612
+ ... )
613
613
  >>> my_chart.add_rows(some_fancy_name=df2) # <-- name used as keyword
614
614
 
615
615
  """
@@ -587,7 +587,9 @@ class ArrowMixin:
587
587
  >>> import pandas as pd
588
588
  >>> import numpy as np
589
589
  >>>
590
- >>> df = pd.DataFrame(np.random.randn(10, 5), columns=("col %d" % i for i in range(5)))
590
+ >>> df = pd.DataFrame(
591
+ ... np.random.randn(10, 5), columns=("col %d" % i for i in range(5))
592
+ ... )
591
593
  >>>
592
594
  >>> st.table(df)
593
595
 
@@ -633,11 +635,15 @@ class ArrowMixin:
633
635
  >>> import pandas as pd
634
636
  >>> import numpy as np
635
637
  >>>
636
- >>> df1 = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
638
+ >>> df1 = pd.DataFrame(
639
+ ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
640
+ ... )
637
641
  >>>
638
642
  >>> my_table = st.table(df1)
639
643
  >>>
640
- >>> df2 = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
644
+ >>> df2 = pd.DataFrame(
645
+ ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
646
+ ... )
641
647
  >>>
642
648
  >>> my_table.add_rows(df2)
643
649
  >>> # Now the table shown in the Streamlit app contains the data for
@@ -655,14 +661,16 @@ class ArrowMixin:
655
661
  And for plots whose datasets are named, you can pass the data with a
656
662
  keyword argument where the key is the name:
657
663
 
658
- >>> my_chart = st.vega_lite_chart({
659
- ... 'mark': 'line',
660
- ... 'encoding': {'x': 'a', 'y': 'b'},
661
- ... 'datasets': {
662
- ... 'some_fancy_name': df1, # <-- named dataset
663
- ... },
664
- ... 'data': {'name': 'some_fancy_name'},
665
- ... }),
664
+ >>> my_chart = st.vega_lite_chart(
665
+ ... {
666
+ ... "mark": "line",
667
+ ... "encoding": {"x": "a", "y": "b"},
668
+ ... "datasets": {
669
+ ... "some_fancy_name": df1, # <-- named dataset
670
+ ... },
671
+ ... "data": {"name": "some_fancy_name"},
672
+ ... }
673
+ ... )
666
674
  >>> my_chart.add_rows(some_fancy_name=df2) # <-- name used as keyword
667
675
 
668
676
  """
@@ -70,12 +70,8 @@ class BokehMixin:
70
70
  >>> x = [1, 2, 3, 4, 5]
71
71
  >>> y = [6, 7, 2, 4, 5]
72
72
  >>>
73
- >>> p = figure(
74
- ... title='simple line example',
75
- ... x_axis_label='x',
76
- ... y_axis_label='y')
77
- ...
78
- >>> p.line(x, y, legend_label='Trend', line_width=2)
73
+ >>> p = figure(title="simple line example", x_axis_label="x", y_axis_label="y")
74
+ >>> p.line(x, y, legend_label="Trend", line_width=2)
79
75
  >>>
80
76
  >>> st.bokeh_chart(p, use_container_width=True)
81
77
 
@@ -58,7 +58,7 @@ class CodeMixin:
58
58
  >>>
59
59
  >>> code = '''def hello():
60
60
  ... print("Hello, Streamlit!")'''
61
- >>> st.code(code, language='python')
61
+ >>> st.code(code, language="python")
62
62
 
63
63
  """
64
64
  code_proto = CodeProto()
@@ -91,37 +91,40 @@ class PydeckMixin:
91
91
  >>> import pydeck as pdk
92
92
  >>>
93
93
  >>> chart_data = pd.DataFrame(
94
- ... np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
95
- ... columns=['lat', 'lon'])
94
+ ... np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
95
+ ... columns=["lat", "lon"],
96
+ ... )
96
97
  >>>
97
- >>> st.pydeck_chart(pdk.Deck(
98
- ... map_style=None,
99
- ... initial_view_state=pdk.ViewState(
100
- ... latitude=37.76,
101
- ... longitude=-122.4,
102
- ... zoom=11,
103
- ... pitch=50,
104
- ... ),
105
- ... layers=[
106
- ... pdk.Layer(
107
- ... 'HexagonLayer',
108
- ... data=chart_data,
109
- ... get_position='[lon, lat]',
110
- ... radius=200,
111
- ... elevation_scale=4,
112
- ... elevation_range=[0, 1000],
113
- ... pickable=True,
114
- ... extruded=True,
98
+ >>> st.pydeck_chart(
99
+ ... pdk.Deck(
100
+ ... map_style=None,
101
+ ... initial_view_state=pdk.ViewState(
102
+ ... latitude=37.76,
103
+ ... longitude=-122.4,
104
+ ... zoom=11,
105
+ ... pitch=50,
115
106
  ... ),
116
- ... pdk.Layer(
117
- ... 'ScatterplotLayer',
118
- ... data=chart_data,
119
- ... get_position='[lon, lat]',
120
- ... get_color='[200, 30, 0, 160]',
121
- ... get_radius=200,
122
- ... ),
123
- ... ],
124
- ... ))
107
+ ... layers=[
108
+ ... pdk.Layer(
109
+ ... "HexagonLayer",
110
+ ... data=chart_data,
111
+ ... get_position="[lon, lat]",
112
+ ... radius=200,
113
+ ... elevation_scale=4,
114
+ ... elevation_range=[0, 1000],
115
+ ... pickable=True,
116
+ ... extruded=True,
117
+ ... ),
118
+ ... pdk.Layer(
119
+ ... "ScatterplotLayer",
120
+ ... data=chart_data,
121
+ ... get_position="[lon, lat]",
122
+ ... get_color="[200, 30, 0, 160]",
123
+ ... get_radius=200,
124
+ ... ),
125
+ ... ],
126
+ ... )
127
+ ... )
125
128
 
126
129
  .. output::
127
130
  https://doc-pydeck-chart.streamlit.app/
@@ -90,7 +90,7 @@ class HelpMixin:
90
90
  >>> return 'Woof!'
91
91
  >>>
92
92
  >>>
93
- >>> fido = Dog('poodle', 'white')
93
+ >>> fido = Dog("poodle", "white")
94
94
  >>>
95
95
  >>> st.help(fido)
96
96
 
@@ -66,7 +66,7 @@ class EmptyMixin:
66
66
  >>> with placeholder.container():
67
67
  ... st.write("This is one element")
68
68
  ... st.write("This is another")
69
- ...
69
+ >>>
70
70
  >>> # Clear all those elements:
71
71
  >>> placeholder.empty()
72
72
 
@@ -59,7 +59,7 @@ class ExceptionMixin:
59
59
  -------
60
60
  >>> import streamlit as st
61
61
  >>>
62
- >>> e = RuntimeError('This is an exception of type RuntimeError')
62
+ >>> e = RuntimeError("This is an exception of type RuntimeError")
63
63
  >>> st.exception(e)
64
64
 
65
65
  """
@@ -162,15 +162,14 @@ class FormMixin:
162
162
  >>> import streamlit as st
163
163
  >>>
164
164
  >>> with st.form("my_form"):
165
- ... st.write("Inside the form")
166
- ... slider_val = st.slider("Form slider")
167
- ... checkbox_val = st.checkbox("Form checkbox")
168
- ...
169
- ... # Every form must have a submit button.
170
- ... submitted = st.form_submit_button("Submit")
171
- ... if submitted:
172
- ... st.write("slider", slider_val, "checkbox", checkbox_val)
165
+ ... st.write("Inside the form")
166
+ ... slider_val = st.slider("Form slider")
167
+ ... checkbox_val = st.checkbox("Form checkbox")
173
168
  ...
169
+ ... # Every form must have a submit button.
170
+ ... submitted = st.form_submit_button("Submit")
171
+ ... if submitted:
172
+ ... st.write("slider", slider_val, "checkbox", checkbox_val)
174
173
  >>> st.write("Outside the form")
175
174
 
176
175
  .. output::
@@ -66,19 +66,19 @@ class GraphvizMixin:
66
66
  >>>
67
67
  >>> # Create a graphlib graph object
68
68
  >>> graph = graphviz.Digraph()
69
- >>> graph.edge('run', 'intr')
70
- >>> graph.edge('intr', 'runbl')
71
- >>> graph.edge('runbl', 'run')
72
- >>> graph.edge('run', 'kernel')
73
- >>> graph.edge('kernel', 'zombie')
74
- >>> graph.edge('kernel', 'sleep')
75
- >>> graph.edge('kernel', 'runmem')
76
- >>> graph.edge('sleep', 'swap')
77
- >>> graph.edge('swap', 'runswap')
78
- >>> graph.edge('runswap', 'new')
79
- >>> graph.edge('runswap', 'runmem')
80
- >>> graph.edge('new', 'runmem')
81
- >>> graph.edge('sleep', 'runmem')
69
+ >>> graph.edge("run", "intr")
70
+ >>> graph.edge("intr", "runbl")
71
+ >>> graph.edge("runbl", "run")
72
+ >>> graph.edge("run", "kernel")
73
+ >>> graph.edge("kernel", "zombie")
74
+ >>> graph.edge("kernel", "sleep")
75
+ >>> graph.edge("kernel", "runmem")
76
+ >>> graph.edge("sleep", "swap")
77
+ >>> graph.edge("swap", "runswap")
78
+ >>> graph.edge("runswap", "new")
79
+ >>> graph.edge("runswap", "runmem")
80
+ >>> graph.edge("new", "runmem")
81
+ >>> graph.edge("sleep", "runmem")
82
82
  >>>
83
83
  >>> st.graphviz_chart(graph)
84
84
 
@@ -94,8 +94,8 @@ class HeadingMixin:
94
94
  --------
95
95
  >>> import streamlit as st
96
96
  >>>
97
- >>> st.header('This is a header with a divider', divider='rainbow')
98
- >>> st.header('_Streamlit_ is :blue[cool] :sunglasses:')
97
+ >>> st.header("This is a header with a divider", divider="rainbow")
98
+ >>> st.header("_Streamlit_ is :blue[cool] :sunglasses:")
99
99
 
100
100
  .. output::
101
101
  https://doc-header.streamlit.app/
@@ -167,8 +167,8 @@ class HeadingMixin:
167
167
  --------
168
168
  >>> import streamlit as st
169
169
  >>>
170
- >>> st.subheader('This is a subheader with a divider', divider='rainbow')
171
- >>> st.subheader('_Streamlit_ is :blue[cool] :sunglasses:')
170
+ >>> st.subheader("This is a subheader with a divider", divider="rainbow")
171
+ >>> st.subheader("_Streamlit_ is :blue[cool] :sunglasses:")
172
172
 
173
173
  .. output::
174
174
  https://doc-subheader.streamlit.app/
@@ -234,8 +234,8 @@ class HeadingMixin:
234
234
  --------
235
235
  >>> import streamlit as st
236
236
  >>>
237
- >>> st.title('This is a title')
238
- >>> st.title('_Streamlit_ is :blue[cool] :sunglasses:')
237
+ >>> st.title("This is a title")
238
+ >>> st.title("_Streamlit_ is :blue[cool] :sunglasses:")
239
239
 
240
240
  .. output::
241
241
  https://doc-title.streamlit.app/
@@ -57,7 +57,9 @@ class HtmlMixin:
57
57
  -------
58
58
  >>> import streamlit as st
59
59
  >>>
60
- >>> st.html("<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>")
60
+ >>> st.html(
61
+ ... "<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>"
62
+ ... )
61
63
 
62
64
  .. output::
63
65
  https://doc-html.streamlit.app/
@@ -140,7 +140,7 @@ class ImageMixin:
140
140
  Example
141
141
  -------
142
142
  >>> import streamlit as st
143
- >>> st.image('sunrise.jpg', caption='Sunrise by the mountains')
143
+ >>> st.image("sunrise.jpg", caption="Sunrise by the mountains")
144
144
 
145
145
  .. output::
146
146
  https://doc-image.streamlit.app/
@@ -58,16 +58,18 @@ class JsonMixin:
58
58
  -------
59
59
  >>> import streamlit as st
60
60
  >>>
61
- >>> st.json({
62
- ... 'foo': 'bar',
63
- ... 'baz': 'boz',
64
- ... 'stuff': [
65
- ... 'stuff 1',
66
- ... 'stuff 2',
67
- ... 'stuff 3',
68
- ... 'stuff 5',
69
- ... ],
70
- ... })
61
+ >>> st.json(
62
+ ... {
63
+ ... "foo": "bar",
64
+ ... "baz": "boz",
65
+ ... "stuff": [
66
+ ... "stuff 1",
67
+ ... "stuff 2",
68
+ ... "stuff 3",
69
+ ... "stuff 5",
70
+ ... ],
71
+ ... }
72
+ ... )
71
73
 
72
74
  .. output::
73
75
  https://doc-json.streamlit.app/
@@ -73,11 +73,11 @@ class LayoutsMixin:
73
73
  >>> import streamlit as st
74
74
  >>>
75
75
  >>> with st.container():
76
- ... st.write("This is inside the container")
77
- ...
78
- ... # You can call any Streamlit command, including custom components:
79
- ... st.bar_chart(np.random.randn(50, 3))
76
+ ... st.write("This is inside the container")
80
77
  ...
78
+ ... # You can call any Streamlit command, including custom components:
79
+ ... st.bar_chart(np.random.randn(50, 3))
80
+ >>>
81
81
  >>> st.write("This is outside the container")
82
82
 
83
83
  .. output ::
@@ -201,16 +201,16 @@ class LayoutsMixin:
201
201
  >>> col1, col2, col3 = st.columns(3)
202
202
  >>>
203
203
  >>> with col1:
204
- ... st.header("A cat")
205
- ... st.image("https://static.streamlit.io/examples/cat.jpg")
206
- ...
204
+ ... st.header("A cat")
205
+ ... st.image("https://static.streamlit.io/examples/cat.jpg")
206
+ >>>
207
207
  >>> with col2:
208
- ... st.header("A dog")
209
- ... st.image("https://static.streamlit.io/examples/dog.jpg")
210
- ...
208
+ ... st.header("A dog")
209
+ ... st.image("https://static.streamlit.io/examples/dog.jpg")
210
+ >>>
211
211
  >>> with col3:
212
- ... st.header("An owl")
213
- ... st.image("https://static.streamlit.io/examples/owl.jpg")
212
+ ... st.header("An owl")
213
+ ... st.image("https://static.streamlit.io/examples/owl.jpg")
214
214
 
215
215
  .. output ::
216
216
  https://doc-columns1.streamlit.app/
@@ -386,16 +386,14 @@ class LayoutsMixin:
386
386
  >>> tab1, tab2, tab3 = st.tabs(["Cat", "Dog", "Owl"])
387
387
  >>>
388
388
  >>> with tab1:
389
- ... st.header("A cat")
390
- ... st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
391
- ...
389
+ ... st.header("A cat")
390
+ ... st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
392
391
  >>> with tab2:
393
- ... st.header("A dog")
394
- ... st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
395
- ...
392
+ ... st.header("A dog")
393
+ ... st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
396
394
  >>> with tab3:
397
- ... st.header("An owl")
398
- ... st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
395
+ ... st.header("An owl")
396
+ ... st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
399
397
 
400
398
  .. output ::
401
399
  https://doc-tabs1.streamlit.app/
@@ -799,7 +797,9 @@ class LayoutsMixin:
799
797
  ... time.sleep(1)
800
798
  ... st.write("Downloading data...")
801
799
  ... time.sleep(1)
802
- ... status.update(label="Download complete!", state="complete", expanded=False)
800
+ ... status.update(
801
+ ... label="Download complete!", state="complete", expanded=False
802
+ ... )
803
803
  >>>
804
804
  >>> st.button("Rerun")
805
805
 
@@ -117,6 +117,17 @@ _MELTED_COLOR_COLUMN_NAME: Final = _MELTED_COLOR_COLUMN_TITLE + _PROTECTION_SUFF
117
117
  _NON_EXISTENT_COLUMN_NAME: Final = "DOES_NOT_EXIST" + _PROTECTION_SUFFIX
118
118
 
119
119
 
120
+ def maybe_raise_stack_warning(
121
+ stack: bool | ChartStackType | None, command: str | None, docs_link: str
122
+ ):
123
+ # Check that the stack parameter is valid, raise more informative error message if not
124
+ if stack not in (None, True, False, "normalize", "center", "layered"):
125
+ raise StreamlitAPIException(
126
+ f'Invalid value for stack parameter: {stack}. Stack must be one of True, False, "normalize", "center", "layered" or None. '
127
+ f"See documentation for `{command}` [here]({docs_link}) for more information."
128
+ )
129
+
130
+
120
131
  def generate_chart(
121
132
  chart_type: ChartType,
122
133
  data: Data | None,
@@ -128,7 +139,7 @@ def generate_chart(
128
139
  size_from_user: str | float | None = None,
129
140
  width: int | None = None,
130
141
  height: int | None = None,
131
- # Bar charts only:
142
+ # Bar & Area charts only:
132
143
  stack: bool | ChartStackType | None = None,
133
144
  ) -> tuple[alt.Chart, AddRowsMetadata]:
134
145
  """Function to use the chart's type, data columns and indices to figure out the chart's spec."""
@@ -457,11 +468,13 @@ def _melt_data(
457
468
  --------
458
469
 
459
470
  >>> import pandas as pd
460
- >>> df = pd.DataFrame({
461
- ... "a": [1, 2, 3],
462
- ... "b": [4, 5, 6],
463
- ... "c": [7, 8, 9],
464
- ... })
471
+ >>> df = pd.DataFrame(
472
+ ... {
473
+ ... "a": [1, 2, 3],
474
+ ... "b": [4, 5, 6],
475
+ ... "c": [7, 8, 9],
476
+ ... }
477
+ ... )
465
478
  >>> _melt_data(df, ["a"], ["b", "c"], "value", "color")
466
479
  >>> a color value
467
480
  >>> 0 1 b 4
@@ -673,6 +686,7 @@ def _get_opacity_encoding(
673
686
  ) -> alt.OpacityValue | None:
674
687
  import altair as alt
675
688
 
689
+ # Opacity set to 0.7 for all area charts
676
690
  if color_column and chart_type == ChartType.AREA:
677
691
  return alt.OpacityValue(0.7)
678
692
 
@@ -759,7 +773,7 @@ def _get_axis_encodings(
759
773
  )
760
774
  stack_encoding = y_encoding
761
775
 
762
- # Handle stacking - only relevant for bar charts
776
+ # Handle stacking - only relevant for bar & area charts
763
777
  _update_encoding_with_stack(stack, stack_encoding)
764
778
 
765
779
  return x_encoding, y_encoding
@@ -141,7 +141,7 @@ class MarkdownMixin:
141
141
  >>>
142
142
  >>> code = '''def hello():
143
143
  ... print("Hello, Streamlit!")'''
144
- >>> st.code(code, language='python')
144
+ >>> st.code(code, language="python")
145
145
 
146
146
  """
147
147
  code_proto = MarkdownProto()
@@ -206,8 +206,8 @@ class MarkdownMixin:
206
206
  --------
207
207
  >>> import streamlit as st
208
208
  >>>
209
- >>> st.caption('This is a string that explains something above.')
210
- >>> st.caption('A caption with _italics_ :blue[colors] and emojis :sunglasses:')
209
+ >>> st.caption("This is a string that explains something above.")
210
+ >>> st.caption("A caption with _italics_ :blue[colors] and emojis :sunglasses:")
211
211
 
212
212
  """
213
213
  caption_proto = MarkdownProto()