From f1f73e7ff28eb260306e0489d72b56c003d1cc68 Mon Sep 17 00:00:00 2001 From: aiudirog Date: Wed, 8 Mar 2023 20:34:43 -0500 Subject: [PATCH] Fixed utils/build-dists.py which was broken by 49ae7c7 (#316) * Fixed utils/build-dists.py which was broken by 49ae7c7 Previously the async helpers imported AsyncOpenSearch and therefore failed to import anytime it did Signed-off-by: Roger Aiudi * Refactor async helpers try block to a simple if statement Signed-off-by: Roger Aiudi * Remove newline to pass black Signed-off-by: Roger Aiudi --------- Signed-off-by: Roger Aiudi --- opensearchpy/helpers/__init__.py | 9 ++------- utils/build-dists.py | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/opensearchpy/helpers/__init__.py b/opensearchpy/helpers/__init__.py index 2aff0e3e..94771696 100644 --- a/opensearchpy/helpers/__init__.py +++ b/opensearchpy/helpers/__init__.py @@ -57,11 +57,8 @@ __all__ = [ ] -try: - # Asyncio only supported on Python 3.6+ - if sys.version_info < (3, 6): - raise ImportError - +# Asyncio only supported on Python 3.6+ +if sys.version_info >= (3, 6): from .._async.helpers import ( async_bulk, async_reindex, @@ -70,5 +67,3 @@ try: ) __all__ += ["async_scan", "async_bulk", "async_reindex", "async_streaming_bulk"] -except (ImportError, SyntaxError): - pass diff --git a/utils/build-dists.py b/utils/build-dists.py index 096505b4..e6706c57 100644 --- a/utils/build-dists.py +++ b/utils/build-dists.py @@ -105,11 +105,12 @@ def test_dist(dist): f"from {dist_name} import AsyncOpenSearch", expect_exit_code=256, ) + + # Ensure async helpers are available regardless of aiohttp installation run( venv_python, "-c", f"from {dist_name}.helpers import async_scan, async_bulk, async_streaming_bulk, async_reindex", - expect_exit_code=256, ) # Install aiohttp and see that async is now available