diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3aaeca3..305f4d8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,6 +18,28 @@ jobs: - name: Lint code run: nox -s lint + package: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Setup Python" + uses: actions/setup-python@v4 + with: + python-version: "3.x" + cache: "pip" + + - name: "Check packages" + run: | + python -m pip install -U pip setuptools wheel build twine rstcheck + python -m build + # Our Python example shows a REPL and is not valid Python + rstcheck --ignore-languages python README.rst + python -m twine check dist/* + docs: runs-on: ubuntu-latest steps: diff --git a/README.rst b/README.rst index 51c0bfb..7bffe47 100644 --- a/README.rst +++ b/README.rst @@ -1,10 +1,5 @@ -.. raw:: html - - - - Elasticsearch Serverless Python Client -=========================== +====================================== .. image:: https://img.shields.io/pypi/v/elasticsearch-serverless :target: https://pypi.org/project/elasticsearch-serverless @@ -76,10 +71,10 @@ Quick Start # Import the client from the 'elasticsearch' module >>> from elasticsearch_serverless import Elasticsearch - + # Instantiate a client instance >>> client = Elasticsearch("http://localhost:9200") - + # Call an API, in this example `info()` >>> resp = client.info() diff --git a/elasticsearch_serverless/_sync/client/utils.py b/elasticsearch_serverless/_sync/client/utils.py index f950045..ad890a4 100644 --- a/elasticsearch_serverless/_sync/client/utils.py +++ b/elasticsearch_serverless/_sync/client/utils.py @@ -61,7 +61,7 @@ # Default User-Agent used by the client USER_AGENT = create_user_agent("elasticsearch-py", __versionstr__) -_TYPE_HOST = Union[str, Mapping, NodeConfig] +_TYPE_HOST = Union[str, Mapping[str, Union[str, int]], NodeConfig] _TRANSPORT_OPTIONS = { "api_key", diff --git a/elasticsearch_serverless/helpers/actions.py b/elasticsearch_serverless/helpers/actions.py index a218c5e..100ae2f 100644 --- a/elasticsearch_serverless/helpers/actions.py +++ b/elasticsearch_serverless/helpers/actions.py @@ -262,7 +262,7 @@ def _process_bulk_chunk_success( if not ok and raise_on_error and status_code not in ignore_status: # include original document source if len(data) > 1: - item["data"] = data[1] # type: ignore[misc] + item["data"] = data[1] errors.append({op_type: item}) if ok or not errors: @@ -299,7 +299,7 @@ def _process_bulk_chunk_error( op_type, action = data[0].copy().popitem() info = {"error": err_message, "status": error.status_code, "exception": error} if op_type != "delete" and len(data) > 1: - info["data"] = data[1] # type: ignore[misc] + info["data"] = data[1] info.update(action) exc_errors.append({op_type: info}) diff --git a/noxfile.py b/noxfile.py index ccaca59..1054305 100644 --- a/noxfile.py +++ b/noxfile.py @@ -27,11 +27,13 @@ "test_elasticsearch_serverless/", "utils/", ) +# Allow building aiohttp when no wheels are available (eg. for recent Python versions) +INSTALL_ENV = {"AIOHTTP_NO_EXTENSIONS": "1"} @nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"]) def test(session): - session.install(".[dev]") + session.install(".[dev]", env=INSTALL_ENV, silent=False) junit_xml = os.path.join( SOURCE_DIR, "junit", "elasticsearch-serverless-python-junit.xml" @@ -72,7 +74,7 @@ def lint(session): session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES) # Workaround to make '-r' to still work despite uninstalling aiohttp below. - session.install(".[async,requests]") + session.install(".[async,requests]", env=INSTALL_ENV) # Run mypy on the package and then the type examples separately for # the two different mypy use-cases, ourselves and our users.