From 26efbae7c54219b68b56fc20264fd6af4c9006d9 Mon Sep 17 00:00:00 2001 From: Sean Schaefer Date: Mon, 9 Dec 2024 15:59:29 -0700 Subject: [PATCH] ci: add pyright check to pull request workflow --- .github/workflows/pull-request.yaml | 12 +++++++++--- tws/_async/client.py | 7 +++++++ tws/_sync/client.py | 7 +++++++ tws/base/client.py | 4 ---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 8c3d105..c22b815 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -29,11 +29,17 @@ jobs: - name: Install dependencies run: poetry install + - name: Add Poetry Python binary to PATH + run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH + - name: Lint - run: poetry run ruff check + run: ruff check - name: Check formatting - run: poetry run ruff format --check + run: ruff format --check + + - name: Type check + uses: jakebailey/pyright-action@v2 - name: Test - run: poetry run pytest --cov=./ \ No newline at end of file + run: pytest --cov=./ \ No newline at end of file diff --git a/tws/_async/client.py b/tws/_async/client.py index 2a5fd9c..86bc7b1 100644 --- a/tws/_async/client.py +++ b/tws/_async/client.py @@ -1,13 +1,20 @@ from supabase import create_async_client as create_async_supabase_client +from supabase import AsyncClient as SupabaseAsyncClient, AsyncClientOptions from tws.base.client import TWSClient, ClientException class AsyncClient(TWSClient): + api_client_options: AsyncClientOptions + api_client: SupabaseAsyncClient + @classmethod async def create(cls, public_key: str, secret_key: str, api_url: str): self = cls(public_key, secret_key, api_url) try: + self.api_client_options = AsyncClientOptions( + headers={"Authorization": secret_key} + ) self.api_client = await create_async_supabase_client( api_url, public_key, self.api_client_options ) diff --git a/tws/_sync/client.py b/tws/_sync/client.py index fefb657..0997fb8 100644 --- a/tws/_sync/client.py +++ b/tws/_sync/client.py @@ -1,13 +1,20 @@ from supabase import create_client as create_supabase_client +from supabase import Client as SyncSupabaseClient, ClientOptions from tws.base.client import TWSClient, ClientException class SyncClient(TWSClient): + api_client_options: ClientOptions + api_client: SyncSupabaseClient + @classmethod def create(cls, public_key: str, secret_key: str, api_url: str): self = cls(public_key, secret_key, api_url) try: + self.api_client_options = ClientOptions( + headers={"Authorization": secret_key} + ) self.api_client = create_supabase_client( api_url, public_key, self.api_client_options ) diff --git a/tws/base/client.py b/tws/base/client.py index 37f9216..9ffdd51 100644 --- a/tws/base/client.py +++ b/tws/base/client.py @@ -1,7 +1,5 @@ import re -from supabase import ClientOptions - # TODO something better than Exception? class ClientException(Exception): @@ -28,5 +26,3 @@ def __init__( r"^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$", secret_key ): raise ClientException("Malformed secret key") - - self.api_client_options = ClientOptions(headers={"Authorization": secret_key})