From 1cb75336d083d1385815d04c7f5a50e863746e82 Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Thu, 14 Mar 2024 15:33:35 -0400 Subject: [PATCH] Avoid multiple inheritance in f-str codemod --- src/core_codemods/remove_unnecessary_f_str.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/core_codemods/remove_unnecessary_f_str.py b/src/core_codemods/remove_unnecessary_f_str.py index 26480be0..f8d4dda6 100644 --- a/src/core_codemods/remove_unnecessary_f_str.py +++ b/src/core_codemods/remove_unnecessary_f_str.py @@ -1,6 +1,7 @@ +from typing import cast + import libcst as cst import libcst.matchers as m -from libcst.codemod import CodemodContext from libcst.codemod.commands.unnecessary_format_string import UnnecessaryFormatString from codemodder.codemods.libcst_transformer import ( @@ -11,18 +12,9 @@ from core_codemods.api.core_codemod import CoreCodemod -class RemoveUnnecessaryFStrTransform(LibcstResultTransformer, UnnecessaryFormatString): - +class RemoveUnnecessaryFStrTransform(LibcstResultTransformer): change_description = "Remove unnecessary f-string" - def __init__( - self, codemod_context: CodemodContext, *codemod_args, **codemod_kwargs - ): - UnnecessaryFormatString.__init__(self, codemod_context) - LibcstResultTransformer.__init__( - self, codemod_context, *codemod_args, **codemod_kwargs - ) - @m.leave(m.FormattedString(parts=(m.FormattedStringText(),))) def _check_formatted_string( self, @@ -34,7 +26,9 @@ def _check_formatted_string( ): return updated_node - transformed_node = super()._check_formatted_string(_original_node, updated_node) + transformed_node = UnnecessaryFormatString._check_formatted_string( + cast(UnnecessaryFormatString, self), _original_node, updated_node + ) if not _original_node.deep_equals(transformed_node): self.report_change(_original_node) return transformed_node