diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 9776927..b918640 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -6,7 +6,7 @@ jobs: test: strategy: matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-latest, macos-latest, windows-latest ] python-version: ['3.10', '3.11', '3.12'] runs-on: ${{ matrix.os }} @@ -28,13 +28,13 @@ jobs: run: uv sync --all-extras --dev - name: Run style check - run: uv run ruff format --check --diff $(package) + run: uv run ruff format --check --diff extapi tests - name: Run ruff - run: uv run ruff check $(package) + run: uv run ruff check extapi tests - name: Run mypy - run: uv run mypy --enable-error-code ignore-without-code $(package) + run: uv run mypy --enable-error-code ignore-without-code extapi tests - name: Run deptry run: uv run deptry . -e 'env|\.env|venv|\.venv|\..+' @@ -42,49 +42,11 @@ jobs: - name: Run tests run: uv run pytest . - build-wheels: - name: Build wheels on ${{ matrix.os }} - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] - needs: - - test - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install uv - uses: astral-sh/setup-uv@v3 - - - uses: actions/setup-python@v5 - - - name: Install the project - run: uv sync --all-extras --dev - env: - UV_SYSTEM_PYTHON: 1 - - - name: Install cibuildwheel - run: pip install --upgrade cibuildwheel - - - name: Build wheels - run: python -m cibuildwheel --output-dir wheelhouse - env: - CIBW_BUILD: "cp310-* cp311-* cp312-*" - - - uses: actions/upload-artifact@v4 - with: - name: wheels-${{ matrix.os }} - path: ./wheelhouse/*.whl - publish: - name: Publish wheels + name: Publish to PyPI if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') needs: - - build-wheels + - test runs-on: ubuntu-latest steps: - name: Get tag @@ -106,26 +68,11 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel twine build - - uses: actions/download-artifact@v4 - with: - name: wheels-ubuntu-latest - path: wheels-ubuntu - - - uses: actions/download-artifact@v4 - with: - name: wheels-macos-latest - path: wheels-macos - - - uses: actions/download-artifact@v4 - with: - name: wheels-windows-latest - path: wheels-windows - - name: Publish dist run: | python -m build . -s - tree dist wheels-ubuntu wheels-macos wheels-windows - twine upload dist/* wheels-ubuntu/*.whl wheels-macos/*.whl wheels-windows/*.whl + tree dist + twine upload dist/* env: TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} @@ -136,7 +83,4 @@ jobs: prerelease: false title: ${{ steps.get_tag.outputs.TAG }} files: | - wheels-ubuntu/*.whl - wheels-macos/*.whl - wheels-windows/*.whl dist/* diff --git a/CHANGELOG.md b/CHANGELOG.md index bbaaf3e..0fe1ad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.1.6 +* moved to github + # 0.1.5 * removed unnecessary `asyncio.sleep` after the last retry in `RetryableExecutor.execute` diff --git a/README.md b/README.md index f6131c8..1477158 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # extapi +[![Build](https://github.com/ktsstudio/extapi/actions/workflows/actions.yaml/badge.svg?branch=main)](https://github.com/ktsstudio/extapi/actions) +[![PyPI](https://img.shields.io/pypi/v/extapi.svg)](https://pypi.python.org/pypi/extapi) + Library for performing HTTP calls to external systems. Made to be modular, extensible and easy to use. ## Installation diff --git a/extapi/_meta.py b/extapi/_meta.py index 4f982ed..6fcfaf2 100644 --- a/extapi/_meta.py +++ b/extapi/_meta.py @@ -1,4 +1,6 @@ import importlib.util +import sys +PY311 = sys.version_info >= (3, 11) has_open_telemetry = importlib.util.find_spec("opentelemetry") is not None has_prometheus = importlib.util.find_spec("prometheus_client") is not None diff --git a/extapi/http/abc.py b/extapi/http/abc.py index ab1511b..b382de7 100644 --- a/extapi/http/abc.py +++ b/extapi/http/abc.py @@ -1,12 +1,19 @@ import abc from collections.abc import Mapping -from typing import Any, Generic, Protocol, Self, TypeVar, runtime_checkable +from typing import Any, Generic, Protocol, TypeVar, runtime_checkable from multidict import CIMultiDict from yarl import URL +from extapi._meta import PY311 + from .types import RequestData, Response, StrOrURL +if PY311: + from typing import Self # type: ignore[attr-defined] +else: + from typing_extensions import Self + T_co = TypeVar("T_co", covariant=True) T_contr = TypeVar("T_contr", contravariant=True) T = TypeVar("T") diff --git a/extapi/http/types.py b/extapi/http/types.py index 789f5ff..6a7dec6 100644 --- a/extapi/http/types.py +++ b/extapi/http/types.py @@ -6,7 +6,6 @@ Generic, Literal, Protocol, - Self, TypeVar, runtime_checkable, ) @@ -14,6 +13,13 @@ from multidict import CIMultiDict from yarl import URL +from extapi._meta import PY311 + +if PY311: + from typing import Self # type: ignore[attr-defined] +else: + from typing_extensions import Self + HttpMethod = Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | str StrOrURL = str | URL diff --git a/extapi/limiters/concurrency/abc.py b/extapi/limiters/concurrency/abc.py index 0f89a49..a8a6621 100644 --- a/extapi/limiters/concurrency/abc.py +++ b/extapi/limiters/concurrency/abc.py @@ -1,5 +1,12 @@ import abc -from typing import Protocol, Self +from typing import Protocol + +from extapi._meta import PY311 + +if PY311: + from typing import Self # type: ignore[attr-defined] +else: + from typing_extensions import Self class AbstractSemaphore(metaclass=abc.ABCMeta): diff --git a/pyproject.toml b/pyproject.toml index f04ba14..63f9a98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "extapi" -version = "0.1.5" +version = "0.1.6b1" description = "External API library" authors = [ { name = "KTS", email = "hello@kts.tech" } @@ -25,6 +25,7 @@ readme = "README.md" dependencies = [ "multidict", "yarl", + "typing-extensions; python_version < '3.11'", ] [project.optional-dependencies] diff --git a/tests/exthttp/test_abstract.py b/tests/exthttp/test_abstract.py index 6058799..d7339cd 100644 --- a/tests/exthttp/test_abstract.py +++ b/tests/exthttp/test_abstract.py @@ -1,11 +1,17 @@ -from typing import Any, assert_type +from typing import Any import pytest from multidict import CIMultiDict +from extapi._meta import PY311 from extapi.http.abc import AbstractExecutor, Addon from extapi.http.types import RequestData, Response +if PY311: + from typing import assert_type # type: ignore[attr-defined] +else: + from typing_extensions import assert_type + class TestAbstractExecutor: @pytest.mark.parametrize("method", ["get", "post", "put", "patch", "delete"])