streamlit-nightly 1.36.1.dev20240722__py2.py3-none-any.whl → 1.36.1.dev20240723__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.
@@ -15,6 +15,7 @@
15
15
  from __future__ import annotations
16
16
 
17
17
  import ast
18
+ import sys
18
19
  from typing import Any, Final
19
20
 
20
21
  from streamlit import config
@@ -46,10 +47,12 @@ def add_magic(code: str, script_path: str) -> Any:
46
47
 
47
48
  file_ends_in_semicolon = _does_file_end_in_semicolon(tree, code)
48
49
 
49
- return _modify_ast_subtree(
50
+ _modify_ast_subtree(
50
51
  tree, is_root=True, file_ends_in_semicolon=file_ends_in_semicolon
51
52
  )
52
53
 
54
+ return tree
55
+
53
56
 
54
57
  def _modify_ast_subtree(
55
58
  tree: Any,
@@ -65,19 +68,25 @@ def _modify_ast_subtree(
65
68
  node_type = type(node)
66
69
 
67
70
  # Recursively parses the content of the statements
68
- # `with`, `for` and `while`, as well as function definitions.
71
+ # `with` as well as function definitions.
69
72
  # Also covers their async counterparts
70
73
  if (
71
74
  node_type is ast.FunctionDef
72
75
  or node_type is ast.With
73
- or node_type is ast.For
74
- or node_type is ast.While
75
76
  or node_type is ast.AsyncFunctionDef
76
77
  or node_type is ast.AsyncWith
77
- or node_type is ast.AsyncFor
78
78
  ):
79
79
  _modify_ast_subtree(node)
80
80
 
81
+ # Recursively parses the content of the statements
82
+ # `for` and `while`.
83
+ # Also covers their async counterparts
84
+ elif (
85
+ node_type is ast.For or node_type is ast.While or node_type is ast.AsyncFor
86
+ ):
87
+ _modify_ast_subtree(node)
88
+ _modify_ast_subtree(node, "orelse")
89
+
81
90
  # Recursively parses methods in a class.
82
91
  elif node_type is ast.ClassDef:
83
92
  for inner_node in node.body:
@@ -86,12 +95,14 @@ def _modify_ast_subtree(
86
95
 
87
96
  # Recursively parses the contents of try statements,
88
97
  # all their handlers (except and else) and the finally body
89
- elif node_type is ast.Try:
90
- for j, inner_node in enumerate(node.handlers):
91
- node.handlers[j] = _modify_ast_subtree(inner_node)
92
- finally_node = _modify_ast_subtree(node, body_attr="finalbody")
93
- node.finalbody = finally_node.finalbody
98
+ elif node_type is ast.Try or (
99
+ sys.version_info >= (3, 11) and node_type is ast.TryStar
100
+ ):
94
101
  _modify_ast_subtree(node)
102
+ _modify_ast_subtree(node, body_attr="finalbody")
103
+ _modify_ast_subtree(node, body_attr="orelse")
104
+ for handler_node in node.handlers:
105
+ _modify_ast_subtree(handler_node)
95
106
 
96
107
  # Recursively parses if blocks, as well as their else/elif blocks
97
108
  # (else/elif are both mapped to orelse)
@@ -100,6 +111,10 @@ def _modify_ast_subtree(
100
111
  _modify_ast_subtree(node)
101
112
  _modify_ast_subtree(node, "orelse")
102
113
 
114
+ elif sys.version_info >= (3, 10) and node_type is ast.Match:
115
+ for case_node in node.cases:
116
+ _modify_ast_subtree(case_node)
117
+
103
118
  # Convert standalone expression nodes to st.write
104
119
  elif node_type is ast.Expr:
105
120
  value = _get_st_write_from_expr(
@@ -119,8 +134,6 @@ def _modify_ast_subtree(
119
134
 
120
135
  ast.fix_missing_locations(tree)
121
136
 
122
- return tree
123
-
124
137
 
125
138
  def _insert_import_statement(tree: Any) -> None:
126
139
  """Insert Streamlit import statement at the top(ish) of the tree."""
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.29bca1b5.css",
4
- "main.js": "./static/js/main.35bc5645.js",
4
+ "main.js": "./static/js/main.94c2fada.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.7d516fcc.chunk.js": "./static/js/2736.7d516fcc.chunk.js",
@@ -152,6 +152,6 @@
152
152
  },
153
153
  "entrypoints": [
154
154
  "static/css/main.29bca1b5.css",
155
- "static/js/main.35bc5645.js"
155
+ "static/js/main.94c2fada.js"
156
156
  ]
157
157
  }
@@ -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.35bc5645.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.94c2fada.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>