File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,7 @@ test = [
194194]
195195build = [
196196 ' hatch run "src/build_scripts/clean_js_dir.py"' ,
197+ ' bun install --cwd "src/js"' ,
197198 ' hatch run javascript:build_event_to_object' ,
198199 ' hatch run javascript:build_client' ,
199200 ' hatch run javascript:build_app' ,
Original file line number Diff line number Diff line change 11import click
22
33import reactpy
4- from reactpy ._console .rewrite_camel_case_props import rewrite_camel_case_props
54from reactpy ._console .rewrite_keys import rewrite_keys
5+ from reactpy ._console .rewrite_props import rewrite_props
66
77
88@click .group ()
@@ -12,7 +12,7 @@ def app() -> None:
1212
1313
1414app .add_command (rewrite_keys )
15- app .add_command (rewrite_camel_case_props )
15+ app .add_command (rewrite_props )
1616
1717
1818if __name__ == "__main__" :
Original file line number Diff line number Diff line change 2020
2121@click .command ()
2222@click .argument ("paths" , nargs = - 1 , type = click .Path (exists = True ))
23- def rewrite_camel_case_props (paths : list [str ]) -> None :
24- """Rewrite camelCase props to snake_case """
23+ def rewrite_props (paths : list [str ]) -> None :
24+ """Rewrite snake_case to props to camelCase """
2525
2626 for p in map (Path , paths ):
2727 for f in [p ] if p .is_file () else p .rglob ("*.py" ):
@@ -50,8 +50,11 @@ def find_nodes_to_change(tree: ast.AST) -> list[ChangedNode]:
5050
5151
5252def conv_attr_name (name : str ) -> str :
53- new_name = CAMEL_CASE_SUB_PATTERN .sub ("_" , name ).lower ()
54- return f"{ new_name } _" if new_name in kwlist else new_name
53+ if name in kwlist :
54+ return name
55+ result = name .replace ("_" , " " ).title ().replace (" " , "" )
56+ result = name [0 ].lower () + name [1 :]
57+ return result
5558
5659
5760def _construct_prop_item (key : str , value : ast .expr ) -> tuple [str , ast .expr ]:
Original file line number Diff line number Diff line change 44import pytest
55from click .testing import CliRunner
66
7- from reactpy ._console .rewrite_camel_case_props import (
7+ from reactpy ._console .rewrite_props import (
88 generate_rewrite ,
9- rewrite_camel_case_props ,
9+ rewrite_props ,
1010)
1111
1212
@@ -16,7 +16,7 @@ def test_rewrite_camel_case_props_declarations(tmp_path):
1616 tempfile : Path = tmp_path / "temp.py"
1717 tempfile .write_text ("html.div(dict(camelCase='test'))" )
1818 result = runner .invoke (
19- rewrite_camel_case_props ,
19+ rewrite_props ,
2020 args = [str (tmp_path )],
2121 catch_exceptions = False ,
2222 )
@@ -29,7 +29,7 @@ def test_rewrite_camel_case_props_declarations_no_files():
2929 runner = CliRunner ()
3030
3131 result = runner .invoke (
32- rewrite_camel_case_props ,
32+ rewrite_props ,
3333 args = ["directory-does-no-exist" ],
3434 catch_exceptions = False ,
3535 )
You can’t perform that action at this time.
0 commit comments