Coverage for src/renaissance/recipes/simplify_renaissance.py: 100%
17 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
1"""AI: Recipe that simplifies Renaissance's own unit-to-pytest conversion files."""
3from pathlib import Path
4from typing import override
6from renaissance.recipes.python_refactoring import PythonRefactoring
9class SimplifyRenaissance(PythonRefactoring):
10 """AI: Recipe that simplifies Renaissance's own unit-to-pytest conversion files."""
12 def __init__(self, file):
13 """AI: Prepare a refactoring processor scoped to Renaissance's own unit-to-pytest conversion files."""
14 super().__init__(file)
15 self.white_list_pattern = "unit_to_pytest"
16 self.black_list_pattern = "SimplifyRenaissance"
18 @override
19 def run(self):
20 if self.black_list_pattern in self.filename or self.white_list_pattern not in self.filename:
21 print(f"skipping: {Path(self.filename).resolve()}")
22 return
24 print(f"simplify {Path(self.filename).resolve()}")
25 self.replace_stmt("$val = match.expansions[$key][0].signature", "$val= match[$key]")
26 self.replace_stmt(
27 "factory = ASTFactory(PythonASTNode)\n$atu = factory.create_from_text($code, $name)",
28 "PythonASTNode.load_from_text($code, $name)",
29 )
30 self.commit()