Skip to content

Commit 59d2d4a

Browse files
committed
add ruff + mypy to ci
1 parent cb64d2b commit 59d2d4a

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
typecheck:
8+
name: Type check
9+
runs-on: ubuntu-24.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.13"
15+
- uses: pypa/hatch@install
16+
- run: hatch run types:check
17+
fmt:
18+
name: Format and lint
19+
runs-on: ubuntu-24.04
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
- uses: pypa/hatch@install
26+
- run: hatch fmt --check

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ path = "src/cleanlab_codex/__about__.py"
4040
[tool.hatch.envs.types]
4141
extra-dependencies = [
4242
"mypy>=1.0.0",
43+
"pytest",
44+
"llama-index-core",
4345
]
4446
[tool.hatch.envs.types.scripts]
4547
check = "mypy --install-types --non-interactive {args:src/cleanlab_codex tests}"

src/cleanlab_codex/utils/llamaindex.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
from llama_index.core.bridge.pydantic import BaseModel, FieldInfo, create_model
77

88

9-
def get_function_schema(name: str, func: Callable[..., Any], tool_properties: dict[str, Any]) -> type[BaseModel]:
9+
def get_function_schema(
10+
name: str, func: Callable[..., Any], tool_properties: dict[str, Any]
11+
) -> type[BaseModel]:
1012
fields = {}
1113
params = signature(func).parameters
1214
for param_name in params:
@@ -27,4 +29,4 @@ def get_function_schema(name: str, func: Callable[..., Any], tool_properties: di
2729
FieldInfo(default=param_default, description=description),
2830
)
2931

30-
return create_model(name, **fields)
32+
return create_model(name, **fields) # type: ignore

tests/test_codex.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111

1212
@pytest.fixture
1313
def mock_client() -> Generator[_Codex, None, None]:
14-
with patch("cleanlab_codex.codex.init_codex_client", return_value=MagicMock()) as mock:
14+
with patch(
15+
"cleanlab_codex.codex.init_codex_client", return_value=MagicMock()
16+
) as mock:
1517
yield mock
1618

1719

1820
def test_query_read_only(mock_client: _Codex):
19-
mock_client.projects.entries.query.return_value = None
21+
mock_client.projects.entries.query.return_value = None # type: ignore
2022
codex = Codex("")
21-
res = codex.query("What is the capital of France?", read_only=True, project_id=fake_project_id)
22-
mock_client.projects.entries.query.assert_called_once_with(fake_project_id, "What is the capital of France?")
23-
mock_client.projects.entries.add_question.assert_not_called()
23+
res = codex.query(
24+
"What is the capital of France?", read_only=True, project_id=fake_project_id
25+
)
26+
mock_client.projects.entries.query.assert_called_once_with( # type: ignore
27+
fake_project_id, "What is the capital of France?"
28+
)
29+
mock_client.projects.entries.add_question.assert_not_called() # type: ignore
2430
assert res == (None, None)

0 commit comments

Comments
 (0)