streamlit-nightly 1.38.1.dev20240908__py2.py3-none-any.whl → 1.38.1.dev20240910__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 (94) hide show
  1. streamlit/__init__.py +1 -1
  2. streamlit/cli_util.py +59 -0
  3. streamlit/commands/experimental_query_params.py +33 -10
  4. streamlit/commands/page_config.py +6 -3
  5. streamlit/components/v1/custom_component.py +3 -5
  6. streamlit/config_option.py +3 -3
  7. streamlit/delta_generator.py +1 -1
  8. streamlit/elements/arrow.py +1 -1
  9. streamlit/elements/deck_gl_json_chart.py +1 -7
  10. streamlit/elements/form.py +1 -1
  11. streamlit/elements/lib/built_in_chart_utils.py +1 -2
  12. streamlit/{color_util.py → elements/lib/color_util.py} +8 -20
  13. streamlit/elements/lib/options_selector_utils.py +191 -4
  14. streamlit/elements/lib/policies.py +1 -1
  15. streamlit/elements/lib/utils.py +11 -168
  16. streamlit/elements/map.py +7 -7
  17. streamlit/elements/plotly_chart.py +1 -1
  18. streamlit/elements/vega_charts.py +2 -2
  19. streamlit/elements/widgets/button.py +7 -5
  20. streamlit/elements/widgets/button_group.py +8 -8
  21. streamlit/elements/widgets/camera_input.py +1 -1
  22. streamlit/elements/widgets/chat.py +7 -5
  23. streamlit/elements/widgets/checkbox.py +1 -1
  24. streamlit/elements/widgets/color_picker.py +1 -1
  25. streamlit/elements/widgets/data_editor.py +1 -1
  26. streamlit/elements/widgets/file_uploader.py +1 -1
  27. streamlit/elements/widgets/multiselect.py +3 -5
  28. streamlit/elements/widgets/number_input.py +2 -2
  29. streamlit/elements/widgets/radio.py +3 -6
  30. streamlit/elements/widgets/select_slider.py +7 -5
  31. streamlit/elements/widgets/selectbox.py +3 -6
  32. streamlit/elements/widgets/slider.py +2 -2
  33. streamlit/elements/widgets/text_widgets.py +1 -1
  34. streamlit/elements/widgets/time_widgets.py +1 -1
  35. streamlit/errors.py +22 -0
  36. streamlit/file_util.py +4 -4
  37. streamlit/net_util.py +4 -2
  38. streamlit/proto/DeckGlJsonChart_pb2.pyi +1 -1
  39. streamlit/runtime/app_session.py +1 -1
  40. streamlit/runtime/caching/storage/local_disk_cache_storage.py +2 -2
  41. streamlit/runtime/state/__init__.py +1 -5
  42. streamlit/runtime/state/common.py +1 -14
  43. streamlit/runtime/state/query_params.py +9 -2
  44. streamlit/runtime/state/widgets.py +0 -9
  45. streamlit/static/asset-manifest.json +20 -20
  46. streamlit/static/index.html +1 -1
  47. streamlit/static/static/js/1260.4017a70f.chunk.js +5 -0
  48. streamlit/static/static/js/{245.532167ed.chunk.js → 245.68a062da.chunk.js} +1 -1
  49. streamlit/static/static/js/{3156.0542d233.chunk.js → 3156.002c6ee0.chunk.js} +1 -1
  50. streamlit/static/static/js/3560.ce031236.chunk.js +1 -0
  51. streamlit/static/static/js/{4103.2a961369.chunk.js → 4103.d863052a.chunk.js} +1 -1
  52. streamlit/static/static/js/{5180.5e064ef1.chunk.js → 5180.e826dd46.chunk.js} +1 -1
  53. streamlit/static/static/js/5618.08be9e66.chunk.js +5 -0
  54. streamlit/static/static/js/{5625.0394ecdc.chunk.js → 5625.3a8dc81f.chunk.js} +1 -1
  55. streamlit/static/static/js/{5711.28939a95.chunk.js → 5711.2f36e813.chunk.js} +1 -1
  56. streamlit/static/static/js/6088.c137d543.chunk.js +1 -0
  57. streamlit/static/static/js/{6360.17e58a87.chunk.js → 6360.6d7cfa35.chunk.js} +1 -1
  58. streamlit/static/static/js/{7193.bc9bdd04.chunk.js → 7193.2594a18c.chunk.js} +1 -1
  59. streamlit/static/static/js/7493.95e79b96.chunk.js +1 -0
  60. streamlit/static/static/js/8166.11abccb8.chunk.js +1 -0
  61. streamlit/static/static/js/{8237.ed5d881b.chunk.js → 8237.210a5ac4.chunk.js} +1 -1
  62. streamlit/static/static/js/8815.0284d089.chunk.js +1 -0
  63. streamlit/static/static/js/9114.1ee3d4dd.chunk.js +1 -0
  64. streamlit/static/static/js/954.3cc76210.chunk.js +5 -0
  65. streamlit/static/static/js/{main.abc0ee04.js → main.7b7fe9ac.js} +2 -2
  66. streamlit/string_util.py +13 -5
  67. streamlit/time_util.py +3 -14
  68. streamlit/util.py +1 -127
  69. streamlit/watcher/local_sources_watcher.py +1 -1
  70. streamlit/web/bootstrap.py +2 -2
  71. streamlit/web/cli.py +2 -2
  72. {streamlit_nightly-1.38.1.dev20240908.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/METADATA +1 -1
  73. {streamlit_nightly-1.38.1.dev20240908.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/RECORD +82 -85
  74. streamlit/case_converters.py +0 -91
  75. streamlit/code_util.py +0 -90
  76. streamlit/constants.py +0 -19
  77. streamlit/static/static/js/1260.5ebd5704.chunk.js +0 -5
  78. streamlit/static/static/js/3560.17463b1c.chunk.js +0 -1
  79. streamlit/static/static/js/5618.6d42e995.chunk.js +0 -5
  80. streamlit/static/static/js/6088.00849717.chunk.js +0 -1
  81. streamlit/static/static/js/6364.7ec8417d.chunk.js +0 -1
  82. streamlit/static/static/js/8166.0d1971ea.chunk.js +0 -1
  83. streamlit/static/static/js/8815.0b7dc879.chunk.js +0 -1
  84. streamlit/static/static/js/9114.c676bef4.chunk.js +0 -1
  85. streamlit/static/static/js/954.bf90fe19.chunk.js +0 -5
  86. /streamlit/{echo.py → commands/echo.py} +0 -0
  87. /streamlit/elements/{form_utils.py → lib/form_utils.py} +0 -0
  88. /streamlit/{js_number.py → elements/lib/js_number.py} +0 -0
  89. /streamlit/static/static/js/{main.abc0ee04.js.LICENSE.txt → main.7b7fe9ac.js.LICENSE.txt} +0 -0
  90. /streamlit/{folder_black_list.py → watcher/folder_black_list.py} +0 -0
  91. {streamlit_nightly-1.38.1.dev20240908.data → streamlit_nightly-1.38.1.dev20240910.data}/scripts/streamlit.cmd +0 -0
  92. {streamlit_nightly-1.38.1.dev20240908.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/WHEEL +0 -0
  93. {streamlit_nightly-1.38.1.dev20240908.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/entry_points.txt +0 -0
  94. {streamlit_nightly-1.38.1.dev20240908.dist-info → streamlit_nightly-1.38.1.dev20240910.dist-info}/top_level.txt +0 -0
streamlit/string_util.py CHANGED
@@ -26,11 +26,6 @@ if TYPE_CHECKING:
26
26
  _ALPHANUMERIC_CHAR_REGEX: Final = re.compile(r"^[a-zA-Z0-9_&\-\. ]+$")
27
27
 
28
28
 
29
- def decode_ascii(string: bytes) -> str:
30
- """Decodes a string as ascii."""
31
- return string.decode("ascii")
32
-
33
-
34
29
  def clean_text(text: SupportsStr) -> str:
35
30
  """Convert an object to text, dedent it, and strip whitespace."""
36
31
  return textwrap.dedent(str(text)).strip()
@@ -204,3 +199,16 @@ def probably_contains_html_tags(s: str) -> bool:
204
199
  Note that false positives/negatives are possible, so this function should not be
205
200
  used in contexts where complete correctness is required."""
206
201
  return bool(_RE_CONTAINS_HTML.search(s))
202
+
203
+
204
+ def to_snake_case(camel_case_str: str) -> str:
205
+ """Converts UpperCamelCase and lowerCamelCase to snake_case.
206
+
207
+ Examples
208
+ --------
209
+ fooBar -> foo_bar
210
+ BazBang -> baz_bang
211
+
212
+ """
213
+ s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", camel_case_str)
214
+ return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
streamlit/time_util.py CHANGED
@@ -18,7 +18,7 @@ import math
18
18
  from datetime import date, timedelta
19
19
  from typing import Literal, overload
20
20
 
21
- from streamlit.errors import MarkdownFormattedException, StreamlitAPIException
21
+ from streamlit.errors import StreamlitAPIException, StreamlitBadTimeStringError
22
22
 
23
23
 
24
24
  def adjust_years(input_date: date, years: int) -> date:
@@ -38,17 +38,6 @@ def adjust_years(input_date: date, years: int) -> date:
38
38
  ) from err
39
39
 
40
40
 
41
- class BadTimeStringError(StreamlitAPIException):
42
- """Raised when a bad time string argument is passed."""
43
-
44
- def __init__(self, t: str):
45
- MarkdownFormattedException.__init__(
46
- self,
47
- "Time string doesn't look right. It should be formatted as"
48
- f"`'1d2h34m'` or `2 days`, for example. Got: {t}",
49
- )
50
-
51
-
52
41
  @overload
53
42
  def time_to_seconds(
54
43
  t: float | timedelta | str | None, *, coerce_none_to_inf: Literal[False]
@@ -77,10 +66,10 @@ def time_to_seconds(
77
66
  seconds: float = pd.Timedelta(t).total_seconds()
78
67
 
79
68
  if np.isnan(seconds):
80
- raise BadTimeStringError(t)
69
+ raise StreamlitBadTimeStringError(t)
81
70
 
82
71
  return seconds
83
72
  except ValueError as ex:
84
- raise BadTimeStringError(t) from ex
73
+ raise StreamlitBadTimeStringError(t) from ex
85
74
 
86
75
  return t
streamlit/util.py CHANGED
@@ -19,16 +19,8 @@ from __future__ import annotations
19
19
  import dataclasses
20
20
  import functools
21
21
  import hashlib
22
- import os
23
- import subprocess
24
22
  import sys
25
- from typing import Any, Callable, Final, Iterable, Mapping, TypeVar
26
-
27
- from streamlit import env_util
28
-
29
- # URL of Streamlit's help page.
30
- HELP_DOC: Final = "https://docs.streamlit.io/"
31
- FLOAT_EQUALITY_EPSILON: Final[float] = 0.000000000005
23
+ from typing import Any, Callable
32
24
 
33
25
  # Due to security issue in md5 and sha1, usedforsecurity
34
26
  # argument is added to hashlib for python versions higher than 3.8
@@ -50,60 +42,6 @@ def memoize(func: Callable[..., Any]) -> Callable[..., Any]:
50
42
  return wrapped_func
51
43
 
52
44
 
53
- def open_browser(url: str) -> None:
54
- """Open a web browser pointing to a given URL.
55
-
56
- We use this function instead of Python's `webbrowser` module because this
57
- way we can capture stdout/stderr to avoid polluting the terminal with the
58
- browser's messages. For example, Chrome always prints things like "Created
59
- new window in existing browser session", and those get on the user's way.
60
-
61
- url : str
62
- The URL. Must include the protocol.
63
-
64
- """
65
- # Treat Windows separately because:
66
- # 1. /dev/null doesn't exist.
67
- # 2. subprocess.Popen(['start', url]) doesn't actually pop up the
68
- # browser even though 'start url' works from the command prompt.
69
- # Fun!
70
- # Also, use webbrowser if we are on Linux and xdg-open is not installed.
71
- #
72
- # We don't use the webbrowser module on Linux and Mac because some browsers
73
- # (ahem... Chrome) always print "Opening in existing browser session" to
74
- # the terminal, which is spammy and annoying. So instead we start the
75
- # browser ourselves and send all its output to /dev/null.
76
-
77
- if env_util.IS_WINDOWS:
78
- _open_browser_with_webbrowser(url)
79
- return
80
- if env_util.IS_LINUX_OR_BSD:
81
- if env_util.is_executable_in_path("xdg-open"):
82
- _open_browser_with_command("xdg-open", url)
83
- return
84
- _open_browser_with_webbrowser(url)
85
- return
86
- if env_util.IS_DARWIN:
87
- _open_browser_with_command("open", url)
88
- return
89
-
90
- import platform
91
-
92
- raise Error('Cannot open browser in platform "%s"' % platform.system())
93
-
94
-
95
- def _open_browser_with_webbrowser(url: str) -> None:
96
- import webbrowser
97
-
98
- webbrowser.open(url)
99
-
100
-
101
- def _open_browser_with_command(command: str, url: str) -> None:
102
- cmd_line = [command, url]
103
- with open(os.devnull, "w") as devnull:
104
- subprocess.Popen(cmd_line, stdout=devnull, stderr=subprocess.STDOUT)
105
-
106
-
107
45
  def repr_(self: Any) -> str:
108
46
  """A clean repr for a class, excluding both values that are likely defaults,
109
47
  and those explicitly default for dataclasses.
@@ -127,46 +65,6 @@ def repr_(self: Any) -> str:
127
65
  return f"{classname}({field_reprs})"
128
66
 
129
67
 
130
- _Value = TypeVar("_Value")
131
-
132
-
133
- def index_(iterable: Iterable[_Value], x: _Value) -> int:
134
- """Return zero-based index of the first item whose value is equal to x.
135
- Raises a ValueError if there is no such item.
136
-
137
- We need a custom implementation instead of the built-in list .index() to
138
- be compatible with NumPy array and Pandas Series.
139
-
140
- Parameters
141
- ----------
142
- iterable : list, tuple, numpy.ndarray, pandas.Series
143
- x : Any
144
-
145
- Returns
146
- -------
147
- int
148
- """
149
- for i, value in enumerate(iterable):
150
- if x == value:
151
- return i
152
- elif isinstance(value, float) and isinstance(x, float):
153
- if abs(x - value) < FLOAT_EQUALITY_EPSILON:
154
- return i
155
- raise ValueError(f"{str(x)} is not in iterable")
156
-
157
-
158
- _Key = TypeVar("_Key", bound=str)
159
-
160
-
161
- def lower_clean_dict_keys(dict: Mapping[_Key, _Value]) -> dict[str, _Value]:
162
- return {k.lower().strip(): v for k, v in dict.items()}
163
-
164
-
165
- # TODO: Move this into errors.py? Replace with StreamlitAPIException?
166
- class Error(Exception):
167
- pass
168
-
169
-
170
68
  def calc_md5(s: bytes | str) -> str:
171
69
  """Return the md5 hash of the given string."""
172
70
  h = hashlib.new("md5", **HASHLIB_KWARGS)
@@ -175,27 +73,3 @@ def calc_md5(s: bytes | str) -> str:
175
73
 
176
74
  h.update(b)
177
75
  return h.hexdigest()
178
-
179
-
180
- def exclude_keys_in_dict(
181
- d: dict[str, Any], keys_to_exclude: list[str]
182
- ) -> dict[str, Any]:
183
- """Returns new object but without keys defined in keys_to_exclude"""
184
- return {
185
- key: value for key, value in d.items() if key.lower() not in keys_to_exclude
186
- }
187
-
188
-
189
- def extract_key_query_params(
190
- query_params: dict[str, list[str]], param_key: str
191
- ) -> set[str]:
192
- """Extracts key (case-insensitive) query params from Dict, and returns them as Set of str."""
193
- return {
194
- item.lower()
195
- for sublist in [
196
- [value.lower() for value in query_params[key]]
197
- for key in query_params.keys()
198
- if key.lower() == param_key and query_params.get(key)
199
- ]
200
- for item in sublist
201
- }
@@ -20,8 +20,8 @@ from pathlib import Path
20
20
  from typing import TYPE_CHECKING, Any, Callable, Final, NamedTuple
21
21
 
22
22
  from streamlit import config, file_util
23
- from streamlit.folder_black_list import FolderBlackList
24
23
  from streamlit.logger import get_logger
24
+ from streamlit.watcher.folder_black_list import FolderBlackList
25
25
  from streamlit.watcher.path_watcher import (
26
26
  NoOpPathWatcher,
27
27
  get_default_path_watcher_class,
@@ -20,7 +20,7 @@ import signal
20
20
  import sys
21
21
  from typing import Any, Final
22
22
 
23
- from streamlit import cli_util, config, env_util, file_util, net_util, secrets, util
23
+ from streamlit import cli_util, config, env_util, file_util, net_util, secrets
24
24
  from streamlit.config import CONFIG_FILENAMES
25
25
  from streamlit.git_util import MIN_GIT_VERSION, GitRepo
26
26
  from streamlit.logger import get_logger
@@ -130,7 +130,7 @@ def _on_server_start(server: Server) -> None:
130
130
  else:
131
131
  addr = "localhost"
132
132
 
133
- util.open_browser(server_util.get_url(addr))
133
+ cli_util.open_browser(server_util.get_url(addr))
134
134
 
135
135
  # Schedule the browser to open on the main thread.
136
136
  asyncio.get_running_loop().call_soon(maybe_open_browser)
streamlit/web/cli.py CHANGED
@@ -176,9 +176,9 @@ def main_version():
176
176
  def main_docs():
177
177
  """Show help in browser."""
178
178
  click.echo("Showing help page in browser...")
179
- from streamlit import util
179
+ from streamlit import cli_util
180
180
 
181
- util.open_browser("https://docs.streamlit.io")
181
+ cli_util.open_browser("https://docs.streamlit.io")
182
182
 
183
183
 
184
184
  @main.command("hello")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: streamlit-nightly
3
- Version: 1.38.1.dev20240908
3
+ Version: 1.38.1.dev20240910
4
4
  Summary: A faster way to build and share data apps
5
5
  Home-page: https://streamlit.io
6
6
  Author: Snowflake Inc