diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7ccd69b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Generate GitHub App token + id: app-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.DEPENDABOT_APP_ID }} + private-key: ${{ secrets.DEPENDABOT_APP_PRIVATE_KEY }} + owner: gradientlabs-ai + + - name: Configure git to use HTTPS for gradientlabs-ai repos + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + git config --global url."https://x-access-token:${GH_TOKEN}@github.com/gradientlabs-ai/".insteadOf "ssh://git@github.com/gradientlabs-ai/" + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: uv sync + + - name: Check formatting + run: uvx ruff format --check . + + - name: Lint + run: uvx ruff check . + + - name: Run unit tests + run: | + if [ -d "tests" ]; then + uv run pytest tests/ -m unit || [ $? -eq 5 ] # exit 5 means no tests selected; treat as success + else + echo "No tests directory, skipping" + fi diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 0c182e0..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Run Python Tests - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Check out - uses: actions/checkout@v4 - - - name: Install uv - uses: astral-sh/setup-uv@v5 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version-file: "pyproject.toml" - - - name: Add PyTest - run: uv add pytest - - - name: Run tests - run: uv run pytest tests diff --git a/pyproject.toml b/pyproject.toml index 924e642..66510f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "gradient-labs" -version = "0.11.8" +version = "0.12.0" description = "Python bindings for the Gradient Labs API" readme = "README.md" requires-python = ">=3.9,<4.0" @@ -23,10 +23,10 @@ members = ["examples/tools"] [tool.uv] constraint-dependencies = [ "urllib3>=2.7.0", - "starlette>=0.49.1", + "starlette>=1.3.1", "h11>=0.16.0", "idna>=3.15", ] [tool.ruff.lint] -ignore = ["D100", "D101"] +ignore = ["D100", "D101", "F403", "F405"] diff --git a/src/gradient_labs/_conversation_add_message.py b/src/gradient_labs/_conversation_add_message.py index e69e7ba..78a45af 100644 --- a/src/gradient_labs/_conversation_add_message.py +++ b/src/gradient_labs/_conversation_add_message.py @@ -1,4 +1,4 @@ -from typing import Optional, Any, List +from typing import Optional, List from datetime import datetime from dataclasses import dataclass, field diff --git a/src/gradient_labs/client.py b/src/gradient_labs/client.py index 0d4c167..fb9ac7c 100644 --- a/src/gradient_labs/client.py +++ b/src/gradient_labs/client.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, List +from typing import Optional, List from ._article_delete import delete_article from ._article_set_status import set_article_usage_status, SetArticleUsageStatusParams @@ -28,8 +28,6 @@ start_outbound_conversation, StartOutboundConversationParams, StartOutboundConversationResponse, - CustomerSource, - SupportPlatform, ) from ._handoff_target_upsert import upsert_hand_off_target, UpsertHandOffTargetParams @@ -108,14 +106,9 @@ from .tool import * from .note import Note from .secret import Secret -from .resource_type import ResourceType, Scope, RefreshStrategy, SourceConfig +from .resource_type import ResourceType from .resource_source import ( ResourceSource, - SourceType, - SchemaUpdateStrategy, - ResourceHTTPDefinition, - ResourceHTTPBodyDefinition, - ResourceWebhookDefinition, ) from .webhook import Webhook, WebhookEvent @@ -487,9 +480,7 @@ def set_procedure_gated_version( params=params, ) - def unset_procedure_gated_version( - self, *, procedure_id: str, version: int - ) -> None: + def unset_procedure_gated_version(self, *, procedure_id: str, version: int) -> None: """unset_procedure_gated_version removes gated status from a version. Once unset, the version will no longer be used for A/B testing or served as a gated version. @@ -733,9 +724,7 @@ def delete_resource_source(self, *, id: str) -> None: # ==================== Traffic Group Operations ==================== - def create_traffic_group( - self, *, params: CreateTrafficGroupParams - ) -> TrafficGroup: + def create_traffic_group(self, *, params: CreateTrafficGroupParams) -> TrafficGroup: """create_traffic_group creates a new traffic group. Note: requires a `Management` API key.""" diff --git a/src/gradient_labs/webhook.py b/src/gradient_labs/webhook.py index 707f845..325685c 100644 --- a/src/gradient_labs/webhook.py +++ b/src/gradient_labs/webhook.py @@ -77,7 +77,7 @@ def parse_signature_header( timestamp, signatures = cls._get_timestamp_and_signatures( header, cls.SCHEME ) - except: + except Exception: return WebhookSignature(valid=False, timestamp=None) signed_payload = "%d.%s" % (timestamp, payload) diff --git a/uv.lock b/uv.lock index e2aef30..30e9dbb 100644 --- a/uv.lock +++ b/uv.lock @@ -10,7 +10,7 @@ members = [ constraints = [ { name = "h11", specifier = ">=0.16.0" }, { name = "idna", specifier = ">=3.15" }, - { name = "starlette", specifier = ">=0.49.1" }, + { name = "starlette", specifier = ">=1.3.1" }, { name = "urllib3", specifier = ">=2.7.0" }, ] @@ -128,7 +128,7 @@ wheels = [ [[package]] name = "gradient-labs" -version = "0.11.8" +version = "0.12.0" source = { editable = "." } dependencies = [ { name = "dataclasses-json" }, @@ -339,14 +339,14 @@ wheels = [ [[package]] name = "starlette" -version = "0.52.1" +version = "1.3.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/c4/68/79977123bb7be889ad680d79a40f339082c1978b5cfcf62c2d8d196873ac/starlette-0.52.1.tar.gz", hash = "sha256:834edd1b0a23167694292e94f597773bc3f89f362be6effee198165a35d62933", size = 2653702, upload-time = "2026-01-18T13:34:11.062Z" } +sdist = { url = "https://files.pythonhosted.org/packages/eb/e3/7c1dc7381d9f8ab7d854328ebfa884e62cb3f3d8549ddfd37c7814f42afa/starlette-1.3.1.tar.gz", hash = "sha256:05d0213193f2fbaae60e2ecb593b4add4262ad4e46536b54abe36f11a71724e0", size = 2703240, upload-time = "2026-06-12T09:23:11.602Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/81/0d/13d1d239a25cbfb19e740db83143e95c772a1fe10202dda4b76792b114dd/starlette-0.52.1-py3-none-any.whl", hash = "sha256:0029d43eb3d273bc4f83a08720b4912ea4b071087a3b48db01b7c839f7954d74", size = 74272, upload-time = "2026-01-18T13:34:09.188Z" }, + { url = "https://files.pythonhosted.org/packages/ec/bb/2799cc2ede3ed41131f8975621e7213dfc7ef4acbbaadfa440f32500c370/starlette-1.3.1-py3-none-any.whl", hash = "sha256:c7372aae11c3c3f26a42df7bd626cec2f47d03483d261d369516a615a53714c6", size = 73632, upload-time = "2026-06-12T09:23:10.017Z" }, ] [[package]]