From 96bc17a40f84bd9c665879e94ccbdd6523ea3269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar?= Date: Thu, 7 Jul 2022 16:42:14 +0200 Subject: [PATCH] Annotate `jmespath` public API (#8253) --- stubs/jmespath/jmespath/__init__.pyi | 4 ++-- stubs/jmespath/jmespath/functions.pyi | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/stubs/jmespath/jmespath/__init__.pyi b/stubs/jmespath/jmespath/__init__.pyi index 4f40ec73e..23077fb69 100644 --- a/stubs/jmespath/jmespath/__init__.pyi +++ b/stubs/jmespath/jmespath/__init__.pyi @@ -3,5 +3,5 @@ from typing import Any from jmespath import parser as parser from jmespath.visitor import Options as Options -def compile(expression): ... -def search(expression, data, options: Any | None = ...): ... +def compile(expression: str) -> parser.ParsedResult: ... +def search(expression: str, data: Any, options: Any | None = ...) -> Any: ... diff --git a/stubs/jmespath/jmespath/functions.pyi b/stubs/jmespath/jmespath/functions.pyi index b64e9ec28..e1916f99e 100644 --- a/stubs/jmespath/jmespath/functions.pyi +++ b/stubs/jmespath/jmespath/functions.pyi @@ -1,9 +1,17 @@ -from typing import Any +from collections.abc import Callable +from typing import Any, TypeVar +from typing_extensions import NotRequired, TypedDict -TYPES_MAP: Any -REVERSE_TYPES_MAP: Any +TYPES_MAP: dict[str, str] +REVERSE_TYPES_MAP: dict[str, tuple[str, ...]] -def signature(*arguments): ... +class _Signature(TypedDict): + types: list[str] + variadic: NotRequired[bool] + +_F = TypeVar("_F", bound=Callable[..., Any]) + +def signature(*arguments: _Signature) -> Callable[[_F], _F]: ... class FunctionRegistry(type): def __init__(cls, name, bases, attrs) -> None: ...