Skip to content

Commit 745e8e3

Browse files
authored
Check package will upload correctly to PyPI (#25)
1 parent 82af667 commit 745e8e3

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

.github/workflows/tests.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ jobs:
1818
- name: Lint code
1919
run: nox -s lint
2020

21+
package:
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 10
24+
25+
steps:
26+
- name: "Checkout repository"
27+
uses: actions/checkout@v4
28+
29+
- name: "Setup Python"
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: "3.x"
33+
cache: "pip"
34+
35+
- name: "Check packages"
36+
run: |
37+
python -m pip install -U pip setuptools wheel build twine rstcheck
38+
python -m build
39+
# Our Python example shows a REPL and is not valid Python
40+
rstcheck --ignore-languages python README.rst
41+
python -m twine check dist/*
42+
2143
docs:
2244
runs-on: ubuntu-latest
2345
steps:

README.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
.. raw:: html
2-
3-
<img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png">
4-
5-
61
Elasticsearch Serverless Python Client
7-
===========================
2+
======================================
83

94
.. image:: https://img.shields.io/pypi/v/elasticsearch-serverless
105
:target: https://pypi.org/project/elasticsearch-serverless
@@ -76,10 +71,10 @@ Quick Start
7671
7772
# Import the client from the 'elasticsearch' module
7873
>>> from elasticsearch_serverless import Elasticsearch
79-
74+
8075
# Instantiate a client instance
8176
>>> client = Elasticsearch("http://localhost:9200")
82-
77+
8378
# Call an API, in this example `info()`
8479
>>> resp = client.info()
8580

elasticsearch_serverless/_sync/client/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# Default User-Agent used by the client
6262
USER_AGENT = create_user_agent("elasticsearch-py", __versionstr__)
6363

64-
_TYPE_HOST = Union[str, Mapping, NodeConfig]
64+
_TYPE_HOST = Union[str, Mapping[str, Union[str, int]], NodeConfig]
6565

6666
_TRANSPORT_OPTIONS = {
6767
"api_key",

elasticsearch_serverless/helpers/actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def _process_bulk_chunk_success(
262262
if not ok and raise_on_error and status_code not in ignore_status:
263263
# include original document source
264264
if len(data) > 1:
265-
item["data"] = data[1] # type: ignore[misc]
265+
item["data"] = data[1]
266266
errors.append({op_type: item})
267267

268268
if ok or not errors:
@@ -299,7 +299,7 @@ def _process_bulk_chunk_error(
299299
op_type, action = data[0].copy().popitem()
300300
info = {"error": err_message, "status": error.status_code, "exception": error}
301301
if op_type != "delete" and len(data) > 1:
302-
info["data"] = data[1] # type: ignore[misc]
302+
info["data"] = data[1]
303303
info.update(action)
304304
exc_errors.append({op_type: info})
305305

noxfile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
"test_elasticsearch_serverless/",
2828
"utils/",
2929
)
30+
# Allow building aiohttp when no wheels are available (eg. for recent Python versions)
31+
INSTALL_ENV = {"AIOHTTP_NO_EXTENSIONS": "1"}
3032

3133

3234
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
3335
def test(session):
34-
session.install(".[dev]")
36+
session.install(".[dev]", env=INSTALL_ENV, silent=False)
3537

3638
junit_xml = os.path.join(
3739
SOURCE_DIR, "junit", "elasticsearch-serverless-python-junit.xml"
@@ -72,7 +74,7 @@ def lint(session):
7274
session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES)
7375

7476
# Workaround to make '-r' to still work despite uninstalling aiohttp below.
75-
session.install(".[async,requests]")
77+
session.install(".[async,requests]", env=INSTALL_ENV)
7678

7779
# Run mypy on the package and then the type examples separately for
7880
# the two different mypy use-cases, ourselves and our users.

0 commit comments

Comments
 (0)