Skip to content

Check package will upload correctly to PyPI #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 3 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
.. raw:: html

<img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png">


Elasticsearch Serverless Python Client
===========================
======================================

.. image:: https://img.shields.io/pypi/v/elasticsearch-serverless
:target: https://pypi.org/project/elasticsearch-serverless
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion elasticsearch_serverless/_sync/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions elasticsearch_serverless/helpers/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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})

Expand Down
6 changes: 4 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down