diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e7624eb..b8bb731c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Added - Added Point in time API rest API([#191](https://github.com/opensearch-project/opensearch-py/pull/191)) - Github workflow for changelog verification ([#218](https://github.com/opensearch-project/opensearch-py/pull/218)) +- Added overload decorators to helpers-actions.pyi-"bulk" ([#239](https://github.com/opensearch-project/opensearch-py/pull/239)) ### Changed - Updated getting started to user guide ([#233](https://github.com/opensearch-project/opensearch-py/pull/233)) - Updated CA certificate handling to check OpenSSL environment variables before defaulting to certifi ([#196](https://github.com/opensearch-project/opensearch-py/pull/196)) diff --git a/opensearchpy/helpers/actions.pyi b/opensearchpy/helpers/actions.pyi index ecc9447b..4fee4bd1 100644 --- a/opensearchpy/helpers/actions.pyi +++ b/opensearchpy/helpers/actions.pyi @@ -25,6 +25,7 @@ # under the License. import logging +import sys from typing import ( Any, AsyncIterable, @@ -38,8 +39,14 @@ from typing import ( Optional, Tuple, Union, + overload, ) +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + from ..client import OpenSearch from ..serializer import Serializer @@ -74,14 +81,24 @@ def streaming_bulk( *args: Any, **kwargs: Any ) -> Generator[Tuple[bool, Any], None, None]: ... +@overload def bulk( client: OpenSearch, actions: Iterable[Any], - stats_only: bool = ..., + stats_only: Literal[True] = ..., ignore_status: Optional[Union[int, Collection[int]]] = ..., *args: Any, **kwargs: Any -) -> Tuple[int, Union[int, List[Any]]]: ... +) -> Tuple[int, int]: ... +@overload +def bulk( + client: OpenSearch, + actions: Iterable[Any], + stats_only: Literal[False], + ignore_status: Optional[Union[int, Collection[int]]] = ..., + *args: Any, + **kwargs: Any +) -> Tuple[int, List[Any]]: ... def parallel_bulk( client: OpenSearch, actions: Iterable[Any],