From 3488163592f6f71131a021ed4bb921e19c6d28f5 Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Wed, 10 Jan 2024 14:38:45 -0300 Subject: [PATCH] do not run remove f str if we want to skip line --- src/core_codemods/https_connection.py | 10 ---------- src/core_codemods/remove_unnecessary_f_str.py | 6 +++--- src/core_codemods/use_walrus_if.py | 10 ---------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/core_codemods/https_connection.py b/src/core_codemods/https_connection.py index 0ea2f0c2c..502e3faa7 100644 --- a/src/core_codemods/https_connection.py +++ b/src/core_codemods/https_connection.py @@ -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( @@ -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( diff --git a/src/core_codemods/remove_unnecessary_f_str.py b/src/core_codemods/remove_unnecessary_f_str.py index e9904cb53..6b5468db3 100644 --- a/src/core_codemods/remove_unnecessary_f_str.py +++ b/src/core_codemods/remove_unnecessary_f_str.py @@ -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 diff --git a/src/core_codemods/use_walrus_if.py b/src/core_codemods/use_walrus_if.py index 76fcdf718..45ae4f02c 100644 --- a/src/core_codemods/use_walrus_if.py +++ b/src/core_codemods/use_walrus_if.py @@ -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)) @@ -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 = ( (