From b8c0653cc4e6bacad8db8bd42984fd0e1cec75b0 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Mon, 13 Jul 2026 05:14:03 +0200 Subject: [PATCH] fix: FrappeFilterList type hint (#53) (cherry picked from commit 0bcc08ddc6b5e8401dd5f60b24e540b60d7e81c7) --- ask_alyf/ask_alyf/toolset.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ask_alyf/ask_alyf/toolset.py b/ask_alyf/ask_alyf/toolset.py index 66af924..fc658a8 100644 --- a/ask_alyf/ask_alyf/toolset.py +++ b/ask_alyf/ask_alyf/toolset.py @@ -15,6 +15,13 @@ from ask_alyf.ask_alyf.skill_utils import get_accessible_skill_doc from ask_alyf.ask_alyf.utils import parse_newline_list +# Frappe list filters are a list of filter rows, where each row is a list of +# scalars, e.g. [["Customer", "name", "=", "CUST-001"], ["disabled", "=", 0]]. +# Typed (rather than `list[Any]`) so the generated JSON Schema gives the array +# `items` a concrete `type`, which OpenAI strict function-calling requires. +Scalar = str | int | float | bool | None +FrappeFilterList = list[list[Scalar | list[Scalar]]] + @dataclass class ask_alyfRuntime: @@ -143,7 +150,7 @@ def get_list( self, doctype: str, fields: str | list[str] | None = None, - filters: dict[str, Any] | list[Any] | None = None, + filters: dict[str, Any] | FrappeFilterList | None = None, order_by: str | None = None, limit: int = 20, group_by: str | None = None, @@ -174,7 +181,7 @@ def get_list( def get_count( self, doctype: str, - filters: dict[str, Any] | list[Any] | None = None, + filters: dict[str, Any] | FrappeFilterList | None = None, ) -> int: """Count documents that match the given filters. @@ -211,7 +218,7 @@ def get_value( self, doctype: str, fieldname: str | list[str], - filters: dict[str, Any] | list[Any] | str | None = None, + filters: dict[str, Any] | FrappeFilterList | str | None = None, ) -> Any: """Read one or more field values from a document.