streamlit-nightly 1.45.1.dev20250511__py3-none-any.whl → 1.45.2.dev20250513__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 (165) hide show
  1. streamlit/__init__.py +1 -0
  2. streamlit/auth_util.py +6 -6
  3. streamlit/commands/echo.py +5 -3
  4. streamlit/commands/experimental_query_params.py +1 -1
  5. streamlit/commands/navigation.py +1 -4
  6. streamlit/components/v1/custom_component.py +2 -2
  7. streamlit/config.py +16 -18
  8. streamlit/config_util.py +6 -7
  9. streamlit/connections/sql_connection.py +1 -1
  10. streamlit/dataframe_util.py +50 -51
  11. streamlit/delta_generator.py +4 -1
  12. streamlit/deprecation_util.py +5 -5
  13. streamlit/elements/arrow.py +1 -1
  14. streamlit/elements/deck_gl_json_chart.py +1 -4
  15. streamlit/elements/doc_string.py +5 -10
  16. streamlit/elements/exception.py +5 -7
  17. streamlit/elements/layouts.py +4 -3
  18. streamlit/elements/lib/built_in_chart_utils.py +22 -22
  19. streamlit/elements/lib/pandas_styler_utils.py +6 -8
  20. streamlit/elements/lib/policies.py +1 -1
  21. streamlit/elements/map.py +2 -8
  22. streamlit/elements/markdown.py +1 -4
  23. streamlit/elements/media.py +50 -2
  24. streamlit/elements/metric.py +9 -10
  25. streamlit/elements/spinner.py +1 -1
  26. streamlit/elements/vega_charts.py +1 -1
  27. streamlit/elements/widgets/audio_input.py +1 -4
  28. streamlit/elements/widgets/camera_input.py +1 -4
  29. streamlit/elements/widgets/chat.py +52 -5
  30. streamlit/elements/widgets/data_editor.py +1 -1
  31. streamlit/elements/widgets/slider.py +4 -5
  32. streamlit/elements/widgets/time_widgets.py +1 -4
  33. streamlit/elements/write.py +2 -2
  34. streamlit/env_util.py +2 -7
  35. streamlit/error_util.py +15 -8
  36. streamlit/errors.py +11 -8
  37. streamlit/file_util.py +6 -3
  38. streamlit/git_util.py +26 -21
  39. streamlit/hello/dataframe_demo.py +1 -1
  40. streamlit/hello/mapping_demo.py +1 -1
  41. streamlit/hello/plotting_demo.py +3 -3
  42. streamlit/hello/streamlit_app.py +1 -1
  43. streamlit/hello/utils.py +2 -1
  44. streamlit/logger.py +4 -5
  45. streamlit/proto/Audio_pb2.py +4 -3
  46. streamlit/proto/Audio_pb2.pyi +8 -1
  47. streamlit/proto/Block_pb2.py +5 -5
  48. streamlit/proto/Block_pb2.pyi +7 -1
  49. streamlit/proto/ChatInput_pb2.py +8 -7
  50. streamlit/proto/ChatInput_pb2.pyi +10 -1
  51. streamlit/proto/Video_pb2.py +8 -7
  52. streamlit/proto/Video_pb2.pyi +8 -1
  53. streamlit/runtime/app_session.py +5 -5
  54. streamlit/runtime/caching/cache_data_api.py +2 -2
  55. streamlit/runtime/caching/cache_resource_api.py +1 -1
  56. streamlit/runtime/caching/cache_utils.py +3 -3
  57. streamlit/runtime/caching/hashing.py +10 -10
  58. streamlit/runtime/credentials.py +9 -8
  59. streamlit/runtime/forward_msg_queue.py +1 -1
  60. streamlit/runtime/memory_media_file_storage.py +5 -4
  61. streamlit/runtime/memory_uploaded_file_manager.py +1 -1
  62. streamlit/runtime/metrics_util.py +2 -2
  63. streamlit/runtime/runtime.py +1 -1
  64. streamlit/runtime/scriptrunner/exec_code.py +1 -1
  65. streamlit/runtime/scriptrunner/script_cache.py +1 -1
  66. streamlit/runtime/scriptrunner/script_runner.py +10 -3
  67. streamlit/runtime/scriptrunner_utils/script_requests.py +3 -3
  68. streamlit/runtime/scriptrunner_utils/script_run_context.py +3 -3
  69. streamlit/runtime/secrets.py +6 -7
  70. streamlit/runtime/state/query_params.py +3 -5
  71. streamlit/runtime/state/session_state.py +15 -15
  72. streamlit/runtime/stats.py +1 -1
  73. streamlit/static/index.html +1 -1
  74. streamlit/static/static/js/{ErrorOutline.esm.B5LmzpSn.js → ErrorOutline.esm.CxkgXqSh.js} +1 -1
  75. streamlit/static/static/js/{FileDownload.esm.BgWveG3s.js → FileDownload.esm.DVrjmwoh.js} +1 -1
  76. streamlit/static/static/js/{FileHelper.DepIpP48.js → FileHelper.CMA9s0t3.js} +1 -1
  77. streamlit/static/static/js/{FormClearHelper.C_BjP_35.js → FormClearHelper.Ca3GFjxv.js} +1 -1
  78. streamlit/static/static/js/{Hooks.BpH4YuRQ.js → Hooks.BpCPXt5n.js} +1 -1
  79. streamlit/static/static/js/{InputInstructions.CjdwGigq.js → InputInstructions.BO_BnHv5.js} +1 -1
  80. streamlit/static/static/js/{ProgressBar.D1hXcW3N.js → ProgressBar.Ctk1m4EX.js} +1 -1
  81. streamlit/static/static/js/{RenderInPortalIfExists.A1T2s6z-.js → RenderInPortalIfExists.kuKoxpXt.js} +1 -1
  82. streamlit/static/static/js/{Toolbar.y7vr7z0G.js → Toolbar.Cde1fEcQ.js} +1 -1
  83. streamlit/static/static/js/{base-input.BKhd-BLG.js → base-input.BwCmIYba.js} +1 -1
  84. streamlit/static/static/js/{checkbox.DC-GFdrh.js → checkbox.CwPOyuag.js} +1 -1
  85. streamlit/static/static/js/{createSuper.D5WUtJEy.js → createSuper.BMtevhyt.js} +1 -1
  86. streamlit/static/static/js/{data-grid-overlay-editor.BPJ38mWp.js → data-grid-overlay-editor.gtfE9z1L.js} +1 -1
  87. streamlit/static/static/js/{downloader.C6a4LRBw.js → downloader.-58ZXBvx.js} +1 -1
  88. streamlit/static/static/js/{es6.DgMlYq8q.js → es6.6JpsZqpF.js} +2 -2
  89. streamlit/static/static/js/{iframeResizer.contentWindow.BpQxex73.js → iframeResizer.contentWindow.Dvm_jxul.js} +1 -1
  90. streamlit/static/static/js/{index.CiO2JPl_.js → index.9Bu4pGgs.js} +1 -1
  91. streamlit/static/static/js/{index.4Gtr9egA.js → index.B1T1N6vQ.js} +1 -1
  92. streamlit/static/static/js/{index.20fI9wQF.js → index.B9LBeTzL.js} +1 -1
  93. streamlit/static/static/js/{index.VPO2zcSN.js → index.BXdNB_A0.js} +1 -1
  94. streamlit/static/static/js/{index.sKXwUANU.js → index.Bd91GXu8.js} +1 -1
  95. streamlit/static/static/js/{index.DT0CWGt3.js → index.BdEKCy-o.js} +1 -1
  96. streamlit/static/static/js/{index.D3tgBU6x.js → index.BhODUTaJ.js} +1 -1
  97. streamlit/static/static/js/{index.BcbB70bz.js → index.BjtSRm-c.js} +1 -1
  98. streamlit/static/static/js/{index.DPiBGVm8.js → index.BnK8pWHN.js} +1 -1
  99. streamlit/static/static/js/{index.49Q6A5_9.js → index.C5xsotRs.js} +1 -1
  100. streamlit/static/static/js/{index.xIQLhQKv.js → index.CD3lJu6g.js} +1 -1
  101. streamlit/static/static/js/{index.BydIp_VR.js → index.CGJjlswG.js} +1 -1
  102. streamlit/static/static/js/{index.Bj81ZRkx.js → index.CIZd1q4K.js} +1 -1
  103. streamlit/static/static/js/{index.5k30-U6O.js → index.CZy9JHE4.js} +2 -2
  104. streamlit/static/static/js/{index.D5PANKHd.js → index.Ce-7kIl6.js} +1 -1
  105. streamlit/static/static/js/{index.Bo-z1JM2.js → index.CiiU1-bS.js} +1 -1
  106. streamlit/static/static/js/{index.Cqla7uBZ.js → index.ClE8XHxl.js} +1 -1
  107. streamlit/static/static/js/{index.CY8tg9lY.js → index.CvKH37SN.js} +1 -1
  108. streamlit/static/static/js/{index.CkBnHCIQ.js → index.D0G-y_z6.js} +1 -1
  109. streamlit/static/static/js/{index.B3UoUwtN.js → index.D1ccH_2Z.js} +1 -1
  110. streamlit/static/static/js/{index.DB42JCH0.js → index.D3ES4sSL.js} +1 -1
  111. streamlit/static/static/js/{index.BLpDfH1w.js → index.DJ0X7aeY.js} +1 -1
  112. streamlit/static/static/js/{index.BRN41-Jy.js → index.DNNQBTM6.js} +1 -1
  113. streamlit/static/static/js/{index.br6zwNIk.js → index.DQJE0i9s.js} +62 -62
  114. streamlit/static/static/js/{index.DSPS70gp.js → index.DR9ekgzX.js} +1 -1
  115. streamlit/static/static/js/{index.BbhQIRth.js → index.DUizq_aW.js} +1 -1
  116. streamlit/static/static/js/{index.ryD8hMpi.js → index.DVE5BhiT.js} +1 -1
  117. streamlit/static/static/js/{index.C2GjbQtf.js → index.DW60zbv4.js} +1 -1
  118. streamlit/static/static/js/{index.BhGEwO_d.js → index.DenamHJl.js} +1 -1
  119. streamlit/static/static/js/{index._oOkpIXS.js → index.DgnhzFgr.js} +1 -1
  120. streamlit/static/static/js/{index.CHnID3dI.js → index.Dk_aZplH.js} +1 -1
  121. streamlit/static/static/js/index.Dqcp7EZB.js +779 -0
  122. streamlit/static/static/js/{index.DAO4Lj-D.js → index.NfOJ2GJ6.js} +1 -1
  123. streamlit/static/static/js/{index.CcvbHTJu.js → index.WVgPkrrw.js} +1 -1
  124. streamlit/static/static/js/{index.Du1Pbz0y.js → index.bkU6rhIM.js} +1 -1
  125. streamlit/static/static/js/{index.Cfi3u2-T.js → index.hQ5adhxG.js} +1 -1
  126. streamlit/static/static/js/{index.B8ca7fYO.js → index.lYSTjxV_.js} +1 -1
  127. streamlit/static/static/js/{input.CNjMviuo.js → input.JEUWF6Z-.js} +1 -1
  128. streamlit/static/static/js/{memory.f8X97LPt.js → memory.BToPJrCN.js} +1 -1
  129. streamlit/static/static/js/{mergeWith.DU9BO8BA.js → mergeWith.DGon2YId.js} +1 -1
  130. streamlit/static/static/js/{number-overlay-editor.xJPBNdGQ.js → number-overlay-editor.kqkFTYSn.js} +1 -1
  131. streamlit/static/static/js/{possibleConstructorReturn.BjPX9m9m.js → possibleConstructorReturn.twGQoCQl.js} +1 -1
  132. streamlit/static/static/js/{sandbox.B23JuuVd.js → sandbox.o85HOKwq.js} +1 -1
  133. streamlit/static/static/js/{textarea.DodnI6GX.js → textarea.CdOYpTta.js} +1 -1
  134. streamlit/static/static/js/{timepicker.ClHKNfP9.js → timepicker.Cy1BKBo3.js} +1 -1
  135. streamlit/static/static/js/{toConsumableArray.CK6YGgcW.js → toConsumableArray.BVXfsvDc.js} +1 -1
  136. streamlit/static/static/js/{uniqueId.BAAVLIKj.js → uniqueId.Dz7-nY8K.js} +1 -1
  137. streamlit/static/static/js/{useBasicWidgetState.B1oropKY.js → useBasicWidgetState.CeKdNkz-.js} +1 -1
  138. streamlit/static/static/js/{useOnInputChange.CHQJz2sf.js → useOnInputChange.CM8BtP-c.js} +1 -1
  139. streamlit/static/static/js/{withFullScreenWrapper.DZ1W8JUx.js → withFullScreenWrapper.DuyW554J.js} +1 -1
  140. streamlit/string_util.py +1 -4
  141. streamlit/temporary_directory.py +2 -2
  142. streamlit/testing/v1/app_test.py +2 -2
  143. streamlit/testing/v1/element_tree.py +10 -9
  144. streamlit/testing/v1/local_script_runner.py +1 -4
  145. streamlit/type_util.py +2 -5
  146. streamlit/watcher/folder_black_list.py +1 -1
  147. streamlit/watcher/local_sources_watcher.py +5 -3
  148. streamlit/watcher/path_watcher.py +3 -6
  149. streamlit/watcher/polling_path_watcher.py +8 -7
  150. streamlit/watcher/util.py +6 -5
  151. streamlit/web/bootstrap.py +4 -4
  152. streamlit/web/cli.py +13 -13
  153. streamlit/web/server/app_static_file_handler.py +1 -1
  154. streamlit/web/server/authlib_tornado_integration.py +6 -1
  155. streamlit/web/server/oauth_authlib_routes.py +3 -3
  156. streamlit/web/server/oidc_mixin.py +15 -3
  157. streamlit/web/server/routes.py +11 -11
  158. streamlit/web/server/stats_request_handler.py +2 -2
  159. {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/METADATA +1 -1
  160. {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/RECORD +164 -164
  161. streamlit/static/static/js/index.BgEbLy94.js +0 -779
  162. {streamlit_nightly-1.45.1.dev20250511.data → streamlit_nightly-1.45.2.dev20250513.data}/scripts/streamlit.cmd +0 -0
  163. {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/WHEEL +0 -0
  164. {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/entry_points.txt +0 -0
  165. {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/top_level.txt +0 -0
@@ -151,7 +151,7 @@ class AppSession:
151
151
  self._client_state = ClientState()
152
152
 
153
153
  self._local_sources_watcher: LocalSourcesWatcher | None = None
154
- self._stop_config_listener: Callable[[], bool] | None = None
154
+ self._stop_config_listener: Callable[[], None] | None = None
155
155
  self._stop_pages_listener: Callable[[], None] | None = None
156
156
 
157
157
  if config.get_option("server.fileWatcherType") != "none":
@@ -792,12 +792,12 @@ class AppSession:
792
792
  msg.git_info_changed.branch = branch
793
793
  msg.git_info_changed.module = module
794
794
 
795
- msg.git_info_changed.untracked_files[:] = repo.untracked_files
796
- msg.git_info_changed.uncommitted_files[:] = repo.uncommitted_files
795
+ msg.git_info_changed.untracked_files[:] = repo.untracked_files or []
796
+ msg.git_info_changed.uncommitted_files[:] = repo.uncommitted_files or []
797
797
 
798
798
  if repo.is_head_detached:
799
799
  msg.git_info_changed.state = GitInfo.GitStates.HEAD_DETACHED
800
- elif len(repo.ahead_commits) > 0:
800
+ elif repo.ahead_commits and len(repo.ahead_commits) > 0:
801
801
  msg.git_info_changed.state = GitInfo.GitStates.AHEAD_OF_REMOTE
802
802
  else:
803
803
  msg.git_info_changed.state = GitInfo.GitStates.DEFAULT
@@ -905,7 +905,7 @@ def _get_toolbar_mode() -> Config.ToolbarMode.ValueType:
905
905
  Config.ToolbarMode, config_value.upper()
906
906
  )
907
907
  if enum_value is None:
908
- allowed_values = ", ".join(k.lower() for k in Config.ToolbarMode.keys())
908
+ allowed_values = ", ".join(k.lower() for k in Config.ToolbarMode.keys()) # noqa: SIM118
909
909
  raise ValueError(
910
910
  f"Config {config_key!r} expects to have one of "
911
911
  f"the following values: {allowed_values}. "
@@ -147,7 +147,7 @@ class CachedDataFuncInfo(CachedFuncInfo):
147
147
  class DataCaches(CacheStatsProvider):
148
148
  """Manages all DataCache instances."""
149
149
 
150
- def __init__(self):
150
+ def __init__(self) -> None:
151
151
  self._caches_lock = threading.Lock()
152
152
  self._function_caches: dict[str, DataCache] = {}
153
153
 
@@ -566,7 +566,7 @@ class CacheDataAPI:
566
566
  if experimental_allow_widgets:
567
567
  show_widget_replay_deprecation("cache_data")
568
568
 
569
- def wrapper(f):
569
+ def wrapper(f): # noqa: ANN001, ANN202
570
570
  return make_cached_func_wrapper(
571
571
  CachedDataFuncInfo(
572
572
  func=f,
@@ -69,7 +69,7 @@ def _equal_validate_funcs(a: ValidateFunc | None, b: ValidateFunc | None) -> boo
69
69
  class ResourceCaches(CacheStatsProvider):
70
70
  """Manages all ResourceCache instances."""
71
71
 
72
- def __init__(self):
72
+ def __init__(self) -> None:
73
73
  self._caches_lock = threading.Lock()
74
74
  self._function_caches: dict[str, ResourceCache] = {}
75
75
 
@@ -65,7 +65,7 @@ TTLCACHE_TIMER = time.monotonic
65
65
  class Cache:
66
66
  """Function cache interface. Caches persist across script runs."""
67
67
 
68
- def __init__(self):
68
+ def __init__(self) -> None:
69
69
  self._value_locks: dict[str, threading.Lock] = defaultdict(threading.Lock)
70
70
  self._value_locks_lock = threading.Lock()
71
71
 
@@ -196,7 +196,7 @@ class CachedFunc:
196
196
  def __repr__(self) -> str:
197
197
  return f"<CachedFunc: {self._info.func}>"
198
198
 
199
- def __get__(self, instance, owner=None):
199
+ def __get__(self, instance: Any, owner: Any | None = None) -> Any:
200
200
  """CachedFunc implements descriptor protocol to support cache methods."""
201
201
  if instance is None:
202
202
  return self
@@ -346,7 +346,7 @@ class CachedFunc:
346
346
  return_value=computed_value, func=self._info.func
347
347
  )
348
348
 
349
- def clear(self, *args, **kwargs):
349
+ def clear(self, *args: Any, **kwargs: Any) -> None:
350
350
  """Clear the cached function's associated cache.
351
351
 
352
352
  If no arguments are passed, Streamlit will clear all values cached for
@@ -136,10 +136,11 @@ If you think this is actually a Streamlit bug, please
136
136
  elif self.cache_type is CacheType.DATA:
137
137
  decorator_name = "@st.cache_data"
138
138
 
139
- if hasattr(self.hash_func, "__name__"):
140
- hash_func_name = f"`{self.hash_func.__name__}()`"
141
- else:
142
- hash_func_name = "a function"
139
+ hash_func_name = (
140
+ f"`{self.hash_func.__name__}()`"
141
+ if hasattr(self.hash_func, "__name__")
142
+ else "a function"
143
+ )
143
144
 
144
145
  return {
145
146
  "orig_exception_desc": str(orig_exc),
@@ -181,7 +182,7 @@ class _HashStack:
181
182
  This causes the "in" to crash since it expects a boolean.
182
183
  """
183
184
 
184
- def __init__(self):
185
+ def __init__(self) -> None:
185
186
  self._stack: collections.OrderedDict[int, list[Any]] = collections.OrderedDict()
186
187
  # A function that we decorate with streamlit cache
187
188
  # primitive (st.cache_data or st.cache_resource).
@@ -212,7 +213,7 @@ class _HashStack:
212
213
  class _HashStacks:
213
214
  """Stacks of what has been hashed, with at most 1 stack per thread."""
214
215
 
215
- def __init__(self):
216
+ def __init__(self) -> None:
216
217
  self._stacks: weakref.WeakKeyDictionary[threading.Thread, _HashStack] = (
217
218
  weakref.WeakKeyDictionary()
218
219
  )
@@ -313,9 +314,8 @@ class _CacheFuncHasher:
313
314
  key = (tname, _key(obj))
314
315
 
315
316
  # Memoize if possible.
316
- if key[1] is not NoResult:
317
- if key in self._hashes:
318
- return self._hashes[key]
317
+ if key[1] is not NoResult and key in self._hashes:
318
+ return self._hashes[key]
319
319
 
320
320
  # Break recursive cycles.
321
321
  if obj in hash_stacks.current:
@@ -362,7 +362,7 @@ class _CacheFuncHasher:
362
362
  # deep, so we don't try to hash them at all.
363
363
  return self.to_bytes(id(obj))
364
364
 
365
- if isinstance(obj, bytes) or isinstance(obj, bytearray):
365
+ if isinstance(obj, (bytes, bytearray)):
366
366
  return obj
367
367
 
368
368
  if type_util.get_fqn_type(obj) in self._hash_funcs:
@@ -29,10 +29,11 @@ from streamlit.logger import get_logger
29
29
  _LOGGER: Final = get_logger(__name__)
30
30
 
31
31
 
32
- if env_util.IS_WINDOWS:
33
- _CONFIG_FILE_PATH = r"%userprofile%/.streamlit/config.toml"
34
- else:
35
- _CONFIG_FILE_PATH = "~/.streamlit/config.toml"
32
+ _CONFIG_FILE_PATH = (
33
+ r"%userprofile%/.streamlit/config.toml"
34
+ if env_util.IS_WINDOWS
35
+ else "~/.streamlit/config.toml"
36
+ )
36
37
 
37
38
 
38
39
  class _Activation(NamedTuple):
@@ -65,7 +66,7 @@ Collecting usage statistics. To deactivate, set browser.gatherUsageStats to fals
65
66
  """
66
67
 
67
68
 
68
- def _send_email(email: str) -> None:
69
+ def _send_email(email: str | None) -> None:
69
70
  """Send the user's email for metrics, if submitted."""
70
71
  import requests
71
72
 
@@ -123,15 +124,15 @@ class Credentials:
123
124
 
124
125
  return cast("Credentials", Credentials._singleton)
125
126
 
126
- def __init__(self):
127
+ def __init__(self) -> None:
127
128
  """Initialize class."""
128
129
  if Credentials._singleton is not None:
129
130
  raise RuntimeError(
130
131
  "Credentials already initialized. Use .get_current() instead"
131
132
  )
132
133
 
133
- self.activation = None
134
- self._conf_file = _get_credential_file_path()
134
+ self.activation: _Activation | None = None
135
+ self._conf_file: str = _get_credential_file_path()
135
136
 
136
137
  Credentials._singleton = self
137
138
 
@@ -41,7 +41,7 @@ class ForwardMsgQueue:
41
41
  """
42
42
  ForwardMsgQueue._before_enqueue_msg = before_enqueue_msg
43
43
 
44
- def __init__(self):
44
+ def __init__(self) -> None:
45
45
  self._queue: list[ForwardMsg] = []
46
46
  # A mapping of (delta_path -> _queue.indexof(msg)) for each
47
47
  # Delta message in the queue. We use this for coalescing
@@ -110,10 +110,11 @@ class MemoryMediaFileStorage(MediaFileStorage, CacheStatsProvider):
110
110
  ) -> str:
111
111
  """Add a file to the manager and return its ID."""
112
112
  file_data: bytes
113
- if isinstance(path_or_data, str):
114
- file_data = self._read_file(path_or_data)
115
- else:
116
- file_data = path_or_data
113
+ file_data = (
114
+ self._read_file(path_or_data)
115
+ if isinstance(path_or_data, str)
116
+ else path_or_data
117
+ )
117
118
 
118
119
  # Because our file_ids are stable, if we already have a file with the
119
120
  # given ID, we don't need to create a new one.
@@ -92,7 +92,7 @@ class MemoryUploadedFileManager(UploadedFileManager):
92
92
 
93
93
  self.file_storage[session_id][file.file_id] = file
94
94
 
95
- def remove_file(self, session_id, file_id):
95
+ def remove_file(self, session_id: str, file_id: str) -> None:
96
96
  """Remove file with given file_id associated with a given session."""
97
97
  session_storage = self.file_storage[session_id]
98
98
  session_storage.pop(file_id, None)
@@ -228,7 +228,7 @@ class Installation:
228
228
  cls._instance = Installation()
229
229
  return cls._instance
230
230
 
231
- def __init__(self):
231
+ def __init__(self) -> None:
232
232
  self.installation_id_v3 = str(
233
233
  uuid.uuid5(uuid.NAMESPACE_DNS, _get_machine_id_v3())
234
234
  )
@@ -487,7 +487,7 @@ def create_page_profile_message(
487
487
  # Collect all config options that have been manually set
488
488
  config_options: set[str] = set()
489
489
  if config._config_options:
490
- for option_name in config._config_options.keys():
490
+ for option_name in config._config_options:
491
491
  if not config.is_manually_set(option_name):
492
492
  # We only care about manually defined options
493
493
  continue
@@ -313,7 +313,7 @@ class Runtime:
313
313
 
314
314
  async_objs = self._get_async_objs()
315
315
 
316
- def stop_on_eventloop():
316
+ def stop_on_eventloop() -> None:
317
317
  if self._state in (RuntimeState.STOPPING, RuntimeState.STOPPED):
318
318
  return
319
319
 
@@ -50,7 +50,7 @@ class modified_sys_path: # noqa: N801
50
50
  def __repr__(self) -> str:
51
51
  return util.repr_(self)
52
52
 
53
- def __enter__(self):
53
+ def __enter__(self) -> None:
54
54
  if self._main_script_path not in sys.path:
55
55
  sys.path.insert(0, self._main_script_path)
56
56
  self._added_path = True
@@ -26,7 +26,7 @@ from streamlit.source_util import open_python_file
26
26
  class ScriptCache:
27
27
  """Thread-safe cache of Python script bytecode."""
28
28
 
29
- def __init__(self):
29
+ def __init__(self) -> None:
30
30
  # Mapping of script_path: bytecode
31
31
  self._cache: dict[str, Any] = {}
32
32
  self._lock = threading.Lock()
@@ -62,6 +62,8 @@ from streamlit.runtime.state import (
62
62
  from streamlit.source_util import page_sort_key
63
63
 
64
64
  if TYPE_CHECKING:
65
+ from collections.abc import Generator
66
+
65
67
  from streamlit.runtime.fragment import FragmentStorage
66
68
  from streamlit.runtime.scriptrunner.script_cache import ScriptCache
67
69
  from streamlit.runtime.uploaded_file_manager import UploadedFileManager
@@ -139,7 +141,7 @@ def _mpa_v1(main_script_path: str) -> None:
139
141
  for page in pages
140
142
  if page.name.endswith(".py")
141
143
  and not page.name.startswith(".")
142
- and not page.name == "__init__.py"
144
+ and page.name != "__init__.py"
143
145
  ],
144
146
  key=page_sort_key,
145
147
  )
@@ -437,7 +439,7 @@ class ScriptRunner:
437
439
  raise StopException()
438
440
 
439
441
  @contextmanager
440
- def _set_execing_flag(self):
442
+ def _set_execing_flag(self) -> Generator[None, None, None]:
441
443
  """A context for setting the ScriptRunner._execing flag.
442
444
 
443
445
  Used by _maybe_handle_execution_control_request to ensure that
@@ -585,7 +587,12 @@ class ScriptRunner:
585
587
  # assume is the main script directory.
586
588
  module.__dict__["__file__"] = script_path
587
589
 
588
- def code_to_exec(code=code, module=module, ctx=ctx, rerun_data=rerun_data):
590
+ def code_to_exec(
591
+ code: str = code,
592
+ module: types.ModuleType = module,
593
+ ctx: ScriptRunContext = ctx,
594
+ rerun_data: RerunData = rerun_data,
595
+ ) -> None:
589
596
  with (
590
597
  modified_sys_path(self._main_script_path),
591
598
  self._set_execing_flag(),
@@ -111,9 +111,9 @@ def _coalesce_widget_states(
111
111
  """
112
112
  if not old_states and not new_states:
113
113
  return None
114
- elif not old_states:
114
+ if not old_states:
115
115
  return new_states
116
- elif not new_states:
116
+ if not new_states:
117
117
  return old_states
118
118
 
119
119
  states_by_id: dict[str, WidgetState] = {
@@ -161,7 +161,7 @@ class ScriptRequests:
161
161
  ScriptRunner handles those requests.
162
162
  """
163
163
 
164
- def __init__(self):
164
+ def __init__(self) -> None:
165
165
  self._lock = threading.Lock()
166
166
  self._state = ScriptRequestType.CONTINUE
167
167
  self._rerun_data = RerunData()
@@ -204,7 +204,7 @@ class ScriptRunContext:
204
204
  # Pass the message up to our associated ScriptRunner.
205
205
  self._enqueue(msg_to_send)
206
206
 
207
- def ensure_single_query_api_used(self):
207
+ def ensure_single_query_api_used(self) -> None:
208
208
  if self._experimental_query_params_used and self._production_query_params_used:
209
209
  raise StreamlitAPIException(
210
210
  "Using `st.query_params` together with either `st.experimental_get_query_params` "
@@ -212,11 +212,11 @@ class ScriptRunContext:
212
212
  " convert your app to only use `st.query_params`"
213
213
  )
214
214
 
215
- def mark_experimental_query_params_used(self):
215
+ def mark_experimental_query_params_used(self) -> None:
216
216
  self._experimental_query_params_used = True
217
217
  self.ensure_single_query_api_used()
218
218
 
219
- def mark_production_query_params_used(self):
219
+ def mark_production_query_params_used(self) -> None:
220
220
  self._production_query_params_used = True
221
221
  self.ensure_single_query_api_used()
222
222
 
@@ -27,9 +27,8 @@ from typing import (
27
27
 
28
28
  from blinker import Signal
29
29
 
30
- import streamlit as st
31
30
  import streamlit.watcher.path_watcher
32
- from streamlit import runtime
31
+ from streamlit import config, runtime
33
32
  from streamlit.errors import StreamlitSecretNotFoundError
34
33
  from streamlit.logger import get_logger
35
34
 
@@ -45,7 +44,7 @@ class SecretErrorMessages:
45
44
  For internal use, may change in future releases without notice.
46
45
  """
47
46
 
48
- def __init__(self):
47
+ def __init__(self) -> None:
49
48
  self.missing_attr_message = lambda attr_name: (
50
49
  f'st.secrets has no attribute "{attr_name}". '
51
50
  "Did you forget to add it to secrets.toml, mount it to secret directory, or the app settings "
@@ -148,7 +147,7 @@ class AttrDict(Mapping[str, Any]):
148
147
  to provide dot access to nested secrets.
149
148
  """
150
149
 
151
- def __init__(self, value):
150
+ def __init__(self, value: Mapping[str, Any]) -> None:
152
151
  self.__dict__["__nested_secrets__"] = dict(value)
153
152
 
154
153
  @staticmethod
@@ -197,7 +196,7 @@ class Secrets(Mapping[str, Any]):
197
196
  Safe to use from multiple threads.
198
197
  """
199
198
 
200
- def __init__(self):
199
+ def __init__(self) -> None:
201
200
  # Our secrets dict.
202
201
  self._secrets: Mapping[str, Any] | None = None
203
202
  self._lock = threading.RLock()
@@ -360,7 +359,7 @@ class Secrets(Mapping[str, Any]):
360
359
 
361
360
  secrets = {}
362
361
 
363
- file_paths = st.config.get_option("secrets.files")
362
+ file_paths = config.get_option("secrets.files")
364
363
  found_secrets_file = False
365
364
  for path in file_paths:
366
365
  path_secrets, found_secrets_file_in_path = self._parse_file_path(path)
@@ -413,7 +412,7 @@ class Secrets(Mapping[str, Any]):
413
412
  if self._file_watchers_installed:
414
413
  return
415
414
 
416
- file_paths = st.config.get_option("secrets.files")
415
+ file_paths = config.get_option("secrets.files")
417
416
  for path in file_paths:
418
417
  try:
419
418
  if path.endswith(".toml"):
@@ -47,9 +47,7 @@ class QueryParams(MutableMapping[str, str]):
47
47
  self._ensure_single_query_api_used()
48
48
 
49
49
  return iter(
50
- key
51
- for key in self._query_params.keys()
52
- if key not in EMBED_QUERY_PARAMS_KEYS
50
+ key for key in self._query_params if key not in EMBED_QUERY_PARAMS_KEYS
53
51
  )
54
52
 
55
53
  def __getitem__(self, key: str) -> str:
@@ -116,7 +114,7 @@ class QueryParams(MutableMapping[str, str]):
116
114
  # to ensure only one one ForwardMsg is sent.
117
115
  self._ensure_single_query_api_used()
118
116
  if hasattr(other, "keys") and hasattr(other, "__getitem__"):
119
- for key in other.keys():
117
+ for key in other.keys(): # noqa: SIM118
120
118
  self.__set_item_internal(key, other[key])
121
119
  else:
122
120
  for key, value in other:
@@ -194,7 +192,7 @@ class QueryParams(MutableMapping[str, str]):
194
192
  if key in EMBED_QUERY_PARAMS_KEYS and preserve_embed
195
193
  }
196
194
 
197
- def _ensure_single_query_api_used(self):
195
+ def _ensure_single_query_api_used(self) -> None:
198
196
  ctx = get_script_run_ctx()
199
197
  if ctx is None:
200
198
  return
@@ -249,7 +249,7 @@ class WStates(MutableMapping[str, Any]):
249
249
  """Return a list of serialized widget values for each widget with a value."""
250
250
  states = [
251
251
  self.get_serialized(widget_id)
252
- for widget_id in self.states.keys()
252
+ for widget_id in self.states
253
253
  if self.get_serialized(widget_id)
254
254
  ]
255
255
  states = cast("list[WidgetStateProto]", states)
@@ -429,10 +429,10 @@ class SessionState:
429
429
  for widgets that don't have user_keys defined, and which aren't
430
430
  exposed to user code).
431
431
  """
432
- old_keys = {self._get_widget_id(k) for k in self._old_state.keys()}
432
+ old_keys = {self._get_widget_id(k) for k in self._old_state}
433
433
  new_widget_keys = set(self._new_widget_state.keys())
434
434
  new_session_state_keys = {
435
- self._get_widget_id(k) for k in self._new_session_state.keys()
435
+ self._get_widget_id(k) for k in self._new_session_state
436
436
  }
437
437
  return old_keys | new_widget_keys | new_session_state_keys
438
438
 
@@ -729,19 +729,19 @@ class SessionState:
729
729
  We use pickleability as the metric for serializability, and test for
730
730
  pickleability by just trying it.
731
731
  """
732
- try:
733
- for k in self:
732
+ for k in self:
733
+ try:
734
734
  pickle.dumps(self[k])
735
- except Exception as e:
736
- err_msg = (
737
- f"Cannot serialize the value (of type `{type(self[k])}`) of '{k}' in "
738
- "st.session_state. Streamlit has been configured to use "
739
- "[pickle](https://docs.python.org/3/library/pickle.html) to "
740
- "serialize session_state values. Please convert the value to a "
741
- "pickle-serializable type. To learn more about this behavior, "
742
- "see [our docs](https://docs.streamlit.io/knowledge-base/using-streamlit/serializable-session-state)."
743
- )
744
- raise UnserializableSessionStateError(err_msg) from e
735
+ except Exception as e: # noqa: PERF203
736
+ err_msg = (
737
+ f"Cannot serialize the value (of type `{type(self[k])}`) of '{k}' in "
738
+ "st.session_state. Streamlit has been configured to use "
739
+ "[pickle](https://docs.python.org/3/library/pickle.html) to "
740
+ "serialize session_state values. Please convert the value to a "
741
+ "pickle-serializable type. To learn more about this behavior, "
742
+ "see [our docs](https://docs.streamlit.io/knowledge-base/using-streamlit/serializable-session-state)."
743
+ )
744
+ raise UnserializableSessionStateError(err_msg) from e
745
745
 
746
746
  def maybe_check_serializable(self) -> None:
747
747
  """Verify that session state can be serialized, if the relevant config
@@ -90,7 +90,7 @@ class CacheStatsProvider(Protocol):
90
90
 
91
91
 
92
92
  class StatsManager:
93
- def __init__(self):
93
+ def __init__(self) -> None:
94
94
  self._cache_stats_providers: list[CacheStatsProvider] = []
95
95
 
96
96
  def register_provider(self, provider: CacheStatsProvider) -> None:
@@ -51,7 +51,7 @@
51
51
  <script>
52
52
  window.prerenderReady = false
53
53
  </script>
54
- <script type="module" crossorigin src="./static/js/index.BgEbLy94.js"></script>
54
+ <script type="module" crossorigin src="./static/js/index.Dqcp7EZB.js"></script>
55
55
  <link rel="stylesheet" crossorigin href="./static/css/index.C6rq3aMZ.css">
56
56
  </head>
57
57
  <body>
@@ -1 +1 @@
1
- import{r,E as a,_ as n}from"./index.BgEbLy94.js";var i=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(a,n({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});i.displayName="ErrorOutline";export{i as E};
1
+ import{r,E as a,_ as n}from"./index.Dqcp7EZB.js";var i=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(a,n({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});i.displayName="ErrorOutline";export{i as E};
@@ -1 +1 @@
1
- import{r as e,E as n,_ as a}from"./index.BgEbLy94.js";var o=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),e.createElement("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}))});o.displayName="Delete";var i=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("rect",{width:24,height:24,fill:"none"}),e.createElement("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4l-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}))});i.displayName="FileDownload";export{o as D,i as F};
1
+ import{r as e,E as n,_ as a}from"./index.Dqcp7EZB.js";var o=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),e.createElement("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}))});o.displayName="Delete";var i=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("rect",{width:24,height:24,fill:"none"}),e.createElement("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4l-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}))});i.displayName="FileDownload";export{o as D,i as F};