Skip to content

Commit

Permalink
should return updated_node
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Jan 12, 2024
1 parent 639a42e commit 36a87fe
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/core_codemods/combine_startswith_endswith.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def leave_BooleanOperation(
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node
return updated_node

Check warning on line 20 in src/core_codemods/combine_startswith_endswith.py

View check run for this annotation

Codecov / codecov/patch

src/core_codemods/combine_startswith_endswith.py#L20

Added line #L20 was not covered by tests

if self.matches_startswith_endswith_or_pattern(original_node):
left_call = cst.ensure_type(updated_node.left, cst.Call)
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion src/core_codemods/exception_without_raise.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def leave_SimpleStatementLine(
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node
return updated_node

match original_node:
case cst.SimpleStatementLine(
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/fix_deprecated_abstractproperty.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def leave_Decorator(
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node
return updated_node

if (
base_name := self.find_base_name(original_node.decorator)
Expand Down
8 changes: 5 additions & 3 deletions src/core_codemods/remove_debug_breakpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ class RemoveDebugBreakpoint(BaseCodemod, NameResolutionMixin, AncestorPatternsMi
REFERENCES: list = []

def leave_Expr(
self, original_node: cst.Expr, _
self,
original_node: cst.Expr,
updated_node: cst.Expr,
) -> Union[cst.Expr, cst.RemovalSentinel]:
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node
return updated_node

Check warning on line 23 in src/core_codemods/remove_debug_breakpoint.py

View check run for this annotation

Codecov / codecov/patch

src/core_codemods/remove_debug_breakpoint.py#L22-L23

Added lines #L22 - L23 were not covered by tests
match call_node := original_node.value:
case cst.Call():
Expand All @@ -29,4 +31,4 @@ def leave_Expr(
self.report_change(original_node)
return cst.RemovalSentinel.REMOVE

return original_node
return updated_node
6 changes: 4 additions & 2 deletions src/core_codemods/remove_module_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class RemoveModuleGlobal(BaseCodemod, NameResolutionMixin):
REFERENCES: list = []

def leave_Global(
self, original_node: cst.Global, _
self,
original_node: cst.Global,
updated_node: cst.Global,
) -> Union[cst.Global, cst.RemovalSentinel,]:
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node
return updated_node
scope = self.get_metadata(ScopeProvider, original_node)
if isinstance(scope, GlobalScope):
self.report_change(original_node)
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/remove_unnecessary_f_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _check_formatted_string(
if not self.filter_by_path_includes_or_excludes(
self.node_position(_original_node)
):
return _original_node
return updated_node

transformed_node = super()._check_formatted_string(_original_node, updated_node)
if not _original_node.deep_equals(transformed_node):
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/subprocess_shell_false.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def leave_Call(self, original_node: cst.Call, updated_node: cst.Call):
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node
return updated_node

Check warning on line 36 in src/core_codemods/subprocess_shell_false.py

View check run for this annotation

Codecov / codecov/patch

src/core_codemods/subprocess_shell_false.py#L36

Added line #L36 was not covered by tests

if self.find_base_name(original_node.func) in self.SUBPROCESS_FUNCS:
for arg in original_node.args:
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/use_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def leave_Call(self, original_node: cst.Call, updated_node: cst.Call):
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node
return updated_node

match original_node.func:
# NOTE: could also support things like `list` and `tuple`
Expand Down

0 comments on commit 36a87fe

Please sign in to comment.