Coverage for src / renaissance / recipes / simplify_renaissance.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-09-09 14:04 +0000

1from pathlib import Path 

2from typing import override 

3 

4from renaissance.recipes.python_refactoring import PythonRefactoring 

5 

6 

7class SimplifyRenaissance(PythonRefactoring): 

8 def __init__(self, file): 

9 super().__init__(file) 

10 self.white_list_pattern = "unit2pytest" 

11 self.black_list_pattern = "SimplifyRenaissance" 

12 

13 @override 

14 def run(self): 

15 if self.black_list_pattern in self.filename or self.white_list_pattern not in self.filename: 

16 print(f"skipping: {Path(self.filename).resolve()}") 

17 return 

18 

19 print(f"simplify {Path(self.filename).resolve()}") 

20 self.replace_stmt("$val = match.expansions[$key][0].signature", "$val= match[$key]") 

21 self.replace_stmt( 

22 "factory = ASTFactory(PythonASTNode)\n$atu = factory.create_from_text($code, $name)", 

23 "PythonASTNode.load_from_text($code, $name)", 

24 ) 

25 self.commit()