From 9f004c8217960bbf5751cb3ff593bc33c0082e08 Mon Sep 17 00:00:00 2001 From: kshitij <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 15 Aug 2026 02:47:59 +0530 Subject: [PATCH] refactor: hoist binary_extensions import to module level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lazy import inside _check_binary_document_write was unnecessary — binary_extensions is a leaf module already imported at line 15. Hoisted has_opaque_document_extension and is_pdf_path to the existing module-level import. /simplify-code finding. --- tools/file_tools.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/file_tools.py b/tools/file_tools.py index 735880d33e..2270fb57f6 100644 --- a/tools/file_tools.py +++ b/tools/file_tools.py @@ -12,7 +12,11 @@ import threading from pathlib import Path, PurePosixPath from agent.file_safety import get_read_block_error -from tools.binary_extensions import has_binary_extension +from tools.binary_extensions import ( + has_binary_extension, + has_opaque_document_extension, + is_pdf_path, +) from tools.file_operations import ( ShellFileOperations, normalize_read_pagination, @@ -2186,7 +2190,6 @@ def _check_binary_document_write(filepath: str, task_id: str = "default") -> str - .pdf: rejected only when OVERWRITING an existing regular file. Raw PDF syntax is text-authorable, so new-file creation stays allowed. """ - from tools.binary_extensions import has_opaque_document_extension, is_pdf_path if has_opaque_document_extension(filepath): ext = filepath[filepath.rfind("."):].lower() return (