Skip to content

How to replace method of a class? #4

Description

@manicko

The query below replacing the entire class {
"language": "python",
"path": "C:\py_dev\mko_telepost\morfx_test\morfix_test_file2.py",
"target_dsl": "class:ImageCache >> method:cleanup_unused",
"replacement": " def cleanup_unused(self, used_files: set[Path]) -> int:\n """Remove unused cached files (MORFX TEST REPLACEMENT)."""\n removed = 0\n for cached_file in self.cache_dir.iterdir():\n if cached_file not in used_files and cached_file.is_file():\n try:\n cached_file.unlink()\n logger.info(f"Removed unused cache: {cached_file}")\n removed += 1\n except Exception as e:\n logger.error(f"Error removing {cached_file}: {e}")\n return removed"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions