From a9459b3d4d7b64c521b4be33db5653419c66eff0 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Fri, 16 Jun 2023 17:25:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Update=20scratch=20instead=20of?= =?UTF-8?q?=20overwriting=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bump_pydantic/main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bump_pydantic/main.py b/bump_pydantic/main.py index 74b1f57..3834e18 100644 --- a/bump_pydantic/main.py +++ b/bump_pydantic/main.py @@ -73,15 +73,15 @@ def main( for codemod in codemods: for filename in files: module_and_package = calculate_module_and_package(str(package), filename) - transformer = codemod( - CodemodContext( - metadata_manager=metadata_manager, - filename=filename, - full_module_name=module_and_package.name, - full_package_name=module_and_package.package, - scratch=scratch, - ) + context = CodemodContext( + metadata_manager=metadata_manager, + filename=filename, + full_module_name=module_and_package.name, + full_package_name=module_and_package.package, ) + context.scratch.update(scratch) + + transformer = codemod(context=context) old_code = Path(filename).read_text() input_tree = cst.parse_module(old_code)