Skip to content

Commit 8ec06c1

Browse files
Cleaned up canonical codemods (#26)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed - [ ] I have read and agree to the [Contributor License Agreement](../CLA.md) Co-authored-by: Edward Li <[email protected]>
1 parent 9904d5f commit 8ec06c1

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/codemods/canonical/pivot_return_types/pivot_return_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def f() -> FastStr:
3535
def execute(self, codebase: Codebase) -> None:
3636
# Iterate over all functions in the codebase
3737
for function in codebase.functions:
38-
# Check if the function's return type annotation is 'BillPayVendor'
38+
# Check if the function's return type annotation is 'str'
3939
if (return_type := function.return_type) and return_type.source == "str":
40-
# Update the return type to 'Payee'
40+
# Update the return type to 'FastStr'
4141
function.set_return_type("FastStr")
4242

4343
# Add import for 'FastStr' if it doesn't exist

src/codemods/canonical/rename_local_variables/rename_local_variables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def execute(self, codebase: Codebase) -> None:
4242
for file in codebase.files:
4343
for function in file.functions:
4444
# Check if any local variable names contain "position"
45-
business_vendor_usages = function.code_block.get_variable_usages("position", fuzzy_match=True)
46-
if len(business_vendor_usages) > 0:
45+
position_usages = function.code_block.get_variable_usages("position", fuzzy_match=True)
46+
if len(position_usages) > 0:
4747
# Rename
4848
function.rename_local_variable("position", "pos", fuzzy_match=True)

src/codemods/canonical/swap_class_attribute_usages/swap_class_attribute_usages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def execute(self, codebase: Codebase) -> None:
4444
# Add import of `CacheConfig` to function definition file
4545
function.file.add_symbol_import(class_b_symb)
4646

47-
# Check if the function body is using `bill_pay_vendor`
47+
# Check if the function body is using `cache_config`
4848
if len(function.code_block.get_variable_usages(class_a_param.name)) > 0:
4949
# Add "wrapper" inside the function
50-
# This creates the `business_vendor` variable internally
50+
# This creates the `cache_config` variable internally
5151
proxy_var_declaration = f"""{class_a_param.name} = cache_config.settings # added by Codegen"""
5252
function.prepend_statements(proxy_var_declaration)
5353

54-
# Update all callsites of original function to take in `payee` instead of `bill_pay_vendor`
54+
# Update all callsites of original function to take in `cache_config` instead of `graph_rag_config`
5555
fcalls = function.call_sites
5656
for fcall in fcalls:
5757
arg = fcall.get_arg_by_parameter_name(class_a_param.name)

0 commit comments

Comments
 (0)