From 06b0e325e9773691e4cbf8542ac7da54960a3d74 Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Thu, 9 Nov 2023 11:20:44 -0300 Subject: [PATCH] optimize django debug codemod --- src/core_codemods/django_debug_flag_on.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core_codemods/django_debug_flag_on.py b/src/core_codemods/django_debug_flag_on.py index da38891ff..37a24704d 100644 --- a/src/core_codemods/django_debug_flag_on.py +++ b/src/core_codemods/django_debug_flag_on.py @@ -33,11 +33,11 @@ def rule(cls): - settings.py """ - def leave_Assign(self, original_node, updated_node): - # checks if this module is a settings.py file from django's default directory structure - if is_django_settings_file(self.file_context.file_path): - return super().leave_Assign(original_node, updated_node) - return updated_node + def visit_Module(self, _: cst.Module) -> bool: + """ + Only visit module with this codemod if it's a settings.py file. + """ + return is_django_settings_file(self.file_context.file_path) def on_result_found(self, _, updated_node): return updated_node.with_changes(value=cst.Name("False"))