from pathlib import Path import re file_path = Path('src/app_controller.py') code = file_path.read_text(encoding='utf-8') # Remove the garbage tail code = re.sub(r'\n= \[\]\s*$', '', code) code = code.strip() + "\n" file_path.write_text(code, encoding='utf-8') print("Tail cleanup complete.")