File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -54,13 +54,20 @@ def find_nodes_to_change(tree: ast.AST) -> list[ChangedNode]:
5454
5555def conv_attr_name (name : str ) -> str :
5656 """Convert snake_case attribute name to camelCase"""
57+ # Return early if the value is a Python keyword
5758 if name in kwlist :
58- return name # Return the name as is if it's a Python keyword
59- # Convert snake_case to CamelCase
60- result = name .replace ("_" , " " ).title ().replace (" " , "" )
61- # Ensure the first letter is lowercase
62- result = name [0 ].lower () + name [1 :]
63- return result
59+ return name
60+
61+ # Return early if the value is not snake_case
62+ if "_" not in name :
63+ return name
64+
65+ # Split the string by underscores
66+ components = name .split ("_" )
67+
68+ # Capitalize the first letter of each component except the first one
69+ # and join them together
70+ return components [0 ] + "" .join (x .title () for x in components [1 :])
6471
6572
6673def _construct_prop_item (key : str , value : ast .expr ) -> tuple [str , ast .expr ]:
File renamed without changes.
You can’t perform that action at this time.
0 commit comments