Skip to content

Commit 42d7db6

Browse files
committed
add precommit and start fixing types
1 parent 9fe000a commit 42d7db6

File tree

13 files changed

+7079
-30
lines changed

13 files changed

+7079
-30
lines changed

.github/workflows/pr-check.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Linting and Type Checking
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
PYTHON_VERSION: "3.10"
7+
UV_PROJECT_ENVIRONMENT: .venv
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
check-ai:
15+
name: Check thirdweb-ai
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ./python/thirdweb-ai
20+
steps:
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5
25+
26+
- name: Install Python
27+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
28+
with:
29+
enable-cache: true
30+
cache-dependency-glob: "uv.lock"
31+
32+
- name: Install the project
33+
run: uv sync --all-extras --dev
34+
35+
- name: Configure path
36+
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
37+
38+
- name: Run Ruff linter
39+
run: uv run ruff check --output-format=github .
40+
41+
- name: Run Ruff formatter
42+
run: uv run ruff format --check .
43+
44+
- name: Run Pyright check
45+
uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2
46+
with:
47+
version: PATH
48+
working-directory: ./python/thirdweb-ai
49+
50+
check-mcp:
51+
name: Check thirdweb-mcp
52+
runs-on: ubuntu-latest
53+
defaults:
54+
run:
55+
working-directory: ./python/thirdweb-mcp
56+
steps:
57+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
58+
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5
61+
62+
- name: Install Python
63+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
64+
with:
65+
enable-cache: true
66+
cache-dependency-glob: "uv.lock"
67+
68+
- name: Install the project
69+
run: uv sync --all-extras --dev
70+
71+
- name: Configure path
72+
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
73+
74+
- name: Run Ruff linter
75+
run: uv run ruff check --output-format=github .
76+
77+
- name: Run Ruff formatter
78+
run: uv run ruff format --check .
79+
80+
- name: Run Pyright check
81+
uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2
82+
with:
83+
version: PATH
84+
working-directory: ./python/thirdweb-mcp

.pre-commit-config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
# thirdweb-ai linting
5+
- id: ruff-check-ai
6+
name: ruff check (thirdweb-ai)
7+
entry: bash -c 'cd python/thirdweb-ai && uv run ruff check --fix .'
8+
language: system
9+
pass_filenames: false
10+
files: ^python/thirdweb-ai/
11+
- id: ruff-format-ai
12+
name: ruff format (thirdweb-ai)
13+
entry: bash -c 'cd python/thirdweb-ai && uv run ruff format .'
14+
language: system
15+
pass_filenames: false
16+
files: ^python/thirdweb-ai/
17+
18+
# thirdweb-mcp linting
19+
- id: ruff-check-mcp
20+
name: ruff check (thirdweb-mcp)
21+
entry: bash -c 'cd python/thirdweb-mcp && uv run ruff check --fix .'
22+
language: system
23+
pass_filenames: false
24+
files: ^python/thirdweb-mcp/
25+
- id: ruff-format-mcp
26+
name: ruff format (thirdweb-mcp)
27+
entry: bash -c 'cd python/thirdweb-mcp && uv run ruff format .'
28+
language: system
29+
pass_filenames: false
30+
files: ^python/thirdweb-mcp/
31+
32+
# thirdweb-ai type checking
33+
- id: pyright-ai
34+
name: pyright (thirdweb-ai)
35+
entry: bash -c 'cd python/thirdweb-ai && uv run pyright'
36+
language: system
37+
pass_filenames: false
38+
files: ^python/thirdweb-ai/
39+
40+
# thirdweb-mcp type checking
41+
- id: pyright-mcp
42+
name: pyright (thirdweb-mcp)
43+
entry: bash -c 'cd python/thirdweb-mcp && uv run pyright'
44+
language: system
45+
pass_filenames: false
46+
files: ^python/thirdweb-mcp/

python/examples/adapter_google_adk/example.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ async def setup_agent() -> Runner:
4343
agent = LlmAgent(
4444
model=LiteLlm(model="gpt-4o-mini"),
4545
name="thirdweb_insight_agent",
46-
# Convert BaseTool to the expected type for LlmAgent
47-
tools=adk_tools, # type: ignore
46+
tools=adk_tools,
4847
)
4948

5049
# Set up session
@@ -68,9 +67,7 @@ async def call_agent(query: str) -> None:
6867

6968
for event in events:
7069
if (
71-
hasattr(event, "is_final_response")
72-
and event.is_final_response()
73-
and (event.content and hasattr(event.content, "parts") and event.content.parts)
70+
event.is_final_response()
7471
):
7572
final_response = event.content.parts[0].text
7673
print("Agent Response: ", final_response)

python/examples/adapter_google_adk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Example of using thirdweb_ai with Google ADK"
55
authors = [{ name = "thirdweb", email = "[email protected]" }]
66
requires-python = "~=3.10"
77
dependencies = [
8-
"thirdweb-ai[google-adk]"
8+
"thirdweb-ai[google-adk]>=0.1.17"
99
]
1010

1111
[tool.uv]

0 commit comments

Comments
 (0)