Skip to content

Commit

Permalink
do not run remove f str if we want to skip line
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Jan 11, 2024
1 parent 0cbf9a8 commit 876836a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
10 changes: 0 additions & 10 deletions src/core_codemods/https_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ def updated_args(self, original_args):

def update_attribute(self, true_name, original_node, updated_node, new_args):
del true_name
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node

return updated_node.with_changes(
args=new_args,
func=updated_node.func.with_changes(
Expand All @@ -39,11 +34,6 @@ def update_attribute(self, true_name, original_node, updated_node, new_args):

def update_simple_name(self, true_name, original_node, updated_node, new_args):
del true_name
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node

AddImportsVisitor.add_needed_import(self.context, "urllib3")
RemoveImportsVisitor.remove_unused_import_by_node(self.context, original_node)
return updated_node.with_changes(
Expand Down
6 changes: 3 additions & 3 deletions src/core_codemods/remove_unnecessary_f_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def _check_formatted_string(
_original_node: cst.FormattedString,
updated_node: cst.FormattedString,
):
transformed_node = super()._check_formatted_string(_original_node, updated_node)
if not self.filter_by_path_includes_or_excludes(
self.node_position(transformed_node)
self.node_position(_original_node)
):
return transformed_node
return _original_node

transformed_node = super()._check_formatted_string(_original_node, updated_node)
if not _original_node.deep_equals(transformed_node):
self.report_change(_original_node)
return transformed_node
10 changes: 0 additions & 10 deletions src/core_codemods/use_walrus_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ def leave_If(self, original_node, updated_node):

def leave_Assign(self, original_node: cst.Assign, updated_node: cst.Assign):
del updated_node
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node

if named_expr := self.assigns.get(original_node):
position = self.node_position(original_node)
self._modify_next_if.append((position, named_expr))
Expand All @@ -157,11 +152,6 @@ def leave_SimpleStatementLine(self, original_node, updated_node):
This feels like a bug in libCST but we'll work around it for now.
"""
if not self.filter_by_path_includes_or_excludes(
self.node_position(original_node)
):
return original_node

if not updated_node.body:
trailing_whitespace = (
(
Expand Down

0 comments on commit 876836a

Please sign in to comment.