@@ -92,7 +92,9 @@ class ChangedNode:
9292 parents : Sequence [ast .AST ]
9393
9494
95- def find_element_constructor_usages (tree : ast .AST ) -> Iterator [ElementConstructorInfo ]:
95+ def find_element_constructor_usages (
96+ tree : ast .AST , add_props : bool = False
97+ ) -> Iterator [ElementConstructorInfo ]:
9698 changed : list [Sequence [ast .AST ]] = []
9799 for parents , node in _walk_with_parent (tree ):
98100 if not (isinstance (node , ast .Call )):
@@ -111,24 +113,37 @@ def find_element_constructor_usages(tree: ast.AST) -> Iterator[ElementConstructo
111113 continue
112114
113115 maybe_attr_dict_node : Any | None = None
116+
114117 if name == "vdom" :
115118 if len (node .args ) == 0 :
116119 continue
117120 elif len (node .args ) == 1 :
118121 maybe_attr_dict_node = ast .Dict (keys = [], values = [])
119- node .args .append (maybe_attr_dict_node )
122+ if add_props :
123+ node .args .append (maybe_attr_dict_node )
124+ else :
125+ continue
120126 elif isinstance (node .args [1 ], (ast .Constant , ast .JoinedStr )):
121127 maybe_attr_dict_node = ast .Dict (keys = [], values = [])
122- node .args .insert (1 , maybe_attr_dict_node )
128+ if add_props :
129+ node .args .insert (1 , maybe_attr_dict_node )
130+ else :
131+ continue
123132 elif len (node .args ) >= 2 :
124133 maybe_attr_dict_node = node .args [1 ]
125134 elif hasattr (html , name ):
126135 if len (node .args ) == 0 :
127136 maybe_attr_dict_node = ast .Dict (keys = [], values = [])
128- node .args .append (maybe_attr_dict_node )
137+ if add_props :
138+ node .args .append (maybe_attr_dict_node )
139+ else :
140+ continue
129141 elif isinstance (node .args [0 ], (ast .Constant , ast .JoinedStr )):
130142 maybe_attr_dict_node = ast .Dict (keys = [], values = [])
131- node .args .insert (0 , maybe_attr_dict_node )
143+ if add_props :
144+ node .args .insert (0 , maybe_attr_dict_node )
145+ else :
146+ continue
132147 else :
133148 maybe_attr_dict_node = node .args [0 ]
134149
0 commit comments